github项目导入Android studio 出现的问题及解决

前言

刚用AS的时候,真心觉得坑不要太多,尤其是导入项目的时候,所以特此整理一些错误信息,方便以后查询和修改
ps:很多错误,如果重新在AS里创建一个project,自己看着对应修改基本上就能解决问题,大多问题是新旧版本不一致或者jar包冲突导致,多google搜索,一般都是可以解决的.

错误一

Error:(19, 0) Gradle DSL method not found: ‘android()’
Possible causes:

解决

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

解决

扫描二维码关注公众号,回复: 2177002 查看本文章

参考: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
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:

解决

在引用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)

最后

很多错误信息的解决方法都来自Stack Overflow,希望以后有其他的错误信息,可以一并纪录下来,如果有什么不对的地方,欢迎指正

猜你喜欢

转载自blog.csdn.net/liuwanyouyue/article/details/52092395