okta-react-native icon indicating copy to clipboard operation
okta-react-native copied to clipboard

Error generating debug R file while building

Open thekevinbrown opened this issue 2 years ago • 5 comments

Describe the bug?

We often experience the following issue when trying to build our React Native application for Android:

gradle: Execution failed for task ':okta-react-native:generateDebugRFile'.
gradle: > A failure occurred while executing com.android.build.gradle.internal.res.GenerateLibraryRFileTask$GenerateLibRFileRunnable
gradle:    > [project path]/src/node_modules/.pnpm/@[email protected]_6a8aa212aad327edf7fc3cad5533ab53/node_modules/@okta/okta-react-native/android/build/intermediates/local_only_symbol_list/debug/R-def.txt

What is expected to happen?

I expect the build to work reliably.

What is the actual behavior?

When this error occurs, we clear the build caches then rebuild and are able to build successfully. It seems that there are undeclared dependencies between your build steps, as we also see a bunch of warnings like so:

gradle: Execution optimizations have been disabled for task ':okta-react-native:compileDebugJavaWithJavac' to ensure correctness due to the following reasons:
gradle:   - Gradle detected a problem with the following location: '[project path]/src/node_modules/.pnpm/@[email protected]_6a8aa212aad327edf7fc3cad5533ab53/node_modules/@okta/okta-react-native/android/build/generated/aidl_source_output_dir/debug/out'. Reason: Task ':okta-react-native:compileDebugJavaWithJavac' uses this output of task ':okta_okta-react-native:compileDebugAidl' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
gradle:   - Gradle detected a problem with the following location: '[project path]/src/node_modules/.pnpm/@[email protected]_6a8aa212aad327edf7fc3cad5533ab53/node_modules/@okta/okta-react-native/android/build/generated/renderscript_source_output_dir/debug/out'. Reason: Task ':okta-react-native:compileDebugJavaWithJavac' uses this output of task ':okta_okta-react-native:compileDebugRenderscript' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
gradle: - Gradle detected a problem with the following location: '[project path]/src/node_modules/.pnpm/@[email protected]_6a8aa212aad327edf7fc3cad5533ab53/node_modules/@okta/okta-react-native/android/build/intermediates/compile_r_class_jar/debug/R.jar'. Reason: Task ':okta-react-native:compileDebugJavaWithJavac' uses this output of task ':okta_okta-react-native:generateDebugRFile' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
gradle: 
gradle: > Task :okta_okta-react-native:generateDebugBuildConfig UP-TO-DATE
gradle: > Task :okta_okta-react-native:javaPreCompileDebug UP-TO-DATE
gradle: 
gradle: > Task :okta-react-native:bundleLibCompileToJarDebug FAILED
gradle: Execution optimizations have been disabled for task ':okta-react-native:bundleLibCompileToJarDebug' to ensure correctness due to the following reasons:
gradle:   - Gradle detected a problem with the following location: '[project path]/src/node_modules/.pnpm/@[email protected]_6a8aa212aad327edf7fc3cad5533ab53/node_modules/@okta/okta-react-native/android/build/intermediates/compile_r_class_jar/debug/R.jar'. Reason: Task ':okta-react-native:bundleLibCompileToJarDebug' uses this output of task ':okta_okta-react-native:generateDebugRFile' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
gradle: > Task :okta_okta-react-native:compileDebugJavaWithJavac
gradle: Execution optimizations have been disabled for task ':okta_okta-react-native:compileDebugJavaWithJavac' to ensure correctness due to the following reasons:
gradle:   - Gradle detected a problem with the following location: '[project path]/src/node_modules/.pnpm/@[email protected]_6a8aa212aad327edf7fc3cad5533ab53/node_modules/@okta/okta-react-native/android/build/generated/aidl_source_output_dir/debug/out'. Reason: Task ':okta_okta-react-native:compileDebugJavaWithJavac' uses this output of task ':okta-react-native:compileDebugAidl' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
gradle:   - Gradle detected a problem with the following location: '[project path]/src/node_modules/.pnpm/@[email protected]_6a8aa212aad327edf7fc3cad5533ab53/node_modules/@okta/okta-react-native/android/build/generated/renderscript_source_output_dir/debug/out'. Reason: Task ':okta_okta-react-native:compileDebugJavaWithJavac' uses this output of task ':okta-react-native:compileDebugRenderscript' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
gradle:   - Gradle detected a problem with the following location: '[project path]/src/node_modules/.pnpm/@[email protected]_6a8aa212aad327edf7fc3cad5533ab53/node_modules/@okta/okta-react-native/android/build/generated/source/buildConfig/debug'. Reason: Task ':okta_okta-react-native:compileDebugJavaWithJavac' uses this output of task ':okta-react-native:generateDebugBuildConfig' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
gradle:   - Gradle detected a problem with the following location: '[project path]/src/node_modules/.pnpm/@[email protected]_6a8aa212aad327edf7fc3cad5533ab53/node_modules/@okta/okta-react-native/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json'. Reason: Task ':okta_okta-react-native:compileDebugJavaWithJavac' uses this output of task ':okta-react-native:javaPreCompileDebug' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
gradle:   - Gradle detected a problem with the following location: '[project path]/src/node_modules/.pnpm/@[email protected]_6a8aa212aad327edf7fc3cad5533ab53/node_modules/@okta/okta-react-native/android/build/intermediates/compile_r_class_jar/debug/R.jar'. Reason: Task ':okta_okta-react-native:compileDebugJavaWithJavac' uses this output of task ':okta-react-native:generateDebugRFile' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
gradle: 
gradle: > Task :app:processDebugManifestForPackage
gradle: 
gradle: Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
gradle: 
gradle: You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
gradle: 
gradle: See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings
gradle: 
gradle: Execution optimizations have been disabled for 11 invalid unit(s) of work during this build to ensure correctness.

