App crash.
BackgroundGeolocation.configure(...) // see below
setTimeout(() => {
BackgroundGelolocation.start();
}, 5000);
Crash when started (after 5 sec) :(
Tested on Redmi 4X, HTC M8 (Android 6.0) and Simulator (Nexus 5X API 24)
FATAL EXCEPTION: main
Process: com.myapp, PID: 6392
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/location/DetectedActivity;
at com.marianhello.bgloc.provider.ActivityRecognitionLocationProvider.<init>(ActivityRecognitionLocationProvider.java:40)
at com.marianhello.bgloc.provider.LocationProviderFactory.getInstance(LocationProviderFactory.java:40)
at com.marianhello.bgloc.LocationService.onStartCommand(LocationService.java:247)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3297)
at android.app.ActivityThread.-wrap21(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.ClassNotFoundException: com.google.android.gms.location.DetectedActivity
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzbgl;
... 12 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.internal.zzbgl" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-1/lib/x86, /data/app/com.myapp-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 12 more
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// Google now hosts their latest API dependencies on their own maven server.
// React Native will eventually add this to their app template.
maven {
url "https://maven.google.com"
}
maven {
url "$rootDir/../node_modules/react-native-background-fetch/android/libs"
}
}
}
ext {
compileSdkVersion = 26
targetSdkVersion = 26
buildToolsVersion = "27.0.3"
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "11.8.0"
oreoEXPERIMENTAL = "yes"
}
app/build.gradle
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
applicationId "hu.hatarinfo.react"
minSdkVersion 16
targetSdkVersion rootProject.targetSdkVersion
multiDexEnabled true
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
. . . . .
}
dependencies {
compile project(':react-native-onesignal')
compile project(':react-native-push-notification-ce')
compile project(':react-native-keep-awake')
compile project(':react-native-device-info')
compile project(':react-native-background-fetch')
compile project(':react-native-vector-icons')
compile project(':react-native-mauron85-background-geolocation')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:multidex:1.0.1"
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}
BackgroundGeolocation.configure({
debug: true,
stopOnTerminate: false,
desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER,
// locationProvider: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER,
// Android
interval: 10000,
startOnBoot: false,
notificationTitle: 'Background tracking',
notificationText: 'enabled',
// iOS
// activityType: '',
pauseLocationUpdates: false,
saveBatteryOnBackground: false,
// DISTANCE_FILTER_PROVIDER
distanceFilter: 8,
stationaryRadius: 25,
// ACTIVITY_PROVIDER
activitiesInterval: 10000,
fastestInterval: 5000,
stopOnStillActivity: false, // deprecated
});
it seems like gplay services issue. make sure the device has them
installed and in recent version
On Mon, May 21, 2018, 15:28 Györög Norbert notifications@github.com wrote:
Your Environment
- Plugin version: ^0.5.0-alpha.27
- Platform: Android
- OS version: Oreo API 26
- Device manufacturer and model: Galaxy S8
- React Native version: 0.55.4
Actual Behavior
App crash.
Steps to ReproduceBackgroundGeolocation.configure(...) // see below
setTimeout(() => {
BackgroundGelolocation.start();
}, 5000);Crash when started (after 5 sec) :(
Tested on Redmi 4X, HTC M8 (Android 6.0) and Simulator (Nexus 5X API 24)
Debug logsFATAL EXCEPTION: main
Process: com.myapp, PID: 6392
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/location/DetectedActivity;
at com.marianhello.bgloc.provider.ActivityRecognitionLocationProvider.(ActivityRecognitionLocationProvider.java:40)
at com.marianhello.bgloc.provider.LocationProviderFactory.getInstance(LocationProviderFactory.java:40)
at com.marianhello.bgloc.LocationService.onStartCommand(LocationService.java:247)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3297)
at android.app.ActivityThread.-wrap21(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.ClassNotFoundException: com.google.android.gms.location.DetectedActivity
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzbgl;
... 12 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.internal.zzbgl" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-1/lib/x86, /data/app/com.myapp-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 12 morebuild.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// Google now hosts their latest API dependencies on their own maven server.
// React Native will eventually add this to their app template.
maven {
url "https://maven.google.com"
}
maven {
url "$rootDir/../node_modules/react-native-background-fetch/android/libs"
}
}
}ext {
compileSdkVersion = 26
targetSdkVersion = 26
buildToolsVersion = "27.0.3"
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "11.8.0"
oreoEXPERIMENTAL = "yes"
}app/build.gradle
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersiondefaultConfig { applicationId "hu.hatarinfo.react" minSdkVersion 16 targetSdkVersion rootProject.targetSdkVersion multiDexEnabled true versionCode 1 versionName "1.0" ndk { abiFilters "armeabi-v7a", "x86" } }. . . . .
}dependencies {
compile project(':react-native-onesignal')
compile project(':react-native-push-notification-ce')
compile project(':react-native-keep-awake')
compile project(':react-native-device-info')
compile project(':react-native-background-fetch')
compile project(':react-native-vector-icons')
compile project(':react-native-mauron85-background-geolocation')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:multidex:1.0.1"
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}BackgroundGeolocation.configure({
debug: true,
stopOnTerminate: false,
desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER,
// locationProvider: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER,// Android
interval: 10000,
startOnBoot: false,
notificationTitle: 'Background tracking',
notificationText: 'enabled',// iOS
// activityType: '',
pauseLocationUpdates: false,
saveBatteryOnBackground: false,// DISTANCE_FILTER_PROVIDER
distanceFilter: 8,
stationaryRadius: 25,// ACTIVITY_PROVIDER
activitiesInterval: 10000,
fastestInterval: 5000,
stopOnStillActivity: false, // deprecated});
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/mauron85/react-native-background-geolocation/issues/196,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAV8GmvtfFmzuzPQZTIqUml3flf7M5ZAks5t0sEXgaJpZM4UG_Vc
.
The current version on my phone is 12.6.85 (040408-197041431)
Did you change node_modules/react-native-mauron85-background-geolocation/android/lib/build.gradle to gms:play-services-locations and match the version used by those libraries?
https://github.com/mauron85/react-native-background-geolocation#compatibility
dependencies {
...
compile 'com.google.android.gms:play-services-location:9.8.0'
...
}
I solved it with this.
@Shagamii there is also better way. Just add to your root build.gradle
ext {
googlePlayServicesVersion = "9.8.0"
}
Advantage over editing it in node_modules is that it survive module update.
const options = {/* same as above */};
try {
BackgroundGeolocation.configure(options);
} catch (e) {
console.error(e);
Sentry.captureException(e);
}
BackgroundGeolocation.start();
ext {
compileSdkVersion = 26
targetSdkVersion = 24
buildToolsVersion = "27.0.3"
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "9.8.0"
// oreoEXPERIMENTAL = "yes"
}
// with oreoEXPERIMENTAL the build fails if play services version is 9.8.0
OR
ext {
compileSdkVersion = 26
targetSdkVersion = 24
buildToolsVersion = "27.0.3"
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "11.8.0" // or 12.0.1 or 15.0.0
oreoEXPERIMENTAL = "yes"
}
Same error always.
// console output
ClassNotFoundException: Didn't find class "com.google.android.gms.internal.zzbgl" on path: DexPathList[[zip file "/data/app/my-app-2/base.apk"],nativeLibraryDirectories=[/data/app/my-app-2/lib/x86, /data/app/my-app-2/base.apk!/lib/x86, /system/lib, /vendor/lib]]
// stack
java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.internal.zzbgl" on path: DexPathList[[zip file "/data/app/my-app-2/base.apk"],nativeLibraryDirectories=[/data/app/my-app-2/lib/x86, /data/app/my-app-2/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.marianhello.bgloc.provider.ActivityRecognitionLocationProvider.<init>(ActivityRecognitionLocationProvider.java:40)
at com.marianhello.bgloc.provider.LocationProviderFactory.getInstance(LocationProviderFactory.java:40)
at com.marianhello.bgloc.LocationService.onStartCommand(LocationService.java:249)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3297)
at android.app.ActivityThread.-wrap21(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzbgl;
at com.marianhello.bgloc.provider.ActivityRecognitionLocationProvider.<init>(ActivityRecognitionLocationProvider.java:40)
at com.marianhello.bgloc.provider.LocationProviderFactory.getInstance(LocationProviderFactory.java:40)
at com.marianhello.bgloc.LocationService.onStartCommand(LocationService.java:249)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3297)
at android.app.ActivityThread.-wrap21(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
java.lang.ClassNotFoundException: com.google.android.gms.location.DetectedActivity
at java.lang.VMClassLoader.findLoadedClass(VMClassLoader.java)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.marianhello.bgloc.provider.ActivityRecognitionLocationProvider.<init>(ActivityRecognitionLocationProvider.java:40)
at com.marianhello.bgloc.provider.LocationProviderFactory.getInstance(LocationProviderFactory.java:40)
at com.marianhello.bgloc.LocationService.onStartCommand(LocationService.java:249)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3297)
at android.app.ActivityThread.-wrap21(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/location/DetectedActivity;
at com.marianhello.bgloc.provider.ActivityRecognitionLocationProvider.<init>(ActivityRecognitionLocationProvider.java:40)
at com.marianhello.bgloc.provider.LocationProviderFactory.getInstance(LocationProviderFactory.java:40)
at com.marianhello.bgloc.LocationService.onStartCommand(LocationService.java:249)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3297)
at android.app.ActivityThread.-wrap21(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Ahh found! The error is not here, but I don't know where is.
If the react-native-onesignal or react-native-push-notification-ce plugins are installed, then the crash occurs when using ACTIVITY_PROVIDER.
If none of them is installed, then the plugin works as expected.
Now, please help me where is the conflict? :(
Another strange thing is that react-native-device-info also crashes if one of them is installed.
Found the solution.
The Firebase and Play Services versions were different. Firebase +, Play Services 11.8.0, setting both to same (11.8.0) version solved the problem.
And now the device-info plugin works too.
I was using this way.
implementation(project(':@mauron85_react-native-background-geolocation')) {
exclude group: 'com.google.android.gms', module: 'play-services-location'
}
It's work for me:
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "15.0.1" //<--------- version 15.0.1
}
Most helpful comment
It's work for me: