13

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

Iman Marashi
  • 5,593
  • 38
  • 51

4 Answers4

9

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

Sam
  • 40,644
  • 36
  • 176
  • 219
4

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
Sam
  • 40,644
  • 36
  • 176
  • 219
0

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.

odgatelmand
  • 393
  • 1
  • 5
  • 16
-1

i changed the place where my APKs generated inside and it's working fine now