【问题标题】:Android studio 3.0 compile time error BUILD FAILEDAndroid studio 3.0 编译时错误BUILD FAILED
【发布时间】:2018-05-03 10:22:53
【问题描述】:

我在使用 android studio 3.0 后遇到了这个问题。

每当我尝试运行几次后,就会出现此错误。

Information:Gradle tasks [:app:assembleDevDebug]
Error:java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.io.IOException: Could not delete path 'D:\Akash\Final\android_main\app\build\intermediates\transforms\desugar\dev\debug\0.jar'.
Error:com.android.build.api.transform.TransformException: java.io.IOException: Could not delete path 'D:\Akash\Final\android_main\app\build\intermediates\transforms\desugar\dev\debug\0.jar'.
Error:java.io.IOException: Could not delete path 'D:\Akash\Final\android_main\app\build\intermediates\transforms\desugar\dev\debug\0.jar'.
Information:BUILD FAILED in 2s
Information:3 errors
Information:0 warnings

解决方案是重建或清理然后运行应用程序。 因此,我无法使用即时运行功能。

I have already tried this solution 并且可以正常工作。

但为什么我会经常遇到这个问题,比如一个小时 4-5 次?

P.S 我没有管理员权限。如上所述HERE as accepted answer

我的其他项目运行良好,没有任何问题。 您可能会发现这个问题是重复的,但以前的解决方案对我一点帮助都没有。

构建.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'
apply plugin: 'realm-android'

repositories {
    maven {
        url "https://XXX.XXX.com/XXX.XXX.com"
    }
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    flavorDimensions "default"
    project.archivesBaseName = "XXX";
    signingConfigs {
        release {
            storeFile file (System.getenv('XXX'))
            storePassword System.getenv("XXX")
            keyAlias System.getenv("XXX")
            keyPassword System.getenv("XXX")
        }
    }
    playAccountConfigs {
        defaultAccountConfig {
            serviceAccountEmail = 'XXX-XXX-account@api-XXX-XXX.iam.XXX.com'
            pk12File = file('XXX-XXX.p12')
        }
    }
    defaultConfig {
        applicationId "com.XXX.app"
        minSdkVersion 16
        targetSdkVersion 26
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        signingConfig signingConfigs.release
        playAccountConfig = playAccountConfigs.defaultAccountConfig

     ndk {
          abiFilters 'armeabi-v7a'
        }
    }
    lintOptions {
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    dexOptions {
        javaMaxHeapSize "4g"
        jumboMode true
    }
    productFlavors {

        pro {
            buildConfigField "XXX", "XXX", System.getenv("XXX")
            buildConfigField "XXX", "XXX", System.getenv("XXX")      
            buildConfigField "XXX", "XXX", System.getenv("XXX")
            buildConfigField "XXX", "XXX", System.getenv("XXX")
        }
        qa {
            buildConfigField "XXX", "XXX", System.getenv("XXX")
            buildConfigField "XXX", "XXX", System.getenv("XXX")
            manifestPlaceholders = [facebookId: "XXX"]
        }
    }
    buildTypes {        
        release {
            minifyEnabled false            
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            applicationVariants.all { variant ->
                variant.outputs.all {
                    outputFileName = "XXX-${variant.baseName}-${variant.versionName}.apk"
                }
            }
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    packagingOptions {
        exclude 'META-INF/XXX'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.code.findbugs'
    })
    testImplementation 'junit:junit:4.12'
    implementation project(path: ':instacount')
    implementation project(path: ':cordova')
    implementation 'com.android.support:multidex:1.0.2'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:palette-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.google.android.gms:play-services-maps:11.0.4'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.squareup.picasso:picasso:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
    implementation 'com.github.bumptech.glide:glide:3.8.0'
    implementation 'net.danlew:android.joda:2.8.2'
    implementation 'com.auth0.android:auth0:1.8.0'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    implementation 'com.amazonaws:aws-android-sdk-s3:2.4.4'
    implementation 'testfairy:testfairy-android-sdk:1.+@aar'
    implementation 'com.afollestad.material-dialogs:commons:0.9.0.1'
    implementation 'com.jenzz.appstate:appstate:3.0.1'
    implementation 'id.zelory:compressor:2.1.0'
    implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    implementation 'com.commonsware.cwac:cam2:0.7.6'
    implementation 'org.parceler:parceler-api:1.1.9'
    annotationProcessor 'org.parceler:parceler:1.1.9'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.5'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    implementation 'com.jakewharton.rxbinding:rxbinding:0.4.0'
    implementation 'com.caverock:androidsvg:1.2.1'
}

play {
    track = 'beta'
}

【问题讨论】:

  • 根据您的描述,我唯一可以确定的是,运行 Gradle 的用户是不允许删除该文件的。为了多说,我们需要查看创建文件的构建脚本。脚本会创建不允许删除的文件,这对我来说似乎很奇怪。
  • 这是要否决这个?
  • @Jolta 我已经添加了 build.gradle 文件。请检查。
  • 我不知道谁对您的问题投了反对票,但通常人们会在问题难以理解或信息缺失的情况下对问题投反对票。投票是来自社区的反馈,将其作为学习工具。
  • 他们可以,但他们没有义务这样做。

标签: android-gradle-plugin build.gradle android-studio-3.0


【解决方案1】:

我也遇到了同样的问题,解决了。

尝试将 Realm 插件更新到 4.2.0。

File handles are not released in RealmTransformer · Issue #5521 · realm/realm-java

【讨论】:

  • 今天早上更新到 4.2.0,直到现在才遇到这个错误。谢谢:)
【解决方案2】:

如果缺少 java 文件,请尝试使用 1.jar,2.jar....28.jar,29.jar...尽快

在 gradle.properties 中添加以下内容:

android.enableD8.desugaring = true 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-11
    • 2013-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多