Studio错误汇总

来源:互联网 发布:php的mvc模式 编辑:程序博客网 时间:2024/06/08 11:04

一:错误
这里写图片描述

当出现如下错误的时候,说明项目的minSdkVersion比测试机的SDK高,将minSdkVersion=16或者更小

这里写图片描述

错误二:
Error:(1, 0) Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to “a7fe329839d6518e9c116ccaa357e2c79c65192e”
Fix plugin version and sync project
Open File

解决办法:删除项目中原来的gradle文件,和build.gradle文件:
在把原来项目中能运行项目的build.gradle复制过来

**错误三:**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.

遇到这种错误那就是要在styles中设置窗口了:

<style name="AppTheme.NoActionBar">        <item name="windowActionBar">false</item>        <item name="windowNoTitle">true</item>    </style>    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />    <!--右滑返回-->    <style name="AppTheme.NoActionBar.Translucent">        <item name="android:windowIsTranslucent">true</item>    </style>

然后再清单文件(manifest)中找到对应的activity:设置theme

<activity android:name=".view.MainActivity"                  android:screenOrientation="portrait"                  android:theme="@style/AppTheme.NoActionBar.Translucent">

错误四:
这里写图片描述

解决办法:
这里写图片描述

错误5:
解决Execution failed for task ‘:app:clean’. > Unable to delete directory问题

在使用Android Studio编译工程的时候,出现了如下错误:

FAILURE: Build failed with an exception.  02.  03.* What went wrong:  04.Execution failed for task ':app:clean'.  05.> Unable to delete directory: F:\Android\AndroidStudioWorkSpace\AIDLDemo\app\build\outputs\apk  06.  07.* Try:  08.Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.  09.  10.BUILD FAILED  

终极解决办法:

删除F:\Android\AndroidStudioWorkSpace\AIDLDemo\app\ 目录下的build文件夹,然后重启Android Studio即可!

但是直接删除build文件夹删除不了,可以使用360文件粉碎机删除文件就可以了!

错误六

Studio编译的时候出现:
Error:org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotterFileCollectionSnapshotImplcannotbecasttoorg.gradle.api.internal.changedetection.state.OutputFilesCollectionSnapshotterOutputFilesSnapshot
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)
  • 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.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

这个问题的时候
找到项目目录下的.gradle文件下的版本例如2.10,在版本文件内有taskArtifacts文件夹,把taskArtifacts这个文件夹删除后在此编译就可以了

错误七
这里写图片描述

当出现上述错误的时候解决方法如下,
这里写图片描述

错误八
在导入studio工程的时候,进行sync的时候,提示Error:Configuration with name ‘default’ not found.

解决办法:
1.打开settings.gradle发现里面有很多个include ‘:app’这样的include,然而发现在工程的目录下面根本没有include的项目,所以将需要include的项目添加进来,如果include的项目不需要,则将其include语句直接删掉,重新sync尝试。
2.按照上面的操作,要么添加了相应inlcude的工程进来,但是发现还是会提示这样的default not found语句,怎么回事呢,原来用gradle编译的工程,每个工程下面都必须要有build.gradle文件,才能够编译include的工程。整个大工程才能sync通过。把include工程中都添加上相应的gradle配置文件,再重新进行sync,整个工程都通过了。

错误九
UnsupportedMethodException
Unsupported method: AndroidProject.getPluginGeneration().
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.

解决方法:关掉instant run

这里写图片描述

错误十
Error:Execution failed for task ‘:pickerview:compileReleaseJava’. > Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.

出现上面的错误解决办法:
这里写图片描述

错误11:

Error:Execution failed for task ':app:processDebugManifest'.> Manifest merger failed : Attribute application@icon value=(@drawable/icon_hbh) from AndroidManifest.xml:30:9-42    is also present at [xxx:wallet:unspecified] AndroidManifest.xml:16:9-43 value=(@mipmap/ic_launcher).    Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:27:5-48:19 to override.

原因:
AS的Gradle插件默认会启用Manifest Merger Tool,若Library项目中也定义了与主项目相同的属性(例如默认生成的android:icon和android:theme),则此时会合并失败,并报上面的错误。

解决方案:
方法1:在在工程的Manifest.xml的application标签下添加tools:replace=”android:icon, android:theme”(多个属性用,隔开,并且记住在manifest根标签上加入xmlns:tools=”http://schemas.android.com/tools”,否则会找不到namespace哦,也可以按到Alt + Enter键快捷添加)
方法2:在build.gradle根标签上加上useOldManifestMerger true (懒人方法)

错误12:
当遇到一些莫名其妙的错误,如果有依赖的库的时候,需要和以来的库中保持SDK版本一致。

错误13:
Error:Dependency xxx:workorder:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: E:\xxx\workorder\build\outputs\apk\workorder-release-unsigned.apk

0 0
原创粉丝点击