Home > Net >  Unable to build release bundle - Deprecated Gradle features were used in this build, making it incom
Unable to build release bundle - Deprecated Gradle features were used in this build, making it incom

Time:10-21

I'm trying to make release bundle build on my react-native (0.68) android app.

All builds have been successful during development, but haven't been able to build release one.

I followed React-Native 0.68 documentation for signed apk android

Ran all the steps but on the last one ./gradlew bundleRelease it fails with the following error `Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.`

I then ran ./gradlew --warning-mode all I got more info on each incompatability but I couldn't understand how to fix them. The output:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings Execution optimizations have been disabled for 11 invalid unit(s) of work during this build to ensure correctness. Please consult deprecation warnings for more details. BUILD FAILED in 6m 16s 205 actionable tasks: 200 executed, 5 up-to-date PS C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\android> gradle --warning-mode all FAILURE: Build failed with an exception.

  • What went wrong: Could not determine java version from '11.0.15'.
  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. PS C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\android> ./gradlew --warning-mode all

Configure project :react-native-community_slider Subproject ':react-native-community_slider' has location 'C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\node_modules@react-native-community\slider\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Consult the upgrading guide for further information: https://docs.gradle.org/7.3.3/userguide/upgrading_version_7.html#deprecated_flat_project_structure Configure project :react-native-linear-gradient Subproject ':react-native-linear-gradient' has location 'C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\node_modules\react-native-linear-gradient\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Consult the upgrading guide for further information: "Link to gradle 7.3.3 uprgrading version 7"> Configure project :react-native-maps Subproject ':react-native-maps' has location 'C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\node_modules\react-native-maps\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Consult the upgrading guide for further information: "Link to gradle 7.3.3 uprgrading version 7"> Configure project :react-native-mmkv Subproject ':react-native-mmkv' has location 'C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\node_modules\react-native-mmkv\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Consult the upgrading guide for further information: "Link to gradle 7.3.3 uprgrading version 7" The RepositoryHandler.jcenter() method has been deprecated. This is scheduled to be removed in Gradle 8.0. JFrog announced JCenter's sunset in February 2021. Use mavenCentral() instead. Consult the upgrading guide for further information: "Link to gradle 7.3.3 uprgrading version 7" at build_4cd6sqel7t3rkl6rcvjfpda1e$_run_closure1$_closure2.doCall(C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\node_modules\react-native-mmkv\android\build.gradle:26) (Run with --stacktrace to get the full stack trace of this deprecation warning.) MMKV: node_modules/ found at: C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\node_modules WARNING:DSL element 'dexOptions' is obsolete and should be removed. It will be removed in version 8.0 of the Android Gradle plugin. Using it has no effect, and the AndroidGradle plugin optimizes dexing automatically. Configure project :react-native-safe-area-context Subproject ':react-native-safe-area-context' has location 'C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\node_modules\react-native-safe-area-context\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Consult the upgrading guide for further information: "Link to gradle 7.3.3 uprgrading version 7" Configure project :react-native-screens Subproject ':react-native-screens' has location 'C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\node_modules\react-native-screens\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Consult the upgrading guide for further information: "Link to gradle 7.3.3 uprgrading version 7" Configure project :react-native-svg Subproject ':react-native-svg' has location 'C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\node_modules\react-native-svg\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Consult the upgrading guide for further information: "Link to gradle 7.3.3 uprgrading version 7" Configure project :react-native-vector-icons Subproject ':react-native-vector-icons' has location 'C:\Users\nunoh\Documents\GitHub\hoopersApp\HoopersClubApp\node_modules\react-native-vector-icons\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Consult the upgrading guide for further information: "Link to gradle 7.3.3 uprgrading version 7" Task :help Welcome to Gradle 7.3.3. To run a build, run gradlew ... To see a list of available tasks, run gradlew tasks To see more detail about a task, run gradlew help --task To see a list of command-line options, run gradlew --help For more detail on using Gradle, see "Link to gradle 7.3.3 uprgrading version 7" For troubleshooting, visit https://help.gradle.org BUILD SUCCESSFUL in 1m 8s 7 actionable tasks: 1 executed, 6 up-to-date

My build.gradle inside Project/android/app:

apply plugin: "com.android.application"

