Closed rvasseur31 closed 2 years ago
Getting same error after setting newArchEnabled=true. upgraded to 0.68.0 with help of the Upgrade Helper.
System OS: Windows 11 RN: 0.68.0
Getting same error newArchEnabled=true. It looks like it happens during build using gradle productFlavors
System OS: Windows 11 RN: 0.68.0
Getting same error newArchEnabled=true. It looks like it happens during build using gradle productFlavors
@SergioAN007 Are you able to get the build working by removing productFlavors? Thanks!
Let's isolate the upgrade 0.67 -> 068 and the newArchEnabled=true
.
Are you able to build correctly after the update to 0.68 with newArchEnabled=false
?
I'm getting the same error too after upgrading from 0.67 -> 0.68 when newArchEnabled=true. But i was able to build it when newArchEnabled=false.
Let's isolate the upgrade 0.67 -> 068 and the
newArchEnabled=true
. Are you able to build correctly after the update to 0.68 withnewArchEnabled=false
?
newArchEnabled=false. --> build normal using RN68 newArchEnabled=true. --> Could not get unknown property 'preDebugBuild' for extension 'android
This error passed when build flower main and edit app\gradle: preMainDebugBuild.dependsOn(packageReactNdkDebugLibs) preMainReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
But i have many errors later ecxeption link: https://shorturl.at/fikH3
Let's isolate the upgrade 0.67 -> 068 and the
newArchEnabled=true
. Are you able to build correctly after the update to 0.68 withnewArchEnabled=false
?
Correct. Works fine with fabric disabled. But we're getting the above error when enabling. We use product flavours, if that's to any help. (Works fine on iOS when enabling new arch.
Looks like it's caused by product flavours. We have "staging" and "production", changing preDebugBuild
to preStagingDebugBuild
seems to work, ie inserting your flavour.
Can someone here validate that my fix solves your issues too?
afterEvaluate {
// If you wish to add a custom TurboModule or component locally,
// you should uncomment this line.
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
android.applicationVariants.all { def variant ->
def variantName = variant.name.capitalize()
def preVariantBuildTask = tasks.findByName("pre${variantName}Build")
// Due to a bug inside AGP, we have to explicitly set a dependency
// between configureNdkBuild* tasks and the preBuild tasks.
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
if (variantName.endsWith("Debug")) {
preVariantBuildTask.dependsOn(packageReactNdkDebugLibs)
configureNdkBuildDebug.dependsOn(preVariantBuildTask)
reactNativeArchitectures().each { architecture ->
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
dependsOn(preVariantBuildTask.name)
}
}
}
if (variantName.endsWith("Release")) {
preVariantBuildTask.dependsOn(packageReactNdkReleaseLibs)
configureNdkBuildRelease.dependsOn(preVariantBuildTask)
reactNativeArchitectures().each { architecture ->
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
dependsOn(preVariantBuildTask.name)
}
}
}
}
}
I confirm that this fixes the bug !
@oblador I'm getting below issue: Could not get unknown property 'configureNdkBuildDebug' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.
NDK version: 24.0.8215888 System: Apple M1 pro reactNativeArchitectures=x86_64 -> in gradle.properties.
i am having the same issue & I tried @oblador fix but i got another error from it.
* What went wrong:
Could not determine the dependencies of task ':ReactAndroid:packageReactNdkDebugLibsForBuck'.
> Task with path 'mergeDebugNativeLibs' not found in project ':ReactAndroid'.
So I am grateful for any suggestions here.
@oblador I'm getting below issue: Could not get unknown property 'configureNdkBuildDebug' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.
NDK version: 24.0.8215888 System: Apple M1 pro reactNativeArchitectures=x86_64 -> in gradle.properties.
@oblador I am also facing same issue after applying your solution
i am having the same issue & I tried @oblador fix but i got another error from it.
* What went wrong: Could not determine the dependencies of task ':ReactAndroid:packageReactNdkDebugLibsForBuck'. > Task with path 'mergeDebugNativeLibs' not found in project ':ReactAndroid'.
So I am grateful for any suggestions here.
if you have a line ndk.dir
in your local.properties
, try to comment this line
@oblador I'm getting below issue: Could not get unknown property 'configureNdkBuildDebug' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl. NDK version: 24.0.8215888 System: Apple M1 pro reactNativeArchitectures=x86_64 -> in gradle.properties.
@oblador I am also facing same issue after applying your solution
I'm also getting the same error, any progress on this?
It would make sens to put @oblador patch in rnfdiff app ! but thank you !
@oblador I'm getting below issue: Could not get unknown property 'configureNdkBuildDebug' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl. NDK version: 24.0.8215888 System: Apple M1 pro reactNativeArchitectures=x86_64 -> in gradle.properties.
@oblador I am also facing same issue after applying your solution
I'm also getting the same error, any progress on this?
I'm also facing this issue, do not forgot to change
android {
defaultConfig {
externalNativeBuild {
ndkBuild {
arguments "APP_PLATFORM=android-21",
"APP_STL=c++_shared",
"NDK_TOOLCHAIN_VERSION=clang",
"GENERATED_SRC_DIR=$buildDir/generated/source",
"PROJECT_BUILD_DIR=$buildDir",
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
cppFlags "-std=c++17"
// Make sure this target name is the same you specify inside the
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
targets "sample_appmodules"
}
}
}
}
and
// We configure the NDK build only if you decide to opt-in for the New Architecture.
externalNativeBuild {
ndkBuild {
path "$projectDir/src/main/jni/Android.mk"
}
}
Same issue here
I also face the same issue after upgrading from 0.68.0 to 0.69.0, I followed manual upgrade instructions. Seems that everything that had to be chaged, I did change. I tried to use answer provided by @oblador but this did not solve the issue.
reactNativeArchitectures
It worked for me for the debug, though it still does not work for my release flavors, I have multiple releases for each flavor.
Anyone with the same problem could make it work?
@oblador I'm getting below issue: Could not get unknown property 'configureNdkBuildDebug' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.
NDK version: 24.0.8215888 System: Apple M1 pro reactNativeArchitectures=x86_64 -> in gradle.properties.
I had the same issue and this fixed it for me. It seems like https://issuetracker.google.com/issues/207403732 is solved on AGP 7.3.0:
afterEvaluate {
// If you wish to add a custom TurboModule or component locally,
// you should uncomment this line.
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
android.applicationVariants.all { def variant ->
def variantName = variant.name.capitalize()
def preVariantBuildTask = tasks.findByName("pre${variantName}Build")
}
}
i tried all the Solutions Here but Nothing Worked for me i still get Same Error
"react": "18.1.0", "react-native": "0.70.6",
Error :
Could not get unknown property 'preDebugBuild' for extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.
Please Help
I faced this same issue. I'm configuring different product flavors on react-native 0.70.6
and new arch enabled. Macbook Pro M1, MacOS Monterey 12.3.1.
I tried @oblador 's afterEvaluate
fix on android/app/build.gradle
, and I got the same build error as others:
Could not get unknown property 'configureNdkBuildDebug' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.
After reading @christopherklint97 's comment I tried updating AGP to newer versions, but I couldn't get it to work. I came to the conclusion that surely this isn't an option (at least in my case). Still using AGP 7.2.1.
I managed to get product flavors working on RN 0.70.6 by making some modifications to oblador's code. Here's the modified fix in case it helps someone else:
afterEvaluate {
// If you wish to add a custom TurboModule or component locally,
// you should uncomment this line.
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
android.applicationVariants.all { def variant ->
def variantName = variant.name.capitalize()
def preVariantBuildTask = tasks.findByName("pre${variantName}Build")
// Due to a bug inside AGP, we have to explicitly set a dependency
// between configureCMakeDebug* tasks and the preBuild tasks.
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
if (variantName.endsWith("Debug")) {
preVariantBuildTask.dependsOn(packageReactNdkDebugLibs)
configureCMakeDebug.dependsOn(preVariantBuildTask)
reactNativeArchitectures().each { architecture ->
tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
dependsOn(preVariantBuildTask.name)
}
}
}
if (variantName.endsWith("Release")) {
preVariantBuildTask.dependsOn(packageReactNdkReleaseLibs)
configureCMakeRelWithDebInfo.dependsOn(preVariantBuildTask)
reactNativeArchitectures().each { architecture ->
tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
dependsOn(preVariantBuildTask.name)
}
}
}
}
}
Not sure if this solution is entirely correct. It's working for me though. It's similar to @oblador 's fix, but switching some NDK lines with their CMake counterparts, taking into account that RN 0.70 introduced support for CMake (so it makes some sense that this would work). I'd love to hear if someone sees a problem with this solution.
Just a heads up that this has been fully fixed in RN 0.71. If you update version everything should work without extra scripts or patches needed.
New Version
0.68.0
Old Version
0.67.3
Build Target(s)
android
Output of
react-native info
Issue and Reproduction Steps
After the update, when I run
yarn android
with newArchitecture enabled, I got the following error :FAILURE: Build failed with an exception.
Where: Build file '/Users/rvasseur/Desktop/LoungeUp/staffcompanion-rn/android/app/build.gradle' line: 224
What went wrong: A problem occurred configuring project ':app'.