android常见编释错误解决

下载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配置:

  1. compileSdkVersion与buildToolsVersion不一致;
  2. build.gradle中 classpath配置的gradle版本与Android Studio使用的版本要一致
  3. 可能是修改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等依赖包引入即可。

 

总结大部分问题都是:

  1. build.gradle中 classpath配置的gradle版本与Android Studio使用的版本
  2. compileSdkVersion与buildToolsVersion不一致;
  3. 可能是修改android sdk使用的版本号不对。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值