Reproduction Steps?

Build the application with the React Native CLI. We're currently running

  • react-native: 0.67.4
  • @okta/okta-react-native: 2.5.0

Additional Information?

A great starting point would be to declare the dependencies between the build steps, which I suspect would resolve this error.

SDK Version

2.5.0

Build Information

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        playServicesVersion = "17.0.0"
        androidMapsUtilsVersion = "2.2.2"
	    ndkVersion = "21.4.7075529"
    }
    repositories {
        google()
	    mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.2")
    }
}

allprojects {
    repositories {
        maven {
             url(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../android"))
        }
        maven {
            url(new File(["node", "--print", "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), "../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' }
    }
}

thekevinbrown avatar Aug 25 '22 05:08 thekevinbrown

Thank you for reporting this. @jaynewstrom-okta could you take a look at this when you have a chance?

mikenachbaur-okta avatar Aug 26 '22 01:08 mikenachbaur-okta

@thekevinbrown ....I got this error if i run it on emulator. code worked fine on simulator. Screenshot 2022-11-16 at 1 43 58 AM

guide me how to clear this error. error screenshot is attached

ghost avatar Nov 15 '22 20:11 ghost

The only solution we as consumers of the library have is to clean and rebuild over and over again until the timing manages to work out. It sometimes takes 7 or 8 builds on my machine for it to work. If Okta declare the dependencies correctly this will go away for people.

thekevinbrown avatar Nov 15 '22 22:11 thekevinbrown

Seeing the same. Wondering why this is happening, seems to not happen to everyone. I've also seen the same on @react-native-community/netinfo (https://github.com/react-native-netinfo/react-native-netinfo/issues/639), but that went away.

eithe avatar Aug 18 '23 10:08 eithe

It also happens with:

  • react-native: 0.72.4
  • @okta/okta-react-native: 2.9.1

lbuttignol avatar Sep 07 '23 00:09 lbuttignol