以下是本人导入工程项目中碰到的问题,仅在此做个记录,不保证涵盖所有问题,解决方法是别人提供,本人验证通过。
如果遇到按照如下方法解决不了的,烦请自行再搜索解决。
1.错误提示如下:
ERROR: Could not find com.android.tools.build:gradle:3.5.1.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.jar
Required by:
project :
Add Google Maven repository and sync project
Open File
原因:程序同步更新gradle包的时候需要引用google的代码库。
解决:在build.gradle配置中添加即可。
原build.gradle如下:
修改后如下:
2.错误提示如下:
ERROR: Minimum supported Gradle version is 5.4.1. Current version is 4.8.
Please fix the project's Gradle settings.
Fix Gradle wrapper and re-import project
Open Gradle wrapper properties
Gradle settings
原因:Gradle要求的最低版本为5.4.1,而系统中最高的版本只是4.8
解决:在AS项目的Project选项下找到gradle-wrapper.properties,将4.8修改成5.4.1即可(具体要使用哪个版本可到:https://services.gradle.org/distributions/ 查看)
修改前的gradle-wrapper.properties
修改后的gradle-wrapper.properties
3.错误提示如下:
ERROR: The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
Remove minSdkVersion and sync project
Affected Modules:
原因:AS3.0 以后不能在AndroidManifest.xml设置这些,必须在gradle里设置
解决:把AndroidManifest.xml中sdk的最小版本设置都删掉
修改前的AndroidManifest.xml
修改后的AndroidManifest.xml
4.错误提示:
Lint found fatal errors while assembling a release target.
To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
原因:AS在release版本中找到了一个很严重的错误。
解决:解决这个在lint发现的问题,或者修改生成脚本。这边采用生成脚本方式解决,最好用另外一种方式确定下根因。
修改前的build.gradle(Module:xxx)
修改后的build.gradle(Module:xxx)
【注】
解决方案是参考别人的,以下提供参考链接:
1.https://www.jianshu.com/p/c2688734292a
2.https://blog.csdn.net/yuge8930/article/details/85336450