请选择 进入手机版 | 继续访问电脑版

北南南北论坛

 找回密码
 立即注册
查看: 16|回复: 0

Android Studio 编译常见问题解决办法

[复制链接]

563

主题

950

帖子

2694

积分

金牌会员

Rank: 6Rank: 6

积分
2694
发表于 2017-12-20 08:19:57 | 显示全部楼层 |阅读模式
本帖最后由 vxbus 于 2017-12-20 08:24 编辑

前言

Android Studio已经成为Android开发最主要平台了,但是开发过程中,因为环境会出现各种各样的bug,这里我收录了一些常见bug希望能帮助到大家。
问题总结及解决方法

1.dexDebug ExecException finished with non-zero exit value 2
需要在gradle中配置下面的代码,原因是引用了多个libraries文件
  1. defaultConfig {
  2. multiDexEnabled true
  3. }
复制代码


2.Execution failed for task ‘:
app:transformClassesWithJarMergingForDebug’.

  1. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/app/BackStackState$1.class

  2. Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
  3. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/ArrayRes.class

  4. Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
  5. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/android/volley/ServerError.class
复制代码


原因:在所添加的jar包或aar包中也引用了support-V4,与工程中引用的相冲突
Ctrl+N --> 在搜索框中输入BackStackState --> 查找到所有引用该类的类,这些类即为引起冲突的类
去掉本工程中gradle中用于引用有冲突的包的代码或者将冲突的代码从jar包或aar包中移除,确保一个module中只引用了一份相同的第三方包

3.project sturcture和Project Structure 无论是按快捷键或者是从files中打开都不显示
  1. event log中报:IllegalArgumentException:Multiple entries with same key: Google Inc.:Google APIs:23=Google APIs (Google Inc.) (API 23) and Google Inc.:Google APIs:23=Google APIs (Google Inc.) (API 23)
复制代码


解决办法:先看一下系统配置的SDK的位置和Android Studio所用的路径是否一致,如果不一致重新配置系统的SDK路径或者是重新修改Android Studio的SDK路径
通过SDK Manager删除掉google API23
如果解决不了,卸载android studio -->重新安装 ,还有问题点击File --> Invalidate Cashes/Restart --> Invalidate and Restart,解决不了继续通过SDK Manager删除掉google API23

4.Error:Execution failed for task ‘:app:clean’.
  1. >  Unable to delete directory: E:\as_workspaces\DJIgo\app\build\intermediates\res\merged\debug
复制代码


5.Error:Execution failed for task
‘:tongyan_bugs_framework_master:processDebugAndroidTestManifest’.
  1. > java.lang.RuntimeException: Manifest merger failed :
  2. uses-sdk:minSdkVersion 18 cannot be smaller than version 19 declared in library [DJIgo:tysubwayinspection3.0-framework:unspecified]
  3. E:\as_workspaces\DJIgo\tongyan_bugs_framework_master\build\intermediates\exploded-aar\DJIgo\tysubwayinspection3.0-framework\unspecified\AndroidManifest.xml
  4. Suggestion: use tools:overrideLibrary="com.tongyan.framework" to force usage
复制代码


6.Error:Execution failed for task ‘:
app:processDebugManifest’.
  1. > Manifest merger failed :
  2. uses-sdk:minSdkVersion 17 cannot be smaller than version 19 declared in library [DJIgo:tongyan-djigo-lib:unspecified]
  3. E:\as_workspaces\DJIgo\app\build\intermediates\exploded-aar\DJIgo\tongyan-djigo-lib\unspecified\AndroidManifest.xml
  4. Suggestion: use tools:overrideLibrary="com.tongyan.lib.djigo" to force usage
复制代码


7.Error:Execution failed for task ‘:
tongyan-djigo-lib:compileReleaseJavaWithJavac’.
  1. > > Compilation failed; see the compiler error output for details.
复制代码


http://stackoverflow.com/questions/33404552/execution-failed-for-task-appcompiledebugjavawithjavac-in-android-studio

8.注: E:\
as_workspaces\DJIgo\tongyan-djigo-lib\src\main\java\com\tongyan\lib\djigo\ui\view\ControlMoveView.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 android studio-File->;Project Structure->Android sdk location(路径应该不正确)

9.Error:Execution failed for task ‘:
app:compileDebugJavaWithJavac’.
  1. java.io.FileNotFoundException: E:\as_workspaces\TYSubway\app\libs\pushservice-4.5.6.88.jar (系统找不到指定的文件。)
复制代码


需要把dependencies中的lib包下面的jar包全部取消下,再添加。

10.Error:Execution failed for task ‘:
tysubwayinspection3.0-framework:packageReleaseResources’.
  1. > java.io.IOException: Could not delete folder E:\as_workspaces\DJIgo\tysubwayinspection3.0-framework\build\intermediates\bundles\release\res
复制代码


11.由于使用sdk5.0造成的以下问题,需要用sdk6.0
  1. E:\as_workspaces\DJIgo\app\build\intermediates\res\merged\debug\values-v23\values-v23.xml
  2. Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
  3. Error:(18) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
  4. Error:Execution failed for task ':app:processDebugResources'.
  5. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\Android\adt-bundle-windows-x86_64-20140702\android_sdk\build-tools\23.0.0\aapt.exe'' finished with non-zero exit value 1
复制代码


12.Error:Execution failed for task ‘:app:clean’.
  1. > Unable to delete file: E:\as_workspaces\DjiGo-Demo\app\build\intermediates\exploded-aar\com.android.support\support-v4\23.3.0\jars\classes.jar
复制代码

13.Error:Execution failed for task ‘:
app:transformClassesWithJarMergingForDebug’.
  1. com.android.build.api.transform.TransformException:
  2. java.util.zip.ZipException: duplicate entry: android/support/annotation/IntegerRes.class
复制代码


14.Failed to resolve: com.android.support:appcompat-v7:26.0.0
  1. Failed to resolve: com.android.support:appcompat-v7:26.0.0
  2. Install Repository and sync project
  3. Show in File
  4. Show in Project Structure dialog
复制代码


出现这个问题是因为没有找到appcompat-v7:26.0.0这个包, 这个时候我们需要重新导入包: 选中我们的大工程-->右键-->Open Module Setting-->选中我们的Module-->再选中右边tab栏的Dependencies-->选择绿色的+号,加入我们的appcompat,选中后,再同步一下gradle 完美解决**

15.No resource found
  1. Error retrieving parent for item: No resource found that matc hes the given name 'Theme.AppC ompat Li ght DarkActionBar'.
  2. D No reso jrc e fo und that m atches the givenn ame:attr 'colorAc ent'.
  3. 9 No resoure e found that matches the givenname:attr 'colorPrimary'.
  4. No resource found that matches the given name: attr'colorPrimaryDark'
  5. O Error retrieving parent for item: No resource found that matches the givenname 'Theme.App( ompat Li ght DarkActionBar'.
  6. 9 No resour te found that matches the givenname:attr 'colorAccent.
  7. 9 No resour te found that matches the givenname:attr 'colorPrimary'.
  8. 9 No resource found that matc hes the givenname: attr 'colorPrimaryDark'.
  9. Execution failed for task':app:processDebugResources
  10. ,com.android.ide.common.process.ProcessExceptio Fai led to execute aapt
  11. BUILD FAILED

  12. 这种说资料找不到,就是sdk资源没有找到,请匹配合适的版本资源
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


手机版|北南南北论坛  

GMT+8, 2018-1-24 07:53 , Processed in 0.074323 second(s), 29 queries .

© 2001-2016 VxWorks6 Inc.

快速回复 返回顶部 返回列表