java - 非常困惑的 Java.lang.RuntimeException : java. io.FileNotFoundException:

标签 java android android-studio gradle runtime-error

我已经从我的旧硬盘切换到固态硬盘并且还升级了操作系统。我保存了一份项目副本并下载了 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

但正如我之前所说,构建成功

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

在我的 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'

我们将不胜感激。

最佳答案

有了这个设置,它对我有用

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

关于java - 非常困惑的 Java.lang.RuntimeException : java. io.FileNotFoundException:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57449241/

相关文章:

java - 在 Android 上使用超链接 API 的最佳方式是什么?

android - 如何使用带有 AsyncTask 的 Android Studio 读取 Internet 中的文件?

java - targetSdkVersion 30,不提示用户权限

java - SWT:使用 MouseListener 调整表格大小(高度)

java - 如果在递归调用中多次调用模拟,我可以让模拟返回不同的值吗

android - 推荐的 Android 音乐格式 - mp3、ogg 还是其他?

Android - 空闲时间?

java - 获取类的静态变量值

java - 两种不同的参数类型(将对象转换为类型)

android - MountEmulatedStorage() Zygote SELinux get_category 在 android studio 中的错误