Home > other >  Task :react-native-async-storage_async-storage:generateDebugRFile FAILED
Task :react-native-async-storage_async-storage:generateDebugRFile FAILED

Time:11-07

I am having problems running my React Native application that was running fine just yesterday. Therefore I ran the command:

npx react-native run-android -- --warning-mode=all

Which gives information starting with:

> Task :react-native-async-storage_async-storage:generateDebugRFile FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

FAILURE: Build failed with an exception.

...

* What went wrong:
Execution failed for task ':react-native-async-storage_async-storage:generateDebugRFile'.
> Could not resolve all files for configuration ':react-native-async-storage_async-storage:debugCompileClasspath'.
> Failed to transform react-native-0.71.0-rc.0-debug.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
  > Execution failed for JetifyTransform: C:\Users\pangi\.gradle\caches\modules-2\files-2.1\com.facebook.react\react-native\0.71.0-rc.0\7a7f5a0af6ebd8eb94f7e5f7495e9d9684b4f543\react-native-0.71.0-rc.0-debug.aar.
     > Java heap space

My first problem is how to resolve this issue? I seem to be unable to find resolutions for this particular issue on the Internet. Obviously it is related to the 'async storage' package and I did update it, however that did not resolve the issue.

Supposedly using the "--warning-mode=all" verbiage should provide links to Gradle to help resolve the issue...however I see none. I also notice in that output mention is given of 'react-native-0.71' however I am using a lower version...not sure if that is related to the issue. Any advice appreciated.

My second question is more general. Why do nonsensical and ridiculous things like this CONSTANTLY happen in React Native? As mentioned, the code worked fine last time I booted up. I can make no changes whatsoever to my code (or minimal ones) and suddenly the code is broken and non-functional...through no fault of my own but relating to some npm package or some other reason (Gradle for example) that has nothing to do with me. I have never seen, nor imagined...that such an unreliable and 'bug-ridden' piece of software could be released to the general public. Why are issues like this consistently occurring in React Native? Is it just incompetence or is there a better answer? I am always dealing with unending frustration and anger due to these practices causing me problems with this particular platform. If somebody could explain why this development 'environment' is riddled with these problems I would be most appreciative.

CodePudding user response:

There will be build failures for Android due to the publish of the React Native version 0.71.0-rc0.

Add this fix to your android -> build.gradle file as follows:

buildscript {
    // ...
}


allprojects {
    repositories {
       exclusiveContent {
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
               }
           }
       }
        // ...
    }
}

What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules

Ref: Fix and updates on Android build failures happening since Nov 4th 2022 #35210

CodePudding user response:

The OP seem angry and honestly, i do understand why he is and i doubt why he shouldnt. I havent run build for 2 days until yesterday, 5th of november when i ran npx react-native run-android then this error was noticed. I had spent close to 24 hours searching the solution until i stumbled on this question.

This fix according to @Thanhal works for me.

I tweaked my android/build.gradle. Here is the full content of my gradle file and the fix.

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

buildscript {

    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        ndkVersion = "21.4.7075529"
        kotlinVersion = '1.6.0'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.2")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {

        // ------ Fix starts here

        exclusiveContent {
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
               }
           }
       }
       
       // --------- Fix ends here

       
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        mavenCentral {
            // We don't want to fetch react-native from Maven Central as there are
            // older versions over there.
            content {
                excludeGroup "com.facebook.react"
            }
        }
        google()
        maven { url 'https://www.jitpack.io' }
    }
}

I hope this also helps somebody out there.

  • Related