一. 编译错误
1. "AndroidManifest.xml file not found" 错误
(1) 报错信息
报错信息 :
-- Message Make :
1. Information:Compilation completed with 1 error and 0 warnings in 2 sec
2. Information:1 error
3. Information:0 warnings
4. Error:Android Source Generator: [MidiScope] AndroidManifest.xml file not found
-- Event Log :
1. 上午8:41:38 Compilation completed with 1 error and 0 warnings in 2 sec
(2) 解决方案
解决方案 :
-- 选择 右键点击工程, 选择 Open Module Settings :
-- 配置 AndroidManifest 路径 :
2. "error: Error: No resource found that matches the given name (at 'resource' with value" 错误
(1) 报错信息
报错信息 :
-- Message Make :
1. Information:Using javac 1.8.0_45 to compile java sources
2. Information:Compilation completed with 5 errors and 0 warnings in 3 sec
3. Information:5 errors
4. Information:0 warnings
5. /Users/hanshuliang/Downloads/MidiScope/Application/src/main/AndroidManifest.xml
6. Error:(27, -1) Android Resource Packaging: [MidiScope] /Users/hanshuliang/Downloads/MidiScope/Application/src/main/AndroidManifest.xml:27: error: Error: No resource found that matches the given name (at 'icon' with value '@mipmap/ic_launcher').
7. Error:(27, -1) Android Resource Packaging: [MidiScope] /Users/hanshuliang/Downloads/MidiScope/Application/src/main/AndroidManifest.xml:27: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name').
8. Error:(27, -1) Android Resource Packaging: [MidiScope] /Users/hanshuliang/Downloads/MidiScope/Application/src/main/AndroidManifest.xml:27: error: Error: No resource found that matches the given name (at 'theme' with value '@style/MidiScopeTheme').
9. Error:(33, -1) Android Resource Packaging: [MidiScope] /Users/hanshuliang/Downloads/MidiScope/Application/src/main/AndroidManifest.xml:33: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name').
10. Error:(48, -1) Android Resource Packaging: [MidiScope] /Users/hanshuliang/Downloads/MidiScope/Application/src/main/AndroidManifest.xml:48: error: Error: No resource found that matches the given name (at 'resource' with value '@xml/scope_device_info').
(2) 解决方案
解决方案 :
-- 选择 右键点击工程, 选择 Open Module Settings :
-- 配置 资源路径 路径 :
3. "This Activity already has an action bar supplied by the window decor." 错误
(1) 报错信息
报错信息 :
1. 12-08 16:39:31.105 15700-15700/cn.zkhw.midi E/AndroidRuntime: FATAL EXCEPTION: main
2. java.lang.RuntimeException: Unable to start activity ComponentInfo{cn.zkhw.midi/cn.zkhw.midi.slide.MainActivity}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
3. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2297)
4. at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2351)
5. at android.app.ActivityThread.access$700(ActivityThread.java:161)
6. at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1318)
7. at android.os.Handler.dispatchMessage(Handler.java:99)
8. at android.os.Looper.loop(Looper.java:177)
9. at android.app.ActivityThread.main(ActivityThread.java:5426)
10. at java.lang.reflect.Method.invokeNative(Native Method)
11. at java.lang.reflect.Method.invoke(Method.java:525)
12. at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1225)
13. at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1041)
14. at dalvik.system.NativeStart.main(Native Method)
15. Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
16. at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:198)
17. at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:99)
18. at cn.zkhw.midi.slide.MainActivity.onCreate(MainActivity.java:28)
19. at android.app.Activity.performCreate(Activity.java:5372)
20. at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
21. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259)
22. at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2351)?
23. at android.app.ActivityThread.access$700(ActivityThread.java:161)?
24. at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1318)?
25. at android.os.Handler.dispatchMessage(Handler.java:99)?
26. at android.os.Looper.loop(Looper.java:177)?
27. at android.app.ActivityThread.main(ActivityThread.java:5426)?
28. at java.lang.reflect.Method.invokeNative(Native Method)?
29. at java.lang.reflect.Method.invoke(Method.java:525)?
30. at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1225)?
31. at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1041)?
32. at dalvik.system.NativeStart.main(Native Method)?
33. 12-08 16:39:32.815 15700-15700/cn.zkhw.midi I/Process: Sending signal. PID: 15700 SIG: 9
(2) 解决方案
解决方案 :
-- 出错原因 : 使用 ToolBar 后, 原有的 ActionBar 没有取消, 两个导航栏都出现就出现了上述错误;
-- 设置一个 style :
1. <style name="AppTheme.NoActionBar">
2. <item name="windowActionBar">false</item>
3. <item name="windowNoTitle">true</item>
4. </style>
--
将这个 style 设置给 Activity
:
android
:theme=
"@style/AppTheme.NoActionBar"
1. <activity
2. android:name=".MainActivity"
3. android:label="@string/app_name"
4. android:theme="@style/AppTheme.NoActionBar">
5. <intent-filter>
6. <action android:name="android.intent.action.MAIN" />
7.
8. <category android:name="android.intent.category.LAUNCHER" />
9. </intent-filter>
10. </activity>
4. "aidl is missing" 错误
(1) 报错信息
报错信息 :
1. FAILURE: Build failed with an exception.
2.
3. * What went wrong:
4. Execution failed for task ':library:compileReleaseAidl'.
5. > aidl is missing
6.
7. * Try:
8. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
9.
10. BUILD FAILED
11.
12. Total time: 0.651 secs
(2) 解决方案
解决方案 :
-- 错误原因 : SDK 文件不全, 换一个 SDk 重新编译即可通过;
-- 原来的 SDK 查看 : 右键点击工程, 选择 "Open Module Setting" ;
-- 编译设置 : 由此可见 22 5.1 的 SDK 是不完整的;
-- 更换 SDK 即可完成编译 : 注意 SDK 版本 和 编译工具的版本必须对应;
5. "unspecified on project ... resolves to an APK archive which is not supported as a compilation dependency." 错误
(1) 报错信息
报错信息 :
1. Warning:Dependency AndroidQuickDevelop:lib_widget:unspecified on project app_sample resolves to an APK archive which is not supported as a compilation dependency. File: C:\hanshuliang\develop\workspace\as\AndroidQuickDevelop\lib_widget\build\outputs\apk\lib_widget-release-unsigned.apk
--
场景描述
: 需要一个 Module 存放所有的自定义组件, 如果使用 library 就不能使用 R 文件, 无法引用颜色 属性 图片 布局 等资源, 因此将自定义组件写入一个 Module B 中, 在 Module A 中引用 Moudle B, 就会出现上述错误.
(2) 解决方案
解决方案 :
-- 原来的 gradle 脚本 : 注意其中的 apply plugin 中的输出类型是 application, 另外在 defaultConfig 中有 applicationId.
1. apply plugin: 'com.android.application'
2.
3. android {
4. 23
5. "23.0.2"
6.
7. defaultConfig {
8. "cn.org.octopus.lib_widget"
9. 15
10. 23
11. 1
12. "1.0"
13. }
14. buildTypes {
15. release {
16. false
17. 'proguard-android.txt'), 'proguard-rules.pro'
18. }
19. }
20. }
21.
22. dependencies {
23. 'libs', include: ['*.jar'])
24. 'junit:junit:4.12'
25. 'com.android.support:appcompat-v7:23.1.1'
26. 'com.android.support:design:23.1.1'
27. }
-- 修改为 : 需要将 apply plugin 修改为 apply plugin: 'com.Android.library' , 删除 applicationId, 下面的是修改完的 gradle 脚本, 修改完后即可编译.
1. apply plugin: 'com.android.library'
2.
3. android {
4. 23
5. "23.0.2"
6.
7. defaultConfig {
8. 15
9. 23
10. 1
11. "1.0"
12. }
13. buildTypes {
14. release {
15. false
16. 'proguard-android.txt'), 'proguard-rules.pro'
17. }
18. }
19. }
20.
21. dependencies {
22. 'libs', include: ['*.jar'])
23. 'junit:junit:4.12'
24. 'com.android.support:appcompat-v7:23.1.1'
25. 'com.android.support:design:23.1.1'
26. }
6. "Unable to find method 'org.gradle.api.internal.project.ProjectInternal.getPluginManager()Lorg/gradle/api/internal/plugins/PluginManagerInternal;'" 错误
(1) 报错信息
报错信息 :
1. Error:Unable to find method 'org.gradle.api.internal.project.ProjectInternal.getPluginManager()Lorg/gradle/api/internal/plugins/PluginManagerInternal;'.
2. Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
3. <a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
4. <a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
(2) 解决方案
解决方案 :
-- 参考 : ;
-- 解决方案 : 将 gradle/wrapper/gradle-wrapper.properties 中的 distributionUrl 属性修改为 distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip;
7. Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to 错误
(1) 报错信息
报错信息 : 该问题总是在 Gradle 更新后出现, 原因可能是使用了 alpha 版本的 gradle 插件;
1. 8:28:29 Gradle sync failed: Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to "c1b9f8c9ba6edf57abf0bf0a680ecf1cd51bbfbe"
2. for more details (Help | Show Log)
(2) 解决方案
解决方案 :
-- 参考 : 点击打开链接;
-- 解决方案 : 去 https://jcenter.bintray.com/com/android/tools/build/gradle/ 网站查看最新的 Gradle 插件版本;
1. 一、问题原理
2. 其实问题也很明确,就是插件太老需要更新。
3.
4. 下面举个很好但是很久以前的例子,原理都是一样的:
5.
6. This is my app gradle file:
7.
8. android {
9. compileSdkVersion 22
10. buildToolsVersion "22.0.0"
11. defaultConfig {
12. applicationId "xxx.xxxxxx.xxxxx"
13. versionCode 1
14. versionName '1'
15. minSdkVersion 9
16. targetSdkVersion 22
17. versionCode 1
18. versionName '1'
19. }
20. buildTypes {
21. release {
22. minifyEnabled false
23. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24. }
25. }
26.
27.
28. dependencies {
29. compile fileTree(dir: 'libs', include: ['*.jar'])
30. compile 'com.android.support:appcompat-v7:22.0.0'
31. compile 'com.google.android.gms:play-services:6.5.87'
32. compile 'com.android.support:recyclerview-v7:21.0.0'
33. compile 'com.android.support:cardview-v7:21.0.0'
34. compile 'com.facebook.android:facebook-android-sdk:3.21.1'
35. testCompile 'junit:junit:4.12'
36. compile project(':volley')
37. }
38. This is my top build.gradle:
39.
40.
41. buildscript {
42. repositories {
43. jcenter()
44. }
45. dependencies {
46. classpath 'com.android.tools.build:gradle:1.1.0-rc1'
47.
48. // NOTE: Do not place your application dependencies here; they belong
49. // in the individual module build.gradle files
50. }
51. }
52.
53. allprojects {
54. repositories {
55. jcenter()
56. }
57. }
58. 1.上边的就是gradle版本太老
59.
60. 需要把:classpath 'com.android.tools.build:gradle:1.1.0-rc1'
61.
62. change to:
63.
64. classpath'com.android.tools.build:gradle:1.1.3'//latest 2.2.0-alpha1
65. 现在gradle的版本已经更新到2.13啦。基本上就是gradle的问题。
66.
67. 2.App build.gradle:
68.
69. Change:
70.
71. compile'com.android.support:recyclerview-v7:21.0.0'
72. compile'com.android.support:cardview-v7:21.0.0'
73. To:
74.
75. compile'com.android.support:recyclerview-v7:22.0.0'//latest23.1.1
76. compile'com.android.support:cardview-v7:22.0.0'//latest23.1.1
77. 打开SDK Manager把依赖包也更新,一般更新到最新就可以啦。
78.
79. 下边是一些插件的网址:
80.
81. Gradle: https://gradle.org/downloads
82.
83. Always check the Android SDK Manager for the latest revisions:
84.
85. Android Build Tools Plugin: http://tools.android.com/tech-docs/new-build-system
86.
87. Android Support Libraries: http://developer.android.com/tools/support-library/features.html
88.
89. To view the latest plugin releases, view the Bintray Jcenter page directly:https://bintray.com/android/android-tools/com.android.tools.build.gradle/view.
90.
91. 可以参考这个回答:http://stackoverflow.com/questions/29063968/plugin-is-too-old-please-update-to-a-more-recent-version-or-set-android-daily
92.
93. 二、更新gradle
94. 这个更新gradle真的是很坑啊,百度了半天,倒是找到不少解决办法,但真的是很简洁!!!一些主要步骤都给省略啦,这让我这种新手怎么办!!在这里总结下:
95.
96. 这是离线更新,如果FQ在线更新的话也是一样的,在线更新就把下边的步骤1略过即可,从2开始看。
97.
98. 1.先去gradle官网把最新的gradle下下来,Gradle官网: https://gradle.org/downloads 注意:下载完不要解压!
99.
100. 2.在你的项目根目录下面找gradle/wrapper/gradle-wrapper.properties这个文件,修改里边的文件内容:
101.
102. #Mon Dec 28 10:00:20 PST 2015
103. distributionBase=GRADLE_USER_HOME
104. distributionPath=wrapper/dists
105. zipStoreBase=GRADLE_USER_HOME
106. zipStorePath=wrapper/dists
107. distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
108. 就是改最后一行:distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip这个改为最新的版本,这里最新就是2.1我这是修改完的。
109.
110. 3.第三部很重要的一步,先打开你的Gradle 的user home ,默认是 C:\Users\【你当前的 用户名】 \.gradle 。按下图的路径展开,只是打开不要动任何东西
111.
112.
113.
114. 在Android Studio内置的终端:Terminal 如图:输入gradlew -v
115.
116.
117.
118. 执行这个命令会自动下载上边设置的版本:2.13,我这里已经下载完了,所以显示的是gradle 2.13。注意执行这个命令gradlew -v才会生成gradle-XXX-all和名字乱码的那个文件夹,我当时看别人的方法就很苦恼那个名字乱码的文件夹是怎么生成的!
119.
120. 执行后显示:Downloading distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip //大致就是这个,说明它正在下载,如果你想FQ在线更新就可以一直等它执行完毕,我试过FQ的情况下速度也是可以的
121.
122. 这时候你就注意上边打开的哪个文件夹,不断刷新看看是否生成了最新版本gradle的文件夹,有了这个文件夹就打开里边是一个名字是乱码文件夹,gradle-2.13-all\1b9wlm73elu4cqnbc0rk7r7qn//这个是我的
123.
124. 看到生成这个文件夹之后就可以关掉android studio了。
125.
126. 4.把第一步的压缩包复制到上边生成的乱码文件夹里,打开android studio,在Terminal里输入:gradlew -v,就会自动解压,你只需等待就可以。如图:
127.
128.
129.
130.
131.
132. 解压完成后:
133.
134.
135.
136. 至此你的gradle就更新到了最新版本。
137.
138. 可以参考这个:
139.
140. 搞了好久终于整明白这个问题啦,总结下希望能帮到和我一样的新手。。。。
143.
144. 三、更新Android Gradle Plugin
145. 发现有时候更新了gradle但是gradle plugin版本也不可以。下面就改android plugin version
146.
147. https://jcenter.bintray.com/com/android/tools/build/gradle/ android plugin version 改成最新的;
148. 在android studio里project structrue->Project->Android Plugin Version里直接改成最新的,然后build Project就可以
149.
150. 参考知乎:http://www.zhihu.com/question/39036683/answer/91435802 //这个回答:都用最新的 就可以了 https://jcenter.bintray.com/com/android/tools/build/gradle/ android plugin version 改成最新的;Gradle Distributions gradle version 目前最新版本是2.12 手动下下来,放到本地,配置 gradle home
.
8. * What went wrong:Execution failed for task ':xxx:clean'.> Unable to delete directory: C:\hanshuliang\develop\workspace\xxx\build\outputs\apk
(1) 报错信息
报错信息 :
1. Information:Gradle tasks [:APP_OCTOPUS:clean, :APP_OCTOPUS:generateDebugSources, :APP_OCTOPUS:mockableAndroidJar, :APP_OCTOPUS:prepareDebugUnitTestDependencies, :APP_OCTOPUS:generateDebugAndroidTestSources, :APP_OCTOPUS:assembleDebug]
2. Error:Execution failed for task ':APP_OCTOPUS:clean'.
3. > Unable to delete directory: C:\hanshuliang\develop\workspace\OCTOPUS\APP_OCTOPUS\build\outputs\apk
4. Information:BUILD FAILED
5. Information:Total time: 6.29 secs
6. Error:FAILURE: Build failed with an exception.
7.
8. * What went wrong:
9. Execution failed for task ':APP_OCTOPUS:clean'.
10. > Unable to delete directory: C:\hanshuliang\develop\workspace\OCTOPUS\APP_OCTOPUS\build\outputs\apk
11.
12. * Try:
13. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
14.
15. Information:2 errors
16. Information:0 warnings
17. Information:See complete output in console
(2) 解决方案
解决方案 :
-- 参考链接 : http://stackoverflow.com/questions/25051278/unable-to-clean-project-in-android-studio;
-- 到 windows 目录中删除该文件 : 发现无法删除, 直接用 360 强力删除 搞定, 芝麻大点问题;
.
9. UnsupportedMethodException Error executing task com.intellij.execution.impl.ExecutionManagerImpl$5@3f12ec8a: Unsupported method: AndroidArtifact.getInstantRun().
(1) 报错信息
报错信息 :
1. 下午6:47:50 UnsupportedMethodException
2. Error executing task com.intellij.execution.impl.ExecutionManagerImpl$5@3f12ec8a: Unsupported method: AndroidArtifact.getInstantRun().
3. The version of Gradle you connect to does not support that method.
4. To resolve the problem you can change/upgrade the target version of Gradle you connect to.
5. Alternatively, you can ignore this exception and read other information from the model.
6. 下午6:48:48 Executing tasks: [:app_midi_sheet_music:assembleDebug]
(2) 解决方案
解决方案 :
-- 参考链接 : ;
-- 取消 Instant Run 选项 : 进入 Setting 进行如下设置 : 取消 Instant Run 选项;