ResoCoder / forecast-mvvm-android-kotlin

Forecast MVVM app as found in the free course.
https://www.youtube.com/playlist?list=PLB6lc7nQ1n4jTLDyU2muTBo8xk0dg0D_w
339 stars 163 forks source link

Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 38 column 5 path $.context.facets[0] #12

Closed ImAbhishekTomar closed 5 years ago

ImAbhishekTomar commented 5 years ago

Hello,

Kindly please help me on this issue I am using the same pattern as (@ResoCoder) your weather app. Thanks for sharing great tutorials.

Note: This is working when I remove all List type nested collection

My API : GET https://www.googleapis.com/customsearch/v1?key=INSERT_YOUR_API_KEY&cx=017576662512468239146:omuauf_lfve&q=lectures

ERROR

2019-02-13 09:36:55.613 24016-24199/com.prosofti.libro E/ActivityThread: Failed to find provider info for cn.teddymobile.free.anteater.den.provider
2019-02-13 09:36:56.982 24016-24016/com.prosofti.libro E/ANR_LOG: >>> msg's executing time is too long
2019-02-13 09:36:56.982 24016-24016/com.prosofti.libro E/ANR_LOG: Blocked msg = { when=-2s387ms what=100 target=android.app.ActivityThread$H obj=ActivityRecord{f2d94af token=android.os.BinderProxy@4d2fee7 {com.prosofti.libro/com.prosofti.libro.ui.MainActivity}} } , cost  = 1649 ms
2019-02-13 09:36:56.982 24016-24016/com.prosofti.libro E/ANR_LOG: >>>Current msg List is:
2019-02-13 09:36:56.983 24016-24016/com.prosofti.libro E/ANR_LOG: Current msg <1>  = { when=-1s632ms what=149 target=android.app.ActivityThread$H obj=android.os.BinderProxy@4d2fee7 }
2019-02-13 09:36:56.983 24016-24016/com.prosofti.libro E/ANR_LOG: Current msg <2>  = { when=-956ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2019-02-13 09:36:56.983 24016-24016/com.prosofti.libro E/ANR_LOG: Current msg <3>  = { when=-951ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2019-02-13 09:36:56.983 24016-24016/com.prosofti.libro E/ANR_LOG: Current msg <4>  = { when=-882ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2019-02-13 09:36:56.983 24016-24016/com.prosofti.libro E/ANR_LOG: Current msg <5>  = { when=-870ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2019-02-13 09:36:56.983 24016-24016/com.prosofti.libro E/ANR_LOG: Current msg <6>  = { when=-814ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2019-02-13 09:36:56.983 24016-24016/com.prosofti.libro E/ANR_LOG: Current msg <7>  = { when=-808ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2019-02-13 09:36:56.983 24016-24016/com.prosofti.libro E/ANR_LOG: Current msg <8>  = { when=-740ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2019-02-13 09:36:56.984 24016-24016/com.prosofti.libro E/ANR_LOG: Current msg <9>  = { when=-682ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2019-02-13 09:36:56.984 24016-24016/com.prosofti.libro E/ANR_LOG: Current msg <10>  = { when=-73ms what=0 target=android.os.Handler callback=kotlinx.coroutines.DispatchedContinuation }
2019-02-13 09:36:56.984 24016-24016/com.prosofti.libro E/ANR_LOG: >>>CURRENT MSG DUMP OVER<<<
2019-02-13 09:36:58.407 24016-24016/com.prosofti.libro E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.prosofti.libro, PID: 24016
    com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 38 column 5 path $.context.facets[0]
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
        at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:39)
        at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27)
        at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:122)
        at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:217)
        at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:116)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 38 column 5 path $.context.facets[0]
        at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215)
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) 
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) 
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) 
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) 
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) 
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) 
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) 
        at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:39) 
        at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27) 
        at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:122) 
        at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:217) 
        at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:116) 
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153) 
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
        at java.lang.Thread.run(Thread.java:764) 

MY JSON FORMAT

