问题
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:
Open top-level
build.gradle
and change the gradle classpath to:classpath 'com.android.tools.build:gradle:4.0.0'
Open
gradle\wrapper\gradle-wrapper.properties
and change the distribution URL to:distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
- 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:
- Build -> Clean Project
- 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