前言
刚用AS的时候,真心觉得坑不要太多,尤其是导入项目的时候,所以特此整理一些错误信息,方便以后查询和修改
ps:大多问题是新旧版本不一致, jar包版本冲突或者gradle版本问题,多网上搜索,一般可以解决.
以下内容与最新AndroidStudio或许有所差异,如有错误,请留言告知,谢谢
错误一
Error:(19, 0) Gradle DSL method not found: ‘android()’
Possible causes:
- The project ‘Zhihu-Parallax-Animation-develop’ may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file- The build file may be missing a Gradle plugin.
Apply Gradle plugin
解决
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’
}
说明: 此改法的基础依赖的是旧版本的AndroidStudio和Gradle,新版本请自行处理
错误二
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
解决
错误三
Error:Configuration with name ‘default’ not found.
解决
错误四
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
Fix Gradle wrapper and re-import project
Gradle settings
解决
在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
解决
需要jdk1.8
错误十
Error:(27, 0) Gradle DSL method not found: ‘apt()’
Possible causes:
- The project ‘ViewPagerTab’ may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file- The build file may be missing a Gradle plugin.
Apply Gradle plugin
解决
在引用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就可以了
错误十二
Error:Execution failed for task ‘:app:transformDexArchiveWithDexMergerForDebug’.
com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/google/zxing/EncodeHintType;
以及
Error:Execution failed for task ‘:app:transformDexArchiveWithExternalLibsDexMergerForDebug’.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
解决
在进行打包的时候出现错误的,编译安装到手机上是没有问题的,一旦发现这种情况,请不要怀疑,一定是引用了重复的library
补充: 我真的不知道facebook的sdk里有zxing,写法请参照如下:
compile (‘com.facebook.android:facebook-android-sdk:4.+’)
{ exclude group: ‘com.google.zxing’ }
补充说明:
使用官方推荐的implementation可有效避免该问题(替换了compile),
但是如果引用的第三方里包含library的引用版本号大于你当前同library的版本号,请升级你的build.gradle里的library的版本号.(当我使用implementation后,并在引用Glide之前引用的com.android.support:design:27.0.2的时候,出现了此问题,后来修改为27.1.1之后,一切正常)
最后
很多错误信息的解决方法都来自Stack Overflow,希望以后有其他的错误信息,可以一并纪录下来,如果有什么不对的地方,欢迎指正