下载andorid的项目,编释常见问题解决:
错误1:Error:Gradle version 2.2 is required. Current version is 2.10. If using the gradle wrapper, try editing the distributionUrl in D:\stethoscope\lepu_stethoscopic-7be32cd9193fb35f254f79e7f8da53ca8bf6993f\gradle\wrapper\gradle-wrapper.properties to gradle-2.2-all.zip.
解决: build.gradle中 classpath配置的gradle版本与Android Studio使用的版本要一致。不知道gradle版本的,新建一下MyApp项目编释试试就知道。
build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
Android Studio:File>Settings
参考:https://blog.csdn.net/weixin_35789435/article/details/52119008
错误2:Error:Cause: failed to find target with hash string 'android-21'
解决:最理解,就下载这个版本的android SDK;
错误2.1:Error:failed to find Build Tools revision 21.1.1
<a href="install.build.tools">Install Build Tools 21.1.1 and sync project</a>
解决:修改Build Tools的版本; File>Project Structure
设置见:https://blog.csdn.net/xiaoxiang22/article/details/102780777
错误2.2:Error:Unable to find method 'com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V'.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li><li>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.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
解决:见错误1的解决方法
错误2.3:Error:Could not find com.android.tools.build:gradle:2.10.
Searched in the following locations:
file:/D:/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.10/gradle-2.10.pom
file:/D:/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.10/gradle-2.10.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.10/gradle-2.10.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.10/gradle-2.10.jar
Required by:
:lepu_stethoscopic-7be32cd9193fb35f254f79e7f8da53ca8bf6993f:unspecified
解决:见错误1的解决方法
错误3:Module not backed by gradle
解决:见错误1的解决方法
错误4:A problem occurred configuring project ':app'.
解决:检查build.gradle配置:
- compileSdkVersion与buildToolsVersion不一致;
- build.gradle中 classpath配置的gradle版本与Android Studio使用的版本要一致
- 可能是修改android sdk使用的版本号不对。
错误5:Could not find any version that matches com.android.support:design:29.+.
解决:把sdk改为特定的版本,更新后即可.File>Project Structure
设置见:https://blog.csdn.net/xiaoxiang22/article/details/102780777
错误6:Android Studio:Could not find any version that matches com.android.support:appcompat-v7:29.+.
解决:改一下正则匹配就行。
build.gradle
implementation 'com.android.support:appcompat-v7:+
设置见:https://blog.csdn.net/afireswallow/article/details/91129831
错误7:Execution failed for task ':lib_core:compileReleaseJavaWithJavac
解决: build.gradle修改匹配的android SDK,build.gradle可能有多个地方:
参考:https://blog.csdn.net/cq_async/article/details/73550733
错误8:Error:Cause: peer not authenticated
解决:gradle版本与IDE改为一致即可。
参考:https://www.jianshu.com/p/5d482c73fd91
错误9:解决error[22,0]Could not find method android() for arguments的方法
解决: build.gradle中去掉
android {
compileSdkVersion 22
buildToolsVersion '25.0.0'
dexOptions {
incremental true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig {
minSdkVersion 22
targetSdkVersion 22
}
productFlavors {
}
}
注释掉后重新编译通过。
参考1:https://blog.csdn.net/yanweju/article/details/72722064
参考2:https://blog.csdn.net/qq_40722232/article/details/78299805
其他缺依赖包的错误,AndroidStudio增加下载依赖包的说明:
错误10:Error:(3, 23) 错误: 程序包com.google.gson不存在
解决:
https://blog.csdn.net/qq_36418170/article/details/81430095
在AndroidStudio中为项目添加Gson架包
提示:找依赖包可以用findjar:https://www.findjar.com/index.x
错误10.1:android:java.lang.NoClassDefFoundError: com.lidroid.xutils.HttpUtils 异常的解决
解决:下载xUtils 2.6.14 jar依赖包引入即可。
下载地址:https://pan.baidu.com/s/1gfL9qt9#list/path=%2F
错误10.2:Error:(6, 23) 错误: 程序包org.apache.http不存在
解决:下载httpmime-4.0.1.jar、httpcore-4.0.1.jar、apache-mime4j-0.6.jar等依赖包引入即可。
总结大部分问题都是:
- build.gradle中 classpath配置的gradle版本与Android Studio使用的版本
- compileSdkVersion与buildToolsVersion不一致;
- 可能是修改android sdk使用的版本号不对。