您的位置:首页 > 其它

AS填坑

2017-05-03 09:55 113 查看
1,

Gradle project sync failed.Please fix project and try again.


2,

Observed package id 'add-ons;addon-google_apis-google-23' in
inconsistent location 'D:\LocalSDK\AndroidStudio\sdk\add-ons\addon-google_apis-google-23-1' (Expected 'D:\LocalSDK\AndroidStudio\sdk\add-ons\addon-google_apis-google-23')


23版本的有两个,直接删除D:\LocalSDK\AndroidStudio\sdk\add-ons\文件夹下的一个就行,留一个。问题解决!

3,

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/yanzhenjie/nohttp/BuildConfig;
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_101\bin\java.exe'' finished with non-zero exit value 2


可以查看发现在.idea/libraries中发现两个不同版本的nohttp的jar包。

所以,解决问题也就很简单,想办法去掉一个就行。我是这样干的,先重新选定一个版本进行编译。如何再clean掉,最后再运行。问题解决

4,

com.android.ddmlib.AdbCommandRejectedException: device offline
Error while Installing APK


网上有说重启adb。执行命令adb kill-server; adb start-server。

我试过无效。最后是重启电脑才好了。

5,

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(org.apache.commons.logging.LogFactory$1) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.




在该项目里的proguard-rules.pro 中加入下面这句代码即可:

-keepattributes EnclosingMethod


问题解决

之后问题又出现了,这个问题还会导致无法打包

解决办法是,在开发的项目build.gradle中添加

defaultConfig {
multiDexEnabled true
}
dependencies { compile 'com.android.support:multidex:1.0.1' }


之后再打包,可以成功,问题解决

5,

Android Studio更新到2.0以后,在build variants窗口下没有 test artifact选项,无法选择是Android Instrumentation Tests还是Unit Tests

Google一下,解决方案是依次打开: File Menu -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle -> Experimental,

将Enable all test artifacts (Unit Test and Instrumentation Test) in Android projects取消勾选,之后我们熟悉的Test Artifact就出现了,如下图

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  as gradle