当前位置:   article > 正文

【Android应用开发】Android Studio 错误集锦 -- 将所有的 AS 错误集合到本文_android studio related problem报错

android studio related problem报错

.





一. 编译错误



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) 报错信息


报错信息

  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 设置给 Activityandroid :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. <category android:name="android.intent.category.LAUNCHER" />
  8. </intent-filter>
  9. </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.

  1. apply plugin: 'com.android.application'
  2. android {
  3. compileSdkVersion 23
  4. buildToolsVersion "23.0.2"
  5. defaultConfig {
  6. applicationId "cn.org.octopus.lib_widget"
  7. minSdkVersion 15
  8. targetSdkVersion 23
  9. versionCode 1
  10. versionName "1.0"
  11. }
  12. buildTypes {
  13. release {
  14. minifyEnabled false
  15. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  16. }
  17. }
  18. }
  19. dependencies {
  20. compile fileTree(dir: 'libs', include: ['*.jar'])
  21. testCompile 'junit:junit:4.12'
  22. compile 'com.android.support:appcompat-v7:23.1.1'
  23. compile 'com.android.support:design:23.1.1'
  24. }

-- 修改为 : 需要将 apply plugin 修改为 apply plugin: 'com.android.library' , 删除 applicationId, 下面的是修改完的 gradle 脚本, 修改完后即可编译. 

  1. apply plugin: 'com.android.library'
  2. android {
  3. compileSdkVersion 23
  4. buildToolsVersion "23.0.2"
  5. defaultConfig {
  6. minSdkVersion 15
  7. targetSdkVersion 23
  8. versionCode 1
  9. versionName "1.0"
  10. }
  11. buildTypes {
  12. release {
  13. minifyEnabled false
  14. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  15. }
  16. }
  17. }
  18. dependencies {
  19. compile fileTree(dir: 'libs', include: ['*.jar'])
  20. testCompile 'junit:junit:4.12'
  21. compile 'com.android.support:appcompat-v7:23.1.1'
  22. compile 'com.android.support:design:23.1.1'
  23. }





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:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<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.
<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) 解决方案


解决方案

-- 参考 : 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 插件;

  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. Consult IDE log for more details (Help | Show Log)





(2) 解决方案


解决方案

-- 参考 : 点击打开链接;

-- 解决方案 : 去 https://jcenter.bintray.com/com/android/tools/build/gradle/ 网站查看最新的 Gradle 插件版本;


-- 转载资料

一、问题原理
其实问题也很明确,就是插件太老需要更新。

下面举个很好但是很久以前的例子,原理都是一样的:

This is my app gradle file:

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"
    defaultConfig {
        applicationId "xxx.xxxxxx.xxxxx"
        versionCode 1
        versionName '1'
        minSdkVersion 9
        targetSdkVersion 22
        versionCode 1
        versionName '1'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
 
 
    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.android.support:recyclerview-v7:21.0.0'
    compile 'com.android.support:cardview-v7:21.0.0'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    testCompile 'junit:junit:4.12'
    compile project(':volley')
}
  This is my top build.gradle:


buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0-rc1'
 
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
 
allprojects {
    repositories {
        jcenter()
    }
} 
1.上边的就是gradle版本太老

需要把:classpath 'com.android.tools.build:gradle:1.1.0-rc1'

change to:

classpath'com.android.tools.build:gradle:1.1.3'//latest 2.2.0-alpha1
现在gradle的版本已经更新到2.13啦。基本上就是gradle的问题。

2.App build.gradle:

Change:

compile'com.android.support:recyclerview-v7:21.0.0'
compile'com.android.support:cardview-v7:21.0.0'
To:

compile'com.android.support:recyclerview-v7:22.0.0'//latest23.1.1
compile'com.android.support:cardview-v7:22.0.0'//latest23.1.1
打开SDK Manager把依赖包也更新,一般更新到最新就可以啦。

下边是一些插件的网址:

Gradle: https://gradle.org/downloads

Always check the Android SDK Manager for the latest revisions:

Android Build Tools Plugin: http://tools.android.com/tech-docs/new-build-system

Android Support Libraries: http://developer.android.com/tools/support-library/features.html

To view the latest plugin releases, view the Bintray Jcenter page directly:https://bintray.com/android/android-tools/com.android.tools.build.gradle/view.

可以参考这个回答:http://stackoverflow.com/questions/29063968/plugin-is-too-old-please-update-to-a-more-recent-version-or-set-android-daily