{
  "kind": "customsearch#search",
  "url": {
    "type": "application/json",
    "template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json"
  },
  "queries": {
    "request": [
      {
        "title": "Google Custom Search - lectures",
        "totalResults": "1070000000",
        "searchTerms": "lectures",
        "count": 10,
        "startIndex": 1,
        "inputEncoding": "utf8",
        "outputEncoding": "utf8",
        "safe": "off",
        "cx": "017576662512468239146:omuauf_lfve"
      }
    ],
    "nextPage": [
      {
        "title": "Google Custom Search - lectures",
        "totalResults": "1070000000",
        "searchTerms": "lectures",
        "count": 10,
        "startIndex": 11,
        "inputEncoding": "utf8",
        "outputEncoding": "utf8",
        "safe": "off",
        "cx": "017576662512468239146:omuauf_lfve"
      }
    ]
  },
  "context": {
    "title": "CS Curriculum",
    "facets": [
      [
        {
          "label": "lectures",
          "anchor": "Lectures",
          "label_with_op": "more:lectures"
        }
      ],
      [
        {
          "label": "assignments",
          "anchor": "Assignments",
          "label_with_op": "more:assignments"
        }
      ],
      [
        {
          "label": "reference",
          "anchor": "Reference",
          "label_with_op": "more:reference"
        }
      ]
    ]
  },
  "searchInformation": {
    "searchTime": 0.190076,
    "formattedSearchTime": "0.19",
    "totalResults": "1070000000",
    "formattedTotalResults": "1,070,000,000"
  },
  "items": [
    {
      "kind": "customsearch#result",
      "title": "Gibbons Lecture Series - The University of Auckland",
      "htmlTitle": "Gibbons \u003cb\u003eLecture\u003c/b\u003e Series - The University of Auckland",
      "link": "https://www.cs.auckland.ac.nz/gibbons_lectures/",
      "displayLink": "www.cs.auckland.ac.nz",
      "snippet": "The Department hosts an annual series of lectures intended to describe ongoing \nresearch in Computer Science to a wider public.",
      "htmlSnippet": "The Department hosts an annual series of \u003cb\u003electures\u003c/b\u003e intended to describe ongoing \u003cbr\u003e\nresearch in Computer Science to a wider public.",
      "formattedUrl": "https://www.cs.auckland.ac.nz/gibbons_lectures/",
      "htmlFormattedUrl": "https://www.cs.auckland.ac.nz/gibbons_\u003cb\u003electures\u003c/b\u003e/",
      "pagemap": {
        "cse_thumbnail": [
          {
            "width": "183",
            "height": "276",
            "src": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQ1cEgOaiWE8z9gPa_UwvJDTFtgyCL56V1fqljwshQdFfUsyI2CQve0Rdg"
          }
        ],
        "cse_image": [
          {
            "src": "https://www.cs.auckland.ac.nz/en/about/ourdepartment/gibbons-lectures/_jcr_content/par/image.img.jpg/1490740692929.jpg"
          }
        ]
      }
    },
    {
      "kind": "customsearch#result",
      "title": "Lectures",
      "htmlTitle": "\u003cb\u003eLectures\u003c/b\u003e",
      "link": "https://www.cis.upenn.edu/~cis160/current/lectures.html",
      "displayLink": "www.cis.upenn.edu",
      "snippet": "Lectures are held in LEVH101 (001) and CHEM102 (002) every Tuesday and \nThursday from 9:00-10:30 AM (001) and 1:30-3:00 PM (002). While lecture ...",
      "htmlSnippet": "\u003cb\u003eLectures\u003c/b\u003e are held in LEVH101 (001) and CHEM102 (002) every Tuesday and \u003cbr\u003e\nThursday from 9:00-10:30 AM (001) and 1:30-3:00 PM (002). While \u003cb\u003electure\u003c/b\u003e&nbsp;...",
      "cacheId": "k9487vOAo70J",
      "formattedUrl": "https://www.cis.upenn.edu/~cis160/current/lectures.html",
      "htmlFormattedUrl": "https://www.cis.upenn.edu/~cis160/current/\u003cb\u003electures\u003c/b\u003e.html",
      "pagemap": {
        "metatags": [
          {
            "viewport": "width=device-width, initial-scale=1.0"
          }
        ]
      },
      "labels": [
        {
          "name": "lectures",
          "displayName": "Lectures",
          "label_with_op": "more:lectures"
        }
      ]
    },
    {
      "kind": "customsearch#result",
      "title": "CS 50th Anniversary Distinguished Lecture Series | Computer ...",
      "htmlTitle": "CS 50th Anniversary Distinguished \u003cb\u003eLecture\u003c/b\u003e Series | Computer ...",
      "link": "https://www.cs.ubc.ca/news-events/distinguished-lecture-series",
      "displayLink": "www.cs.ubc.ca",
      "snippet": "UBC Computer Science is celebrating its 50th Anniversary! We are proud to \nhighlight our distinguished lectures along with many other exciting events that \nwill ...",
      "htmlSnippet": "UBC Computer Science is celebrating its 50th Anniversary! We are proud to \u003cbr\u003e\nhighlight our distinguished \u003cb\u003electures\u003c/b\u003e along with many other exciting events that \u003cbr\u003e\nwill&nbsp;...",
      "cacheId": "9PqoZD7VTcYJ",
      "formattedUrl": "https://www.cs.ubc.ca/news-events/distinguished-lecture-series",
      "htmlFormattedUrl": "https://www.cs.ubc.ca/news-events/distinguished-\u003cb\u003electure\u003c/b\u003e-series",
      "pagemap": {
        "cse_thumbnail": [
          {
            "width": "348",
            "height": "145",
            "src": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTmX4tS6x47LKjsoIz9cYhpWwPLMqz_LLxe78ZYYiC1RI6O6MR_D-TOos55"
          }
        ],
        "cse_image": [
          {
            "src": "https://www.cs.ubc.ca/sites/cs/files/imagecache/node_image/18924134402_622293178b_k.jpg"
          }
        ]
      }
    },
    {
      "kind": "customsearch#result",
      "title": "CSC2535S : lectures",
      "htmlTitle": "CSC2535S : \u003cb\u003electures\u003c/b\u003e",
      "link": "http://www.cs.toronto.edu/~hinton/csc2535/lectures.html",
      "displayLink": "www.cs.toronto.edu",
      "snippet": "CSC2535 Spring 2013 - Lectures. DRAFT LECTURE SCHEDULE: SUBJECT TO \nCHANGE. The final versions of the lecture notes will generally be posted on ...",
      "htmlSnippet": "CSC2535 Spring 2013 - \u003cb\u003eLectures\u003c/b\u003e. DRAFT \u003cb\u003eLECTURE\u003c/b\u003e SCHEDULE: SUBJECT TO \u003cbr\u003e\nCHANGE. The final versions of the \u003cb\u003electure\u003c/b\u003e notes will generally be posted on&nbsp;...",
      "cacheId": "N8wrLohIrBUJ",
      "formattedUrl": "www.cs.toronto.edu/~hinton/csc2535/lectures.html",
      "htmlFormattedUrl": "www.cs.toronto.edu/~hinton/csc2535/\u003cb\u003electures\u003c/b\u003e.html"
    },
    {
      "kind": "customsearch#result",
      "title": "John Hennessy and David Patterson Turing Lecture",
      "htmlTitle": "John Hennessy and David Patterson Turing \u003cb\u003eLecture\u003c/b\u003e",
      "link": "https://www.acm.org/hennessy-patterson-turing-lecture",
      "displayLink": "www.acm.org",
      "snippet": "2017 ACM A.M. Turing Award recipients John Hennessy and David Patterson \ndelivered the Turing Lecture on June 4 at ISCA 2018 in Los Angeles. The lecture\n ...",
      "htmlSnippet": "2017 ACM A.M. Turing Award recipients John Hennessy and David Patterson \u003cbr\u003e\ndelivered the Turing \u003cb\u003eLecture\u003c/b\u003e on June 4 at ISCA 2018 in Los Angeles. The \u003cb\u003electure\u003c/b\u003e\u003cbr\u003e\n&nbsp;...",
      "cacheId": "8V-Hwo9_hxkJ",
      "formattedUrl": "https://www.acm.org/hennessy-patterson-turing-lecture",
      "htmlFormattedUrl": "https://www.acm.org/hennessy-patterson-turing-\u003cb\u003electure\u003c/b\u003e",
      "pagemap": {
        "cse_thumbnail": [
          {
            "width": "225",
            "height": "225",
            "src": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRPBiOcm6qnq4LIENM30UWUCzSDFfEL-VC_ECkqKg6PxwVjwuzjvHAnsKI"
          }
        ],
        "metatags": [
          {
            "viewport": "width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no",
            "og:title": "John Hennessy and David Patterson Deliver Turing Lecture at ISCA 2018",
            "og:description": "webpage to host livestream of hennessy-patterson turing lecture",
            "og:type": "website",
            "og:image": "https://www.acm.org/images/acm_rgb_grad_pos_diamond.png",
            "twitter:card": "summary_large_image",
            "twitter:site": "@theofficialacm",
            "twitter:title": "John Hennessy and David Patterson Deliver Turing Lecture at ISCA 2018",
            "twitter:description": "webpage to host livestream of hennessy-patterson turing lecture",
            "twitter:image": "https://www.acm.org/images/acm_rgb_grad_pos_diamond.png",
            "og:url": "https://www.acm.org/hennessy-patterson-turing-lecture"
          }
        ],
        "cse_image": [
          {
            "src": "https://www.acm.org/images/acm_rgb_grad_pos_diamond.png"
          }
        ]
      }
    },
    {
      "kind": "customsearch#result",
      "title": "Neural Networks for Machine Learning Lecture 6a Overview of mini ...",
      "htmlTitle": "Neural Networks for Machine Learning \u003cb\u003eLecture\u003c/b\u003e 6a Overview of mini ...",
      "link": "https://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf",
      "displayLink": "www.cs.toronto.edu",
      "snippet": "Neural Networks for Machine Learning. Lecture 6a. Overview of mini-‐batch \ngradient descent. Geoffrey Hinton with. NiRsh Srivastava. Kevin Swersky ...",
      "htmlSnippet": "Neural Networks for Machine Learning. \u003cb\u003eLecture\u003c/b\u003e 6a. Overview of mini-‐batch \u003cbr\u003e\ngradient descent. Geoffrey Hinton with. NiRsh Srivastava. Kevin Swersky&nbsp;...",
      "cacheId": "ba4RKgQC1ywJ",
      "mime": "application/pdf",
      "fileFormat": "PDF/Adobe Acrobat",
      "formattedUrl": "https://www.cs.toronto.edu/~tijmen/csc321/.../lecture_slides_lec6.pdf",
      "htmlFormattedUrl": "https://www.cs.toronto.edu/~tijmen/csc321/.../\u003cb\u003electure\u003c/b\u003e_slides_lec6.pdf",
      "pagemap": {
        "cse_thumbnail": [
          {
            "width": "268",
            "height": "188",
            "src": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSX7xQ9ncedQsb8gM80HHUW8dGymK2BmBb-RAesbeRsJIfs4c0cNtDZw2k"
          }
        ],
        "metatags": [
          {
            "author": "Geoffrey Hinton",
            "producer": "Mac OS X 10.7.4 Quartz PDFContext",
            "creator": "PowerPoint",
            "creationdate": "D:20121009195946Z00'00'",
            "moddate": "D:20121009195946Z00'00'"
          }
        ],
        "cse_image": [
          {
            "src": "x-raw-image:///cc231a2fef4933107b440e830b5f4991fd92571d23d40bfddfc9c5bf7e94d803"
          }
        ]
      }
    },
    {
      "kind": "customsearch#result",
      "title": "Variational Inference",
      "htmlTitle": "Variational Inference",
      "link": "https://www.cs.princeton.edu/courses/archive/fall11/cos597C/lectures/variational-inference-i.pdf",
      "displayLink": "www.cs.princeton.edu",
      "snippet": "conjugate prior of the unit-variance likelihood. See the exponential family lecture.\n) – So, the variational posterior mean and variance of the cluster component k ...",
      "htmlSnippet": "conjugate prior of the unit-variance likelihood. See the exponential family \u003cb\u003electure\u003c/b\u003e.\u003cbr\u003e\n) – So, the variational posterior mean and variance of the cluster component k&nbsp;...",
      "cacheId": "AfaBncgk7Q8J",
      "mime": "application/pdf",
      "fileFormat": "PDF/Adobe Acrobat",
      "formattedUrl": "https://www.cs.princeton.edu/.../lectures/variational-inference-i.pdf",
      "htmlFormattedUrl": "https://www.cs.princeton.edu/.../\u003cb\u003electures\u003c/b\u003e/variational-inference-i.pdf",
      "pagemap": {
        "cse_thumbnail": [
          {
            "width": "312",
            "height": "162",
            "src": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSjet4MJt464QaxYAAokLCpStWuOyt-E79-l50KgHoGAFBwUyHZI6FfJME"
          }
        ],
        "metatags": [
          {
            "producer": "pdfTeX-1.40.10",
            "creator": "TeX",
            "creationdate": "D:20111012063100-04'00'",
            "moddate": "D:20111012063100-04'00'",
            "fullbanner": "This is pdfTeX, Version 3.1415926-1.40.10-2.2 (TeX Live 2009) kpathsea version 5.0.0"
          }
        ],
        "cse_image": [
          {
            "src": "x-raw-image:///fc1a71da5994e9924c9344d49e37bc39eea0689c233a4754ef95d41ff66be566"
          }
        ]
      },
      "labels": [
        {
          "name": "lectures",
          "displayName": "Lectures",
          "label_with_op": "more:lectures"
        }
      ]
    },
    {
      "kind": "customsearch#result",
      "title": "Lecture notes",
      "htmlTitle": "\u003cb\u003eLecture\u003c/b\u003e notes",
      "link": "https://www.cs.cornell.edu/courses/cs2110/2018fa/lecturenotes.html",
      "displayLink": "www.cs.cornell.edu",
      "snippet": "Lecture notes are usually posted the day/evening before the lecture. Please \ndownload the lecture notes the evening before a lecture, peruse them to get a \nsense ...",
      "htmlSnippet": "\u003cb\u003eLecture\u003c/b\u003e notes are usually posted the day/evening before the \u003cb\u003electure\u003c/b\u003e. Please \u003cbr\u003e\ndownload the \u003cb\u003electure\u003c/b\u003e notes the evening before a \u003cb\u003electure\u003c/b\u003e, peruse them to get a \u003cbr\u003e\nsense&nbsp;...",
      "cacheId": "3p0PREC6Ur4J",
      "formattedUrl": "https://www.cs.cornell.edu/courses/cs2110/2018fa/lecturenotes.html",
      "htmlFormattedUrl": "https://www.cs.cornell.edu/courses/cs2110/2018fa/\u003cb\u003electure\u003c/b\u003enotes.html",
      "labels": [
        {
          "name": "lectures",
          "displayName": "Lectures",
          "label_with_op": "more:lectures"
        }
      ]
    },
    {
      "kind": "customsearch#result",
      "title": "Stanford Engineering Everywhere | CS229 - Machine Learning",
      "htmlTitle": "Stanford Engineering Everywhere | CS229 - Machine Learning",
      "link": "https://see.stanford.edu/course/cs229",
      "displayLink": "see.stanford.edu",
      "snippet": "This course provides a broad introduction to machine learning and statistical \npattern recognition. Topics include: supervised learning (generative/\ndiscriminative ...",
      "htmlSnippet": "This course provides a broad introduction to machine learning and statistical \u003cbr\u003e\npattern recognition. Topics include: supervised learning (generative/\u003cbr\u003e\ndiscriminative&nbsp;...",
      "cacheId": "nle_87jqwxcJ",
      "formattedUrl": "https://see.stanford.edu/course/cs229",
      "htmlFormattedUrl": "https://see.stanford.edu/course/cs229",
      "pagemap": {
        "cse_thumbnail": [
          {
            "width": "148",
            "height": "208",
            "src": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQ2_-hJWbczpcTOUvBJuymIrbHevHrTlAL-EhyPo--xfmFh0F0Ts8iCmOc"
          }
        ],
        "metatags": [
          {
            "viewport": "width=device-width, initial-scale=1"
          }
        ],
        "cse_image": [
          {
            "src": "https://see.stanford.edu/Content/Images/Instructors/ng.jpg"
          }
        ]
      },
      "labels": [
        {
          "name": "lectures",
          "displayName": "Lectures",
          "label_with_op": "more:lectures"
        }
      ]
    },
    {
      "kind": "customsearch#result",
      "title": "CS 61A Lecture Notes Week 1 Topic: Functional programming ...",
      "htmlTitle": "CS 61A \u003cb\u003eLecture\u003c/b\u003e Notes Week 1 Topic: Functional programming ...",
      "link": "http://www-inst.eecs.berkeley.edu/~cs61a/reader/notes.pdf",
      "displayLink": "www-inst.eecs.berkeley.edu",
      "snippet": "In file cs61a/lectures/1.1/plural.scm. (define (plural wd). (if (equal? (last wd) 'y). (\nword (bl wd) 'ies). (word wd 's))). If is a special form that only evaluates one of ...",
      "htmlSnippet": "In file cs61a/\u003cb\u003electures\u003c/b\u003e/1.1/plural.scm. (define (plural wd). (if (equal? (last wd) &#39;y). (\u003cbr\u003e\nword (bl wd) &#39;ies). (word wd &#39;s))). If is a special form that only evaluates one of&nbsp;...",
      "cacheId": "6yJyKSd8x8wJ",
      "mime": "application/pdf",
      "fileFormat": "PDF/Adobe Acrobat",
      "formattedUrl": "www-inst.eecs.berkeley.edu/~cs61a/reader/notes.pdf",
      "htmlFormattedUrl": "www-inst.eecs.berkeley.edu/~cs61a/reader/notes.pdf",
      "pagemap": {
        "cse_thumbnail": [
          {
            "width": "360",
            "height": "140",
            "src": "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTU4BgOIpuhYC9rpIFP3_eusXRg562LYx1laHWtYC97xuXJM2MIOybF2qk"
          }
        ],
        "metatags": [
          {
            "producer": "GPL Ghostscript 8.63",
            "creationdate": "D:20090121094046-08'00'",
            "moddate": "D:20090121094046-08'00'",
            "creator": "dvips(k) 5.95a Copyright 2005 Radical Eye Software",
            "title": "notes.dvi"
          }
        ],
        "cse_image": [
          {
            "src": "x-raw-image:///d06c4d1f54d9e737500832a6ff0fcf0a9f1d68f7ffd63bba010533e8ffc9fc7f"
          }
        ]
      }
    }
  ]
}
linucksrox commented 5 years ago

