预期为BEGIN_ARRAY,但在第1行第2列路径$上为BEGIN_OBJECT,生成APK [英] Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ on generate APK

查看:63
本文介绍了预期为BEGIN_ARRAY,但在第1行第2列路径$上为BEGIN_OBJECT,生成APK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目在AVD上正确运行.但是当我尝试生成签名的APK时,gradle会出现此错误:

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

我已经多次使用此命令:gson.fromJson.但我找不到错误源. (哪个文件和哪一行).

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

那我怎么找到错误的原因

推荐答案

当我执行Gradle同步时,我在Android Studio 4.0中遇到了此问题.我通过执行以下操作修复了该问题:

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

  1. 打开顶级build.gradle并将gradle类路径更改为:

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

classpath 'com.android.tools.build:gradle:4.0.0'

  • 打开gradle\wrapper\gradle-wrapper.properties并将分发URL更改为:

  • Open gradle\wrapper\gradle-wrapper.properties and change the distribution URL to:

    distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
    

  • 从新项目复制到.idea\jarRepositories.xml
  • Copy in .idea\jarRepositories.xml from a new project
  • 不知道如何或为什么,但是它对我有用

    No idea how or why, but it worked for me

    这篇关于预期为BEGIN_ARRAY,但在第1行第2列路径$上为BEGIN_OBJECT,生成APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