您的位置:首页 > 移动开发 > Android开发

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

2016-08-02 11:05 477 查看

前言

刚用AS的时候,真心觉得坑不要太多,尤其是导入项目的时候,所以特此整理一些错误信息,方便以后查询和修改

ps:很多错误,如果重新在AS里创建一个project,自己看着对应修改基本上就能解决问题,大多问题是新旧版本不一致或者jar包冲突导致,多google搜索,都是可以解决的

错误一

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


解决

需要jdk1.8


错误十

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,希望以后有其他的错误信息,可以一并纪录下来,如果有什么不对的地方,欢迎指正
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android studio github
相关文章推荐