一. 编译错误
1. "AndroidManifest.xml file not found" 错误
(1) 报错信息
报错信息 :
-- Message Make :
- Information:Compilation completed with 1 error and 0 warnings in 2 sec
- Information:1 error
- Information:0 warnings
- Error:Android Source Generator: [MidiScope] AndroidManifest.xml file not found
-- Event Log :
- 上午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 :
- Information:Using javac 1.8.0_45 to compile java sources
- Information:Compilation completed with 5 errors and 0 warnings in 3 sec
- Information:5 errors
- Information:0 warnings
- /Users/hanshuliang/Downloads/MidiScope/Application/src/main/AndroidManifest.xml
- 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').
- 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').
- 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').
- 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').
- 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) 报错信息
报错信息 :
- 12-08 16:39:31.105 15700-15700/cn.zkhw.midi E/AndroidRuntime: FATAL EXCEPTION: main
- 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.
- at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2297)
- at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2351)
- at android.app.ActivityThread.access$700(ActivityThread.java:161)
- at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1318)
- at android.os.Handler.dispatchMessage(Handler.java:99)
- at android.os.Looper.loop(Looper.java:177)
- at android.app.ActivityThread.main(ActivityThread.java:5426)
- at java.lang.reflect.Method.invokeNative(Native Method)
- at java.lang.reflect.Method.invoke(Method.java:525)
- at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1225)
- at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1041)
- at dalvik.system.NativeStart.main(Native Method)
- 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.
- at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:198)
- at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:99)
- at cn.zkhw.midi.slide.MainActivity.onCreate(MainActivity.java:28)
- at android.app.Activity.performCreate(Activity.java:5372)
- at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
- at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259)
- at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2351)?
- at android.app.ActivityThread.access$700(ActivityThread.java:161)?
- at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1318)?
- at android.os.Handler.dispatchMessage(Handler.java:99)?
- at android.os.Looper.loop(Looper.java:177)?
- at android.app.ActivityThread.main(ActivityThread.java:5426)?
- at java.lang.reflect.Method.invokeNative(Native Method)?
- at java.lang.reflect.Method.invoke(Method.java:525)?
- at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1225)?
- at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1041)?
- at dalvik.system.NativeStart.main(Native Method)?
- 12-08 16:39:32.815 15700-15700/cn.zkhw.midi I/Process: Sending signal. PID: 15700 SIG: 9
(2) 解决方案
解决方案 :
-- 出错原因 : 使用 ToolBar 后, 原有的 ActionBar 没有取消, 两个导航栏都出现就出现了上述错误;
-- 设置一个 style :
- <style name="AppTheme.NoActionBar">
- <item name="windowActionBar">falseitem>
- <item name="windowNoTitle">trueitem>
- style>
--
将这个 style 设置给 Activity
:
android
:theme=
"@style/AppTheme.NoActionBar"
- <activity
- android:name=".MainActivity"
- android:label="@string/app_name"
- android:theme="@style/AppTheme.NoActionBar">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- intent-filter>
- activity>
4. "aidl is missing" 错误
(1) 报错信息
报错信息 :
- FAILURE: Build failed with an exception.
-
- * What went wrong:
- Execution failed for task ':library:compileReleaseAidl'.
- > aidl is missing
-
- * Try:
- Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
-
- BUILD FAILED
-
- 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) 报错信息
报错信息 :
- 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.
- apply plugin: 'com.android.application'
-
- android {
- compileSdkVersion 23
- buildToolsVersion "23.0.2"
-
- defaultConfig {
- applicationId "cn.org.octopus.lib_widget"
- minSdkVersion 15
- targetSdkVersion 23
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- }
-
- dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:23.1.1'
- compile 'com.android.support:design:23.1.1'
- }
-- 修改为 : 需要将 apply plugin 修改为 apply plugin: 'com.Android.library' , 删除 applicationId, 下面的是修改完的 gradle 脚本, 修改完后即可编译.
- apply plugin: 'com.android.library'
-
- android {
- compileSdkVersion 23
- buildToolsVersion "23.0.2"
-
- defaultConfig {
- minSdkVersion 15
- targetSdkVersion 23
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- }
-
- dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:23.1.1'
- compile 'com.android.support:design:23.1.1'
- }
6. "Unable to find method 'org.gradle.api.internal.project.ProjectInternal.getPluginManager()Lorg/gradle/api/internal/plugins/PluginManagerInternal;'" 错误
(1) 报错信息
报错信息 :
- Error:Unable to find method 'org.gradle.api.internal.project.ProjectInternal.getPluginManager()Lorg/gradle/api/internal/plugins/PluginManagerInternal;'.
- Possible causes for this unexpected error include:
- Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
- Re-download dependencies and sync project (requires network)
- The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
- Stop Gradle build processes (requires restart)
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
(2) 解决方案
解决方案 :
-- 参考 : http://www.cnblogs.com/stozen/p/5123841.html;
-- 解决方案 : 将 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 插件;
- 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"
- Consult IDE log for more details (Help | Show Log)
(2) 解决方案
解决方案 :
-- 参考 : 点击打开链接;
-- 解决方案 : 去 https://jcenter.bintray.com/com/android/tools/build/gradle/ 网站查看最新的 Gradle 插件版本;
-- 转载资料 :
.
8. * What went wrong:Execution failed for task ':xxx:clean'.> Unable to delete directory: C:\hanshuliang\develop\workspace\xxx\build\outputs\apk
(1) 报错信息
报错信息 :
- Information:Gradle tasks [:APP_OCTOPUS:clean, :APP_OCTOPUS:generateDebugSources, :APP_OCTOPUS:mockableAndroidJar, :APP_OCTOPUS:prepareDebugUnitTestDependencies, :APP_OCTOPUS:generateDebugAndroidTestSources, :APP_OCTOPUS:assembleDebug]
- Error:Execution failed for task ':APP_OCTOPUS:clean'.
- > Unable to delete directory: C:\hanshuliang\develop\workspace\OCTOPUS\APP_OCTOPUS\build\outputs\apk
- Information:BUILD FAILED
- Information:Total time: 6.29 secs
- Error:FAILURE: Build failed with an exception.
-
- * What went wrong:
- Execution failed for task ':APP_OCTOPUS:clean'.
- > Unable to delete directory: C:\hanshuliang\develop\workspace\OCTOPUS\APP_OCTOPUS\build\outputs\apk
-
- * Try:
- Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
-
- Information:2 errors
- Information:0 warnings
- 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) 报错信息
报错信息 :
- 下午6:47:50 UnsupportedMethodException
- Error executing task com.intellij.execution.impl.ExecutionManagerImpl$5@3f12ec8a: Unsupported method: AndroidArtifact.getInstantRun().
- The version of Gradle you connect to does not support that method.
- To resolve the problem you can change/upgrade the target version of Gradle you connect to.
- Alternatively, you can ignore this exception and read other information from the model.
- 下午6:48:48 Executing tasks: [:app_midi_sheet_music:assembleDebug]
(2) 解决方案
解决方案 :
-- 参考链接 : http://blog.csdn.net/piscesq329a/article/details/49945239;
-- 取消 Instant Run 选项 : 进入 Setting 进行如下设置 : 取消 Instant Run 选项;