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.youkuaiyun.com/xinpengfei521/article/details/79127387
问题:第三方依赖引用了okhttp3,而自己项目也引用了okhttp, 所以冲突了。
解决:
a. 首先查看哪些依赖引用了okhttp3;
在Android studio 的Terminal 输入:
gradlew app:dependencies
如果没有权限: chmod +x gradlew
可以看到retrofit2引用了okhttp3.接着找
发现我们引入的react-native 依赖中也引用了okhttp3.
b. 处理重复引用依赖:移除多余的引用。
修改前:
修改后: