我正在尝试重建我的Android Studio Gradle项目(主要包含Kotlin代码),但它UnableToDeleteFileException在清理/重建过程中开始抛出:
Execution failed for task ':app:clean'.
> Unable to delete file: C:\Users\User\KotlinGameEngine\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.1\jars\classes.jar
在我尝试更改项目的包结构后,这种情况开始发生.不幸的是,我是通过重命名和移动源文件夹而不是通过Android Studio重构来实现的,这是一个坏主意.
我一整天都在寻找解决这个问题的方法,这些都是我试过无用的东西:
gradle和.gradle目录;.gradle我的用户目录中的目录;gradlew clean从AS终端运行;我尝试了一些有点成功的事情,但只让我再次执行一次干净并重新构建错误之前:
java.exe在AS运行时杀死进程(这在技术上可以每次都完成,但是它很繁琐并且减慢了构建过程)所以似乎编译Java进程可能由于某种原因锁定构建文件,但它也可能与Kotlin有关.我有一个(更成熟的)Java Android项目,我正在努力,虽然我在清理时无法重现此错误.这似乎只发生在我的Kotlin项目上.
有任何想法吗?
提前致谢.
我发现问题是由Kotlin Android插件引起的.当我apply plugin: 'kotlin-android'从模块的build.gradle文件中删除时,问题消失,并在重新插入时返回.随意提供任何洞察力.
最后一次更新不是原因.我发现如果一个项目包含一个Kotlin文件,那么重建和清理就会失败.它继续失败,即使所有Kotlin文件都被删除,直到后台Java进程被杀死,这意味着它对构建文件有某种锁定.我在这里提交了一个错误,其中包含更多细节和重现错误的步骤:KT-9440
android kotlin android-studio android-gradle-plugin kotlin-android-extensions
我已经将Android Studio更新为最新的canary版本,现在我无法运行我的应用程序.
每当我尝试构建项目时,我都会收到以下错误:
Error:F:\...\**app_name**\app\build\intermediates\instant-run-support\debug\slice_0\AndroidManifest.xml:2 attribute 'android:versionCode' not found
我试图手动打开文件,属性显然在那里:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="****"
      android:versionCode="1"
      android:versionName="1.0"
      split="lib_slice_0_apk">
</manifest>
我试图清理项目,使缓存无效,重新启动android studio但没有任何帮助.
这是我的build.gradle (app)档案:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "****"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile …我将AndroidStudio升级到3.0 Canary 1后出现此问题
Error:D:\Project\Freelance\Andoid\sosokan-android\sosokan-android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:911 invalid drawable
Error:java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed:
Error:Execution failed for task ':app:mergeDebugResources'.
> Error: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed:
  aapt2 compile -o D:\Project\Freelance\Andoid\sosokan-android\sosokan-android\app\build\intermediates\res\merged\debug D:\Project\Freelance\Andoid\sosokan-android\sosokan-android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
  Issues:
   - ERROR: D:\Project\Freelance\Andoid\sosokan-android\sosokan-android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:911 invalid drawable
它看起来相同 AAPT2编译失败:Android 3.0 Canary 1上的无效Dimen但是我找不到让它在Window上工作的方法
任何帮助或建议将非常感谢.
今天我将我的Studio更新为Canary 2,出现了一个奇怪的构建错误:
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :multipicker:generateDebugSources, :multipicker:generateDebugAndroidTestSources, :multipicker:mockableAndroidJar]
Information:0 errors
Information:0 warnings
Information:See complete output in console
Error:/home/master/AndroidStudioProjects/Reweyou/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:795 invalid drawable
Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed:
Error:Execution failed for task ':app:mergeDebugResources'.
> Error: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed:
  aapt2 compile -o /home/master/AndroidStudioProjects/Reweyou/app/build/intermediates/res/merged/debug /home/master/AndroidStudioProjects/Reweyou/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
  Issues:
   - ERROR: /home/master/AndroidStudioProjects/Reweyou/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:795 invalid drawable
Information:BUILD FAILED in 11s
我在Arch Linux上使用Android Studio 3.0 Canary 3,我正在尝试制作一个小应用程序.在发布问题之前做了一些研究,但我发现的解决方案都不适用于我.任何帮助将非常感激.谢谢
Error:Execution failed for task ':app:mergeDebugResources'. > Error: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed: aapt2 compile -o /home/xhensi/AndroidStudioProjects/FindRestaurant/app/build/intermediates/res/merged/debug /home/xhensi/AndroidStudioProjects/FindRestaurant/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml Issues: - ERROR: /home/xhensi/AndroidStudioProjects/FindRestaurant/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:244 invalid dimen - ERROR: /home/xhensi/AndroidStudioProjects/FindRestaurant/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:245 invalid dimen - ERROR: /home/xhensi/AndroidStudioProjects/FindRestaurant/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:283 invalid dimen - ERROR: /home/xhensi/AndroidStudioProjects/FindRestaurant/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:309 invalid dimen - ERROR: /home/xhensi/AndroidStudioProjects/FindRestaurant/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:310 invalid dimen - ERROR: /home/xhensi/AndroidStudioProjects/FindRestaurant/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:312 invalid dimen - ERROR: /home/xhensi/AndroidStudioProjects/FindRestaurant/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:313 invalid dimen - ERROR: /home/xhensi/AndroidStudioProjects/FindRestaurant/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:314 invalid dimen