Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ on generate APK

ぐ巨炮叔叔 提交于 2020-07-06 09:32:28

问题


My project is run on AVD properly. but when i try to generate signed APK, gradle get this error:

FAILURE: Build failed with an exception.

* What went wrong:
java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
> Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more 
log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

I've used this command many times: gson.fromJson. but i can't find error source. (which file and which line).

So how do I find the source of the error


回答1:


I got this problem in Android Studio 4.0 when I did a Gradle sync. I fixed it by doing the following:

  1. Open top-level build.gradle and change the gradle classpath to:

    classpath 'com.android.tools.build:gradle:4.0.0'
    
  2. Open gradle\wrapper\gradle-wrapper.properties and change the distribution URL to:

    distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
    
  3. Copy in .idea\jarRepositories.xml from a new project

No idea how or why, but it worked for me




回答2:


I got this error in Android Studio 4.0 when I did a Gradle sync after switching branches. I fixed it by doing this:

  1. Build -> Clean Project
  2. Sync Project with Gradle files



回答3:


I had the same problem when I tried to build a "signed release APK". I was using Android Studio Beta 4.0.

To fix the problem, I've upgraded to Beta 4.0 v4 and it resolved the problem.



来源:https://stackoverflow.com/questions/60485948/expected-begin-array-but-was-begin-object-at-line-1-column-2-path-on-generate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!