question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build error "Could not get unknown property 'preDebugBuild' for extension 'android'"

See original GitHub issue

New Version

0.68.0

Old Version

0.67.3

Build Target(s)

android

Output of react-native info

System:
    OS: macOS 12.2.1
    CPU: (8) arm64 Apple M1
    Memory: 775.20 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.10.0 - /opt/homebrew/bin/node
    Yarn: 1.22.15 - ~/.yarn/bin/yarn
    npm: 7.24.0 - /opt/homebrew/bin/npm
    Watchman: 2021.09.27.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK:
      API Levels: 23, 29, 30, 31
      Build Tools: 30.0.2, 30.0.3, 31.0.0
      System Images: android-31 | Google APIs ARM 64 v8a
      Android NDK: 21.4.7075529
  IDEs:
    Android Studio: 2021.1 AI-211.7628.21.2111.8309675
    Xcode: 13.3/13E113 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.12 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: Not Found
    react-native: Not Found
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

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’.

Could not get unknown property ‘preDebugBuild’ for extension ‘android’ of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:9
  • Comments:21 (2 by maintainers)

github_iconTop GitHub Comments

39reactions
obladorcommented, Apr 20, 2022

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)
                }
            }
        }
    }
}
8reactions
Abhishek2250commented, Apr 26, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

could not get unknown property 'predebugbuild' for extension ...
I just imported the project from github and tried to build in Android Studio but I get this error: Could not get unknown...
Read more >
Could not get unknown property 'url' for extension 'android' of ...
Go to your gradle.properties and create a line with your api. Example: Myapitoken ...
Read more >
Fix Error: Could Not Get Unknown Property '*_version' | Android
Could Not Get Unknown Property '*_version' | AndroidPut ext.kotlin_version = '1.3.50'In build grade + clean your project and run.
Read more >
Could not get unknown property 'intermediateDir' - Issue Tracker
google.gms.googleservices.GoogleServicesTask. ``` and on another app ``` Execution failed for task ':app:uploadCrashlyticsMappingFileStagingDebug'. > Failed ...
Read more >
"Could not get unknown property 'ndkVersion' for extension ...
Hello Community, I have been trying to test my flutter app with an ios / android instance. Every time I try to build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found