import com.android.build.OutputFile
import org.apache.tools.ant.taskdefs.condition.Os

project.ext.react = [enableHermes: false,]
apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

def jscFlavor = 'org.webkit:android-jsc: '

def enableHermes = project.ext.react.get("enableHermes", false);

def reactNativeArchitectures() {
  def value = project.getProperties().get("reactNativeArchitectures")
  return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
  ndkVersion rootProject.ext.ndkVersion

  compileSdkVersion rootProject.ext.compileSdkVersion

  defaultConfig {
    applicationId "com.hoopersclubapp"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", 
    isNewArchitectureEnabled().toString()

    if (isNewArchitectureEnabled()) {
      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"
          targets "hoopersclubapp_appmodules"

          if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            arguments "NDK_APP_SHORT_COMMANDS=true"
          }
        }
      }
      if (!enableSeparateBuildPerCPUArchitecture) {
        ndk {
          abiFilters (*reactNativeArchitectures())
        }
      }
    }
  }

  if (isNewArchitectureEnabled()) {
    externalNativeBuild {
      ndkBuild {
        path "$projectDir/src/main/jni/Android.mk"
      }
    }
    def reactAndroidProjectDir = project(':ReactAndroid').projectDir
    def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
      dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
      from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
      into("$buildDir/react-ndk/exported")
    }
    def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy){
      dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
      from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
      into("$buildDir/react-ndk/exported")
    }
    afterEvaluate {
      preDebugBuild.dependsOn(packageReactNdkDebugLibs)
      preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
      configureNdkBuildRelease.dependsOn(preReleaseBuild)
      configureNdkBuildDebug.dependsOn(preDebugBuild)
      reactNativeArchitectures().each { 
        architecture -> tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
          dependsOn("preDebugBuild")
        }
        tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
          dependsOn("preReleaseBuild")
        }
      }
    }
  }

  splits {
    abi {
      reset()
      enable enableSeparateBuildPerCPUArchitecture
      universalApk false
      include (*reactNativeArchitectures())
    }
  }
  signingConfigs {
    debug {
      storeFile file('debug.keystore')
      storePassword 'android'
      keyAlias 'androiddebugkey'
      keyPassword 'android'
    }
    release {
      if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
        storeFile file(MYAPP_UPLOAD_STORE_FILE)
        storePassword MYAPP_UPLOAD_STORE_PASSWORD
        keyAlias MYAPP_UPLOAD_KEY_ALIAS
        keyPassword MYAPP_UPLOAD_KEY_PASSWORD
      }
    }
  }
  buildTypes {
    debug {
      signingConfig signingConfigs.debug
    }
    release {
      signingConfig signingConfigs.release
      minifyEnabled enableProguardInReleaseBuilds
      proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
  }

  applicationVariants.all { 
    variant -> variant.outputs.each { 
      output -> def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
      def abi = output.getFilter(OutputFile.ABI)
      if (abi != null) {
        output.versionCodeOverride=defaultConfig.versionCode*1000 versionCodes.get(abi)
      }
    }
  }

  dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])

    implementation "com.facebook.react:react-native: " 

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
      exclude group:'com.facebook.fbjni'
    }

  debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}"){
    exclude group:'com.facebook.flipper'
    exclude group:'com.squareup.okhttp3', module:'okhttp'
  }

  debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
  }

  if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath   "hermes-debug.aar")
    releaseImplementation files(hermesPath   "hermes-release.aar")
  } else {
    implementation jscFlavor
  }
}

if (isNewArchitectureEnabled()) {
  configurations.all {
    resolutionStrategy.dependencySubstitution {
      substitute(module("com.facebook.react:react-native")).using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
    }
  }
}

task copyDownloadableDepsToLibs(type: Copy) {
  from configurations.implementation
  into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

def isNewArchitectureEnabled() {
  return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

(I had to remove some of the links from the output as I dont have enough reputation to be able to add them. Plus, it was always the same link)

I'm running React-native 0.68. Graddle 7.3.3. On windows 11 Home v.10.0.22

Hopefully someone can help out or guide through next steps to solve it and be able to build my Release APK.

CodePudding user response:

Found out that updating to gradle 7.4 makes it work. Github issue here

  • Related