transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.66k stars 426 forks source link

Could not find com.huawei.hms:location:6.9.0.300. #1686

Closed mgsbabu closed 1 year ago

mgsbabu commented 1 year ago

Your Environment

Expected Behavior

Actual Behavior

Not able to get the app run in debug mode.

Steps to Reproduce

  1. went through all the installation instructions exactly as described.

Context

Debug logs

BUILD FAILED in 21s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

My build.gradle look like import org.apache.tools.ant.taskdefs.condition.Os

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

buildscript { ext { buildToolsVersion = "31.0.0" minSdkVersion = 21 compileSdkVersion = 33 targetSdkVersion = 33 appCompatVersion = "1.4.2" googlePlayServicesLocationVersion = "20.0.0"

    if (System.properties['os.arch'] == "aarch64") {
        // For M1 Users we need to use the NDK 24 which added support for aarch64
        ndkVersion = "24.0.8215888"
    } else {
        // Otherwise we default to the side-by-side NDK version from AGP.
        ndkVersion = "21.4.7075529"
    }
}
repositories {
    google()
    mavenCentral()
    jcenter()
}

dependencies {
    classpath("com.android.tools.build:gradle:7.0.4")
    classpath("com.facebook.react:react-native-gradle-plugin")
    classpath("de.undercouch:gradle-download-task:4.1.2")
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

allprojects {

configurations.all {
    resolutionStrategy {
        force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
    }
}
repositories {
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url("$rootDir/../node_modules/react-native/android")
    }
    maven {
        // Android JSC is installed from npm
        url("$rootDir/../node_modules/jsc-android/dist")
    }
    maven {
        url("${project(':react-native-background-geolocation').projectDir}/libs")
    }
    maven {
        url("${project(':react-native-background-fetch').projectDir}/libs")
    }
    mavenCentral {
        // We don't want to fetch react-native from Maven Central as there are
        // older versions over there.
        content {
            excludeGroup "com.facebook.react"
        }
    }
    google()
    jcenter()
    maven { url 'https://www.jitpack.io' }
}

}

christocracy commented 1 year ago

I assume you solved your own problem and it had something to do with replacing the obsolete jCenter() with mavenCentral()

mgsbabu commented 1 year ago

Thank you Christocracy for your comment.

Why am I getting that even through I am installing in the android emulator nexus 30 device. Nothing to do with Huwaie. That too after installing react-native-background-geolocation.

Screenshot 2023-05-24 at 11 21 54 AM

Above error is gone if I include maven { url 'https://developer.huawei.com/repo/' } in the allProjects.repositories section in build.gradle. Where as I am getting a popup after my app got opened once the react-native-background lcoation is initialized. - "some features in app may not work properly without HMS core which is not installed on your device".

Its not huwaei device, this error should not come at all.

mgsbabu commented 1 year ago

I can't test the functionality in debug mode because of the above popup as the emulator goes into freeze mode and I can't do anything after that. Why is that strange error is coming even though the device is not huawei device

Stuck now. Can't move further. Please help.

christocracy commented 1 year ago

Perhaps Google Play Services is not installed on that device.

IcaroBrunoDev commented 1 year ago

I found the same problem, and i did a reverse enginner process to find what i made before the error. I`ve been using WatermelonDB on my project and somethimes when i need to do a .aab file, i run into a gradle error using gradle 7.5.1. Then i changed the gradle version up to 7.6 and after this upgrade i started to get the "Could not find com.huawei.hms:location:6.9.0.300." error. Try to change the gradle to 7.5.1 or less and it should work, worked for me.

christocracy commented 1 year ago

Do you have jcenter in any of your gradle files’ repositories sections?

IcaroBrunoDev commented 1 year ago

Hey @christocracy, I dont. I've mavenCentral and maven

christocracy commented 1 year ago

Show me your entire android/build.gradle

IcaroBrunoDev commented 1 year ago

Here @christocracy :


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

buildscript {
    ext {
        buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0'
        minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
        compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31')
        targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31')

        kotlinVersion = "1.6.0"
        appCompatVersion = "1.4.2"
        googlePlayServicesLocationVersion = "20.0.0"

        // if (findProperty('android.kotlinVersion')) {
        //     kotlinVersion = findProperty('android.kotlinVersion')
        // }
        frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'

        if (System.properties['os.arch'] == 'aarch64') {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = '24.0.8215888'
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = '21.4.7075529'
        }
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:7.3.1')
        classpath('com.facebook.react:react-native-gradle-plugin')
        classpath('de.undercouch:gradle-download-task:5.0.1')
        classpath 'com.google.gms:google-services:4.3.15'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

def REACT_NATIVE_VERSION = new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

allprojects {
    configurations.all {
        resolutionStrategy {
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }

    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
        }
        maven {
            // Android JSC is installed from npm
            url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
        }
        maven {
           // Required for react-native-background-geolocation
           url("${project(':react-native-background-geolocation').projectDir}/libs")
        }
        maven {
           // react-native-background-fetch
           url("${project(':react-native-background-fetch').projectDir}/libs")
        }

        google()
        mavenCentral {
            // We don't want to fetch react-native from Maven Central as there are
            // older versions over there.
            content {
                excludeGroup 'com.facebook.react'
            }
        }
        maven { url 'https://www.jitpack.io' }
    }
}
// @generated begin expo-camera-import - expo prebuild (DO NOT MODIFY) sync-f244f4f3d8bf7229102e8f992b525b8602c74770
def expoCameraMavenPath = new File(["node", "--print", "require.resolve('expo-camera/package.json')"].execute(null, rootDir).text.trim(), "../android/maven")
allprojects { repositories { maven { url(expoCameraMavenPath) } } }
// @generated end expo-camera-import
christocracy commented 1 year ago

Try this:

allprojects {
    repositories {
         .
         .
         .
+       maven {url 'https://developer.huawei.com/repo/'}
    }
} 
IcaroBrunoDev commented 1 year ago

@christocracy It's working now, i upgraded my gradle again to 7.6.1 and everything is fine now, thank you.

christocracy commented 1 year ago

This maven repo is now required for newer gradle versions. It will be added to the plug-in Setup Instructions.

christocracy commented 1 year ago

now, i upgraded my gradle again to 7.6.1 and everything is fine now,

With or without the added maven url I mentioned recently?

I don’t seem to require the added maven url in my end.

IcaroBrunoDev commented 1 year ago

@christocracy Hey man, with the maven that you mentioned, without that isn`t work with gradle 7.6+, only with 7.5 or less.

Follow my gradle file:

repositories { ... maven { url 'https://developer.huawei.com/repo/' } }

And my gradle-wrapper.properties:

distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists

christocracy commented 1 year ago

Thanks. The Android Setup Instructions will be updated to require adding the maven url.

allprojects {
    repositories {
         .
         .
         .
+       maven {url 'https://developer.huawei.com/repo/'}
    }
} 
jingp-ofload commented 1 year ago

@christocracy How could I make this happen with expo?

jingp-ofload commented 1 year ago

Try this:

allprojects {
    repositories {
         .
         .
         .
+       maven {url 'https://developer.huawei.com/repo/'}
    }
} 

How could I have this without manual update build.gradle because I am using expo?

christocracy commented 1 year ago

Perhaps, I forgot to update the Expo repo with this maven url.

in the meantime, you can rollback to the version where HMS support was introduced a few months ago. See the CHANGELOG.

christocracy commented 1 year ago

This will be fixed in the next release soon.

christocracy commented 1 year ago

Try installing 4.13.1

jingp-ofload commented 1 year ago

Try installing 4.13.1

Many thanks for the quick response. In my case, after upgrade to 4.13.1, I am encountering a timeout error in our CI/CD build. Here is the error log: Screenshot 2023-08-25 at 3 48 47 pm

jingp-ofload commented 1 year ago

@christocracy After retry the build it passed. I think this thread can be closed. Cheers.

ahmedabartaieb commented 11 months ago

i get the same problem : Could not resolve com.huawei.hms:availableupdate:6.5.0.300.

this is the file android/app/build.gradle :

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services'

// background-geolocation
Project background_geolocation = project(':react-native-background-geolocation')
apply from: "${background_geolocation.projectDir}/app.gradle"
 react {
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc:+'
android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    namespace "com.marketme"
    defaultConfig {
        applicationId "com.marketme"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 4
        versionName "0.0.5"
    }
    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 {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.

            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            proguardFiles "${background_geolocation.projectDir}/proguard-rules.pro"
            signingConfig signingConfigs.release

        }
    }
}

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

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

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

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
    implementation 'com.google.android.gms:play-services-location:21.0.1'
}

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

file : android/build.gradle

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

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 26
        compileSdkVersion = 33
        targetSdkVersion = 33
        kotlinVersion = "1.7.0"
        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
        playServicesLocationVersion = "21.0.1"
    }
    repositories {
        google()
        mavenCentral()
        }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath 'com.google.gms:google-services:4.3.15'  
    }
}
allprojects { 
     repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        maven { url("${project(':react-native-background-geolocation').projectDir}/libs") }
        maven { url 'https://developer.huawei.com/repo/' }
       // Required for react-native-background-fetch
        maven { url("${project(':react-native-background-fetch').projectDir}/libs") }
     }
}
christocracy commented 11 months ago

I suggest you post the entire error message you receive in the terminal / Android Studio (as TEXT -- not a screenshot)