Skip to content

[Help Wanted]: Issue with ./gradlew androidDependencies after upgrading to React Native 0.74 #2275

Open
@rarenatoe

Description

Required Reading

  • Confirmed

Plugin Version

4.17.6

Mobile operating-system(s)

  • iOS
  • Android

What do you require assistance about?

Hello,

I recently upgraded my project to React Native 0.74. Running npx react-native run-android works fine, but when I execute cd android && ./gradlew androidDependencies, I encounter the following error:

Execution failed for task ':app:androidDependencies'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
   > Could not resolve com.transistorsoft:tslocationmanager-v21:+.
     Required by:
         project :app > project :react-native-background-geolocation
      > Failed to list versions for com.transistorsoft:tslocationmanager-v21.
         > Unable to load Maven meta-data from file:/Users/renatoalegre/Repositories/mobile/node_modules/react-native-background-geolocation/android/libs/com/transistorsoft/tslocationmanager-v21/maven-metadata.xml.
            > org.xml.sax.SAXNotRecognizedException: Property 'http://javax.xml.XMLConstants/property/accessExternalSchema' is not recognized.

This happens even if I upgrade to the latest version of the package.

Could you please provide guidance on how to temporarily fix this? I want to migrate to future React Native versions, but this is a large project, so upgrading incrementally (even with patches) is necessary for us.

Any advice or workarounds would be greatly appreciated.

Thanks!

android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 31
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "26.1.10909125"
        kotlinVersion = "1.9.24"

        // Additions for react-native-background-location
        googlePlayServicesLocationVersion = "21.3.0"
        appCompatVersion = "1.6.1"
    }
    repositories {
        google()
        mavenCentral()
        // FullStory
        maven { url "https://maven.fullstory.com" }
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
        classpath("com.jaredsburrows:gradle-license-plugin:0.9.7")
        classpath("com.google.gms:google-services:4.4.2")
        classpath(localGroovy())
        classpath("com.fullstory:gradle-plugin-local:1.53.0")
    }
}

allprojects {
    repositories {
        // Required for react-native-background-geolocation
        maven { url("${project(':react-native-background-geolocation').projectDir}/libs") }

        // Required for react-native-background-fetch
        maven { url("${project(':react-native-background-fetch').projectDir}/libs") }
        
        // All of Detox' artifacts are provided via the npm module
        maven { url "$rootDir/../node_modules/detox/Detox-android" }
    }
}

apply plugin: "com.facebook.react.rootproject"

android/app/build.gradle

apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "fullstory"
apply plugin: "com.facebook.react"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
apply plugin: "com.jaredsburrows.license"

import com.android.build.OutputFile
import groovy.json.JsonSlurper

/**
 * This is the configuration block to customize your React Native Android app.
 * By default you don't need to apply any configuration, just uncomment the lines you need.
 */
react {
    /* Variants */
    //   The list of variants to that are debuggable. For those we're going to
    //   skip the bundling of the JS bundle and the assets. By default is just 'debug'.
    //   If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
    debuggableVariants = ["debug", "release"]
}

/**
* Set this to true to create four separate APKs instead of one,
 * one for each native architecture. This is useful if you don't
 * use App Bundles (https://developer.android.com/guide/app-bundle/)
 * and want to have separate APKs to upload to the Play Store.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
 */
def enableProguardInReleaseBuilds = true

/**
 * The preferred build flavor of JavaScriptCore (JSC)
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US. Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

licenseReport {
    generateHtmlReport = false
    generateJsonReport = true
    copyHtmlReportToAssets = false
    copyJsonReportToAssets = true
}

def getNpmVersion() {
    def inputFile = new File("../package.json")
    def packageJson = new JsonSlurper().parseText(inputFile.text)
    return packageJson["version"]
}

def getNpmVersionArray() { // major [0], minor [1], patch [2]
    def (major, minor, patch) = getNpmVersion().tokenize('.')
    return [Integer.parseInt(major), Integer.parseInt(minor), Integer.parseInt(patch)] as int[]
}
def npmVersion = getNpmVersionArray()
def versionMajor = npmVersion[0]
def versionMinor = npmVersion[1]
def versionPatch = npmVersion[2]

apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

Project background_geolocation = project(':react-native-background-geolocation')
apply from: "${background_geolocation.projectDir}/app.gradle"

def enableShrinkResources = true

/**
 * Private function to get the list of Native Architectures you want to build.
 * This reads the value from reactNativeArchitectures in your gradle.properties
 * file and works together with the --active-arch-only flag of react-native run-android.
 */
def reactNativeArchitectures() {
    def value = project.getProperties().get("reactNativeArchitectures")
    return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def getGitSha = {
    return 'git rev-parse HEAD'.execute().text.trim()
}

repositories {
    flatDir {
        dirs 'libs'
    }
}

fullstory {
  org "1ND1D"
  enabledVariants 'all'
  // This is enabled by default. Disabled so we can only record staging sessions.
  recordOnStart false
}

android {
    ndkVersion rootProject.ext.ndkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    compileSdk rootProject.ext.compileSdkVersion

    namespace "com.swoopmobile"

    buildFeatures {
        buildConfig = true
    }

    defaultConfig {
        applicationId "com.swoopmobile"
        manifestPlaceholders = [codeVersion: "${getGitSha()}", auth0Domain: "${project.env.get("AUTH0_DOMAIN")}", auth0Scheme: "${applicationId}.auth0"]
        minSdkVersion rootProject.ext.minSdkVersion
        missingDimensionStrategy 'react-native-camera', 'general'
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode versionMajor * 100000000 + versionMinor * 10000 + versionPatch
        versionName "${versionMajor}.${versionMinor}.${versionPatch}"
        buildConfigField "String", "GIT_SHA", "\"${getGitSha()}\""
        testBuildType System.getProperty('testBuildType', 'debug')  // This will later be used to control the test apk build type
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
        resConfigs 'en'
        resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include (*reactNativeArchitectures())
        }
    }

    signingConfigs {
        debug {
            storeFile file("debug.keystore")
        }
    }

    buildTypes {
        debug {
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            proguardFiles "${background_geolocation.projectDir}/proguard-rules.pro" // Detox-specific additions to pro-guard
            proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            shrinkResources enableShrinkResources
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            proguardFiles "${background_geolocation.projectDir}/proguard-rules.pro" // Detox-specific additions to pro-guard
            proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
        }
    }

    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        defaultConfig.versionCode * 1000 + versionCodes.get(abi)
            }
        }
    }
}

dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")

    androidTestImplementation('com.wix:detox-legacy:+')

    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }

    // Dependencies that cannot be autolinked yet can be added manually here
    implementation 'com.pixotech.android.scanner.library:AndroidScanLib@aar'
    implementation 'com.squareup.retrofit:retrofit:1.9.0'
}

// [Added by react-native-background-geolocation] Purge debug sounds from release build.
def purgeBackgroundGeolocationDebugResources(applicationVariants) {
    if ((rootProject.ext.has("removeBackgroundGeolocationDebugSoundsInRelease")) && (rootProject.ext.removeBackgroundGeolocationDebugSoundsInRelease == false)) return
    applicationVariants.all { variant ->
        if (variant.buildType.name == "release") {
            println("[react-native-background-geolocation] Purging debug resources in release build")
            variant.mergeResources.doLast {
                delete(fileTree(dir: variant.mergeResources.outputDir, includes: ["raw_tslocationmanager*"]))
            }
        }
    }
}

apply plugin: 'com.google.gms.google-services'
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions