mauron85 / react-native-background-geolocation

Background and foreground geolocation plugin for React Native. Tracks user when app is running in background.
Apache License 2.0
1.33k stars 559 forks source link

Error build android: Could not resolve all files for configuration #581

Closed huy-lv closed 1 year ago

huy-lv commented 1 year ago

Your Environment

Context

I installed package follow this instruction: https://github.com/mauron85/react-native-background-geolocation#android-setup Then I got this error:

Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: 
Could not resolve all files for configuration ':@mauron85_react-native-background-geolocation-common:debugCompileClasspath'.

Expected Behavior

Actual Behavior

Possible Fix

Steps to Reproduce

  1. In android/settings.gradle
    include ':@mauron85_react-native-background-geolocation-common'
    project(':@mauron85_react-native-background-geolocation-common').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/common')
    include ':@mauron85_react-native-background-geolocation'
    project(':@mauron85_react-native-background-geolocation').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/lib')
  2. In android/app/build.gradle
    dependencies {
    ...
    compile project(':@mauron85_react-native-background-geolocation')
    ...
    }
  3. Register the module (in MainApplication.java)
  4. add android:exported="true" in /node_modules/@mauron85/react-native-background-geolocation/android/lib/src/main/AndroidManifest.xml

Context

Debug logs

huy-lv commented 1 year ago

When you run react-native run-android, you should see the root cause. In my project, root cause is:

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: 
Could not find com.google.android.gms:play-services-location:18.1.0.

So I fixed this by add this line

buildscript {
    ext {
        playServicesVersion = "18.0.0"
    }
}