0

I have flutter project that I have run in simulator and it runs well, but when I try to run in android emulator in debug mode, I always get this error

What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > java.nio.file.NoSuchFileException: /.../.../MY_PROJECT_NAME/build/trust_location/intermediates/res/symbol-table-with-package/debug/package-aware-r.txt

in my build.gradle for project level, I am using:

classpath 'com.android.tools.build:gradle:3.5.0'

here is app/build.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 29

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.xx.xxxxx"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    signingConfigs {
        release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            // signingConfig signingConfigs.debug
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    api 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "android.arch.core:runtime:1.1.1"
    implementation "android.arch.core:common:1.1.1"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    compile 'com.google.android.gms:play-services-location:9.6.1'
    implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'

and I run in android emulator with api 24. is there something that I should add?

wahyu
  • 1,679
  • 5
  • 35
  • 73
  • Share your build.gradle from android/app/build.gradle – Naveen Rao Mar 08 '21 at 04:00
  • Do you have android studio installed? – Naveen Rao Mar 08 '21 at 04:06
  • @NaveenRao yes, I have – wahyu Mar 08 '21 at 04:07
  • Did you try flutter clean? Also, Tried running in android studio? – Naveen Rao Mar 08 '21 at 04:14
  • @NaveenRao I have tried to flutter clean n still get the same error, so right now I am running ```flutter pub cache repair``` and waiting for the process done... I am running in vs code and using android emulator of android studio – wahyu Mar 08 '21 at 04:16
  • 1
    I guess your question is a duplicate of this https://stackoverflow.com/a/63807916/4723045 please check the solution given there. Mostly by 1st or 2nd solution it will be resolved. – Naveen Rao Mar 08 '21 at 04:19
  • @NaveenRao, I also found that question some minutes ago, and trying to follow the step from it, I will update the result after following that solution and let you know – wahyu Mar 08 '21 at 04:21
  • I follow the step from that question link and the error has gone, thank you @NaveenRao – wahyu Mar 08 '21 at 04:38

0 Answers0