I have been trying to build React Native App i have been searching everywhere I cannot solve this issue. Any help or advise would be very much apprenticed.
My Android build has this error:
/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt: (137, 11): This declaration is experimental and its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)'
In the react-native-gradle-plugin i have found the file BundleHermesCTask.kt. Within this file it is showing me an error at this function i can put this line above the function @OptIn(ExperimentalStdlibApi::class) and the program will build and work but changing the node module is not a solution as it will be overwritten.
internal fun getBundleCommand(bundleFile: File, sourceMapFile: File): List<Any> =
windowsAwareCommandLine(
buildList {
addAll(nodeExecutableAndArgs.get())
add(cliFile.get().asFile.absolutePath)
add(bundleCommand.get())
add("--platform")
add("android")
add("--dev")
add(devEnabled.get().toString())
add("--reset-cache")
add("--entry-file")
add(entryFile.get().asFile.toString())
add("--bundle-output")
add(bundleFile.toString())
add("--assets-dest")
add(resourcesDir.get().asFile.toString())
add("--sourcemap-output")
add(sourceMapFile.toString())
if (bundleConfig.isPresent) {
add("--config")
add(bundleConfig.get().asFile.absolutePath)
}
add("--minify")
add(minifyEnabled.get().toString())
addAll(extraPackagerArgs.get())
add("--verbose")
})
I have search online and tried everything from checking my java version and checking all dependencies are loading the same version also updating react native and dependencies. the only thing i can get to work is changing the file BundleHermesCTask.kt and i cannot do this as the build process will move the app and do npm install of all dependencies and the changes are lost.
I have checked the github pages and also been trying to figure out kotlin more about kotlin and reading the docs on the
https://kotlinlang.org/docs/opt-in-requirements
What version of Gradle are your using? I solved by upgrading to Gradle 7.5.1 as answered here