二、更新gradle
这个更新gradle真的是很坑啊,百度了半天,倒是找到不少解决办法,但真的是很简洁!!!一些主要步骤都给省略啦,这让我这种新手怎么办!!在这里总结下:

这是离线更新,如果FQ在线更新的话也是一样的,在线更新就把下边的步骤1略过即可,从2开始看。

1.先去gradle官网把最新的gradle下下来,Gradle官网: https://gradle.org/downloads  注意:下载完不要解压!

2.在你的项目根目录下面找gradle/wrapper/gradle-wrapper.properties这个文件,修改里边的文件内容:

#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
  就是改最后一行:distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip这个改为最新的版本,这里最新就是2.1我这是修改完的。

3.第三部很重要的一步,先打开你的Gradle 的user home ,默认是 C:\Users\【你当前的 用户名】 \.gradle 。按下图的路径展开,只是打开不要动任何东西



在Android Studio内置的终端:Terminal     如图:输入gradlew -v



执行这个命令会自动下载上边设置的版本:2.13,我这里已经下载完了,所以显示的是gradle 2.13。注意执行这个命令gradlew -v才会生成gradle-XXX-all和名字乱码的那个文件夹,我当时看别人的方法就很苦恼那个名字乱码的文件夹是怎么生成的!

执行后显示:Downloading distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip  //大致就是这个,说明它正在下载,如果你想FQ在线更新就可以一直等它执行完毕,我试过FQ的情况下速度也是可以的

 这时候你就注意上边打开的哪个文件夹,不断刷新看看是否生成了最新版本gradle的文件夹,有了这个文件夹就打开里边是一个名字是乱码文件夹,gradle-2.13-all\1b9wlm73elu4cqnbc0rk7r7qn//这个是我的

看到生成这个文件夹之后就可以关掉android studio了。

4.把第一步的压缩包复制到上边生成的乱码文件夹里,打开android studio,在Terminal里输入:gradlew -v,就会自动解压,你只需等待就可以。如图:



 

解压完成后:



至此你的gradle就更新到了最新版本。

可以参考这个:http://www.cnblogs.com/leo-lsw/p/gradle-first-created-error.html

搞了好久终于整明白这个问题啦,总结下希望能帮到和我一样的新手。。。。

转载注明出处:http://www.cnblogs.com/jycboy/p/5534009.html

三、更新Android Gradle Plugin
发现有时候更新了gradle但是gradle plugin版本也不可以。下面就改android plugin version

https://jcenter.bintray.com/com/android/tools/build/gradle/ android plugin version 改成最新的;
在android studio里project structrue->Project->Android Plugin Version里直接改成最新的,然后build Project就可以

参考知乎: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. * What went wrong:
  8. Execution failed for task ':APP_OCTOPUS:clean'.
  9. > Unable to delete directory: C:\hanshuliang\develop\workspace\OCTOPUS\APP_OCTOPUS\build\outputs\apk
  10. * Try:
  11. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  12. Information:2 errors
  13. Information:0 warnings
  14. 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 选项;



10. Error:Unable to find method 'org.gradle.api.tasks.Sync.getInputs()Lorg/gradle/api/internal/TaskInputsInternal;'.



报错信息 : 

-- 错误信息 : 

  1. Error:Unable to find method 'org.gradle.api.tasks.Sync.getInputs()Lorg/gradle/api/internal/TaskInputsInternal;'.
  2. Possible causes for this unexpected error include:
  3. 1.Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) 网络中断
  4. -- Re-download dependencies and sync project (requires network)
  5. 2. The state of a Gradle build process (daemon) may be corrupt. 其它 Gradle 进程干扰
  6. -- Stopping all Gradle daemons may solve this problem.
  7. 3. Stop Gradle build processes (requires restart) 重启 AS
  8. Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
  9. In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.


解决方案 : 

-- 解决方案 : 更新最新的 SDK Tools, Gradle, Gradle Plugin;

-- 更新最新 Gradle 插件 : 更新最新的 Gradle 插件, 到 https://jcenter.bintray.com/com/android/tools/build/gradle/ 网站查看最新的 Gradle 插件, 查询到最新的插件版本为 2.3.0-beta1, 

-- 更新最新的 Gradle 工具 : 查看地址 https://services.gradle.org/distributions/, 最新的是 gradle-3.3-all.zip, 将 gradle/wrapper/gradle-wrapper.properties 中的 distributionUrl 更新成 distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip ;

-- 更新最新的 SDK Build Tools : 到 SDK Manager 中更新最新的 SDK 和 SDK BuildTools;





.













.


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/963868
推荐阅读
相关标签
  

闽ICP备14008679号