刚开始用AndroidStudio遇到了很多问题很不适应,去谷歌、stackoverflow等网站搜索各种解决方案, 用了AndrodStudio很长时间了,一路上遇到了不少坑,使用过程遇到的一些问题,及解决方案记录了下来了(这里只是记录了我记得的,还有好多,后面会持续更新中),分享给朋友们,可能还会有其他的解决方案,有更好的方法,希望朋友们告诉我,会持续更新中...
- No resource found that matches the given name
error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
原因:
在App目录下build.gradle文件中配置了
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
}
解决方案:
是因为你设置的
compileSdkVersion 22
buildToolsVersion "23.0.2"
改为
compileSdkVersion 23
buildToolsVersion "23.0.2"
- om.android.build.api.transform.TransformException
Error:Execution failed for task ':app:transformClassesWithDexForChannel_testDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:
Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
原因:build.gradle里面配置的依赖,和app下面的libs jar有重复,
- non-zero exit value 1
Error:Execution failed for task ':app:processChannel_testArmeabi-v7aDebugResources'.com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException:
Process 'command '/Users/denghuilong/Library/Android/sdk/build-tools/23.0.2/aapt'' finished with non-zero exit value 1
解决方案:运行AndroidStudio的时候,可能会报上面的异常,重新clean 然后builder就可以了
- Duplicate files copied in APK META-INF/notice.txt
Error:Execution failed for task ':app:packageDebug'. Duplicate files copied in APK META-INF/notice.txt
解决方案:
在App目录下build.gradle文件加入下面这段话
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
- Gradle version 2.2 is required. Current version is 2.10.
Failed to sync Gradle project 'clippicture-master'
Error:Gradle version 2.2 is required. Current version is 2.10. If using the gradle wrapper, try editing the distributionUrl in /Users/denghuilong/Documents/project/AndroidStudioProjects/clippicture-master/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip.
解决方案:
这是我将AndroidStudio升级都2.0之后报的错误
解决方案:修改当前项目下面的
/gradle/wrapper/gradle-wrapper.properties
将gradle-2.2-all.zip改为 gradle-2.10-all.zip
例如
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
不过最好不要使用http这种方式,下载gradle-2.10-all.zip放到本地,然后使用本地路径
distributionUrl=file\:/Users/denghuilong/Documents/project/AndroidStudioProjects/gradle-2.10-all.zip
- Error:(17, 28) 错误: 程序包org.apache.http.util不存在
解决方案:以前的项目使用了httpclient,而在Android 6.0已经把httpclient相关代码移除,如果需要使用,需要在module的build.gradle中加入
android {
useLibrary 'org.apache.http.legacy'
}