It's hard to say without seeing your code, and this probably isn't the best place to ask your question because you're building a different app. But near the top of your error message I'm seeing ANR_LOG which mentions something about taking too long to execute. Does this help? https://stackoverflow.com/questions/51435390/runnable-is-not-being-executed-completely-after-the-delay-is-over-from-handlers

ImAbhishekTomar commented 5 years ago

Here is my code sample

SEARCH Response Root Class

data class SearchResponse(
        val context: Context, //If I disable this line the code is working
        val items: List<Item>, //If I disable this line the code is working
        val kind: String,
        val queries: Queries,
        val searchInformation: SearchInformation,
        val url: Url
)

API Configuration CODE

interface GoogleApiService {
    @GET("v1")
    fun getSearchResult(
        @Query("q") searchQuery:String,
        @Query("cx") searchEngineId:String="017576662512468239146:omuauf_lfve"
    ) : Deferred<SearchResponse>

    companion object {

        operator fun invoke(): GoogleApiService{

            val requestInterceptor=Interceptor{ chain ->
                val url=chain.request()
                        .url()
                        .newBuilder()
                        .addQueryParameter("key",GOOGLE_API_KEY)
                        .build()

                val request=chain.request()
                        .newBuilder()
                        .url(url)
                        .build()

                return@Interceptor chain.proceed(request)
            }

            val okHttpClient = OkHttpClient.Builder()
                    .addInterceptor(requestInterceptor)
                    .build()

            return Retrofit.Builder()
                    .client(okHttpClient)
                    .baseUrl("https://www.googleapis.com/customsearch/")
                    .addCallAdapterFactory(CoroutineCallAdapterFactory())
                    .addConverterFactory(GsonConverterFactory.create())
                    .build()
                    .create(GoogleApiService::class.java)
        }
    }

API CALL

override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        viewModel = ViewModelProviders.of(this).get(SearchViewModel::class.java)
        // TODO: Use the ViewModel
        val apiService=GoogleApiService()

        GlobalScope.launch(Dispatchers.Main) {
                val searchResponce = apiService.getSearchResult("lectures").await()
            txtMain.text=searchResponce.toString()
        }
    }
ImAbhishekTomar commented 5 years ago

My partial error is resolved when I convert my List in ArrayList my error is resolved but how can I create a class for red selected JSON?

JSON

screenshot 2019-02-13 at 10 56 32

Current Class

data class SearchResponse(
        val context: Context, //If I enable this line thro error
        val items: ArrayList<Item>, //If I enable this line thro error
        val kind: String,
        val queries: Queries,
        val searchInformation: SearchInformation,
        val url: Url
)

data class Context(
        val facets:  ArrayList<Any>, //This is showing error.....
        val title: String
)

data class Any(
        val anchor: String,
        val label: String,
        @SerializedName("label_with_op")
        val labelWithOp: String
)