Android ---------- 疑难杂症

1.  

ERROR: Unable to find method 'org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(Ljava/lang/String;)V'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

这个错误是:gradle 版本太低,导致有些依赖下不下来。我使用的版本为:

ext {
    compileSdkVersion = 26
    buildToolsVersion = "26.0.2"
    targetSdkVersion = 26
    versionCode = 1
    versionName = "3.7.8"
}


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

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

解决方法: 先将gradle配置为高版本

ext {
    compileSdkVersion = 28
    buildToolsVersion = "28.0.3"
    targetSdkVersion = 26
    versionCode = 1
    versionName = "3.7.8"
}


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


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

将所用依赖下载完成,然后在配置回低版本


2.

AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader$FrameCallback;","sources":[{}],"original":"UNEXPECTED TOP-LEVEL EXCEPTION:\ncom.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader$FrameCallback;\n","tool":"Dex"}
AGPBI: {"kind":"error","text":"com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader$FrameCallback;","sources":[{}]}

 参考文档:https://blog.csdn.net/xinpengfei521/article/details/79127387

问题:第三方依赖引用了okhttp3,而自己项目也引用了okhttp, 所以冲突了。

解决:

a. 首先查看哪些依赖引用了okhttp3;

在Android studio 的Terminal  输入:

gradlew app:dependencies

如果没有权限: chmod +x gradlew

可以看到retrofit2引用了okhttp3.接着找

发现我们引入的react-native 依赖中也引用了okhttp3. 

b. 处理重复引用依赖:移除多余的引用。

修改前:

修改后:

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值