Android Strudio 常见错误以及解决办法

错误一

Error:(19, 0) Gradle DSL method not found: 'android()'
Possible causes:<ul><li>The project 'Zhihu-Parallax-Animation-develop' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

解决

build.gradle:
buildscript {
    repositories {
        mavenCentral()
        maven { url "http://dl.bintray.com/populov/maven" }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0'
    }
}

allprojects {
    repositories {
        mavenCentral()
        maven { url "http://dl.bintray.com/populov/maven" }
    }
}

app/build.gradle:
apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName '1.0'
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.2.1'
}

Then run gradle:
gradle installDebug

错误二

Error:(16, 0) Gradle DSL method not found: 'runProguard()'
Possible causes:

The project 'GridViewPager' may be using a version of Gradle that does not contain the method.Gradle settings

The build file may be missing a Gradle plugin.Apply Gradle plugin

解决

Before upgrade build tools version:
dependencies {
        classpath 'com.android.tools.build:gradle:0.12.0'
    }

After upgrade build tools version:
dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }


Previous code :buildTypes {        
    release {            
          runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
Current code :buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

参考:http://stackoverflow.com/questions/27016385/error26-0-gradle-dsl-method-not-found-runproguard

错误三

Error:Configuration with name 'default' not found.

解决

http://stackoverflow.com/questions/22743582/error-configuration-with-name-default-not-found-in-android-studio

错误四

Error:(59) No resource identifier found for attribute 'strokeWidth' in package 'org.hybridsquad.droidlab'

解决

因为没有引入viewpagerindicator (把compile project(':library') 删除后,需要各种引用,否则会因为找不到某个类而报错)
http://www.tuicool.com/articles/ZrInyyI

错误五

Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Android\AS_sdk\build-tools\23.0.3\aapt.exe'' finished with non-zero exit value 1

解决

因为引用了重复的jar包,删除多余的jar包

错误六

Error:Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in D:\ll_s\github\lunbotu\Banner-master\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip
<a href="fixGradleVersionInWrapper">Fix Gradle wrapper and re-import project</a><br><a href="openGradleSettings">Gradle settings</a>

解决

在gradle下找到gradle-wrapper.properties,将下面的改为正确的就好
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip

错误七

Error:找不到引用的jar包资源  

解决

原因有二:
1.jar包版本低了,需要引入高版本的
2.资源找不到了

错误八

Error:Could not find com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0.
Searched in the following locations:
    file:/C:/Android/AndroidStudio/AS/gradle/m2repository/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.0/gradle-bintray-plugin-1.0.pom
    file:/C:/Android/AndroidStudio/AS/gradle/m2repository/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.0/gradle-bintray-plugin-1.0.jar
    https://repo1.maven.org/maven2/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.0/gradle-bintray-plugin-1.0.pom
    https://repo1.maven.org/maven2/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.0/gradle-bintray-plugin-1.0.jar
    http://dl.bintray.com/populov/maven/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.0/gradle-bintray-plugin-1.0.pom
    http://dl.bintray.com/populov/maven/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.0/gradle-bintray-plugin-1.0.jar
Required by:
    :Codecafe:unspecified

解决

在build.gradle文件中
dependencies{
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
}

上面那行classpath......与修改的
repositories{//此repositories来自buildscript{}和allprojects{}
    mavenCentral()
    maven { url "http://dl.bintray.com/populov/maven" }
}

可能有冲突,原本修改之前是 
repositories{
 jcenter()
}

错误九

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> When running gradle with java 5, 6 or 7, you must set the path to jdk8, either with property retrolambda.jdk or environment variable JAVA8_HOME

解决

1.需要jdk1.8
2.然后进AS->Project Structure->更改JDK location(这个好多人都容易忘记)

错误十

Error:(27, 0) Gradle DSL method not found: 'apt()'
Possible causes:<ul><li>The project 'ViewPagerTab' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

解决

在引用Butter Knife的时候,没有在module 的build.gradle文件的顶部添加apply plugin: 'com.neenbedankt.android-apt'(ps:在引用Butter Knife的时候一共需要添加四行代码)

来源:http://stackoverflow.com/questions/36876158/gradle-dsl-method-not-found-apt

错误十一

Error:Cause: null value in entry: UMENG_APPKEY=null

解决

自己应该申请一个友盟的UMENG_APPKEY还有value应该就可以了

很多错误信息的解决方法都来自Stack Overflow

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值