首页 > 解决方案 > 非常令人困惑的 Java.lang.RuntimeException: java.io.FileNotFoundException:

问题描述

我已从旧硬盘切换到固态硬盘,并且还升级了操作系统。我保存了我的项目的副本并下载了 Android Studio,并认为它会顺利运行。但我得到了一个

    java.lang.RuntimeException: java.io.FileNotFoundException: 
    C:\Users\Gotta\AndroidStudioProjects\BrandShopping\app\build
    \intermediates\istant_run_split_apk_resources\debug
    \instantRunSplitApkResourcesDebug\out\slice_8\resources_ap

它还说:

   Try:
    Run with --stacktrace option to get the stack trace. Run with --info 
    or --debug option to get more log output. Run with --scan to get full 
    insights.

但是当我尝试使用--scan 时,它说'''此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 6.0 不兼容。'''

但是当我尝试运行该应用程序时,它说:

    * What went wrong:
     Execution failed for task 
    ':app:transformDexWithInstantRunSlicesApkForDebug'.
     java.lang.RuntimeException: java.io.FileNotFoundException: 
    C:\Users\Gotta\AndroidStudioProjects\BrandShopping\app\build\
    intermediates\instant_run_split_apk_resources\debug\
    instantRunSplitApkResourcesDebug\out\slice_2\resources_ap

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info 
    or --debug option to get more log output. Run with --scan to get full 
    insights.

    * Get more help at https://help.gradle.org

但就像我之前说的,构建是成功的

我尝试过不同的方法。我已经使缓存无效并重新启动但无济于事,我还尝试在互联网上搜索可能的 sulotions 但我找不到任何东西。

在我的 Gradle.project 中:

    // Top-level build file where you can add configuration options common 
    to all sub-projects/modules.

    buildscript {
repositories {
    google()
    jcenter()

}

dependencies {
    classpath 'com.android.tools.build:gradle:3.4.1'
    classpath 'com.google.gms:google-services:4.2.0'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
    }

    allprojects {
repositories {
    google()
    jcenter()

}
     }

     task clean(type: Delete) {
delete rootProject.buildDir
    }

在我的 Gradle.app 中:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "com.brandshopping.brandshopping"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-auth:18.0.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'
    implementation 'com.google.gms:google-services:4.2.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'com.facebook.android:facebook-login:[5,6)'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
}
apply plugin: 'com.google.gms.google-services'

任何和所有的帮助将不胜感激。

标签: javaandroidandroid-studiogradleruntime-error

解决方案


使用此设置,它对我有用

Settings->Build->Instant Run 并“取消选择”启用即时运行。


推荐阅读