react-native-geolocation-service
react-native-geolocation-service copied to clipboard
App crashes on Geolocation.getCurrentPosition
Environment
System: OS: macOS 12.3.1 CPU: (4) x64 Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz Memory: 37.18 MB / 8.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node Yarn: 1.22.17 - ~/.nvm/versions/node/v14.15.0/bin/yarn npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm Watchman: 2022.03.21.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild Languages: Java: 18.0.1.1 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.68.2 => 0.68.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Platforms
Android
Versions
Please add the used versions/branches
- Android: 8.0.0
- react-native-geolocation-service: 5.3.0
- react-native: 0.68.2
- react: 17.0.2
Description
App crashes with following error when using Geolocation.getCurrentPosition
Fatal Exception: java.lang.IncompatibleClassChangeError: The method 'boolean java.lang.Object.equals(java.lang.Object)' was expected to be of type interface but instead was found to be of type virtual (declaration of 'com.agontuk.RNFusedLocation.RNFusedLocationModule' appears in /data/app/com.reactnativetest.app-jl6dj0enDjbJo7SYL6L_mA==/base.apk:classes2.dex) at com.agontuk.RNFusedLocation.RNFusedLocationModule.onLocationChange(RNFusedLocationModule.java:69) at com.agontuk.RNFusedLocation.FusedLocationProvider$4.onSuccess(FusedLocationProvider.java:105) at com.agontuk.RNFusedLocation.FusedLocationProvider$4.onSuccess(FusedLocationProvider.java:98) at com.google.android.gms.tasks.zzm.run(com.google.android.gms:play-services-tasks@@18.0.1:1) at android.os.Handler.handleCallback(Handler.java:808) at android.os.Handler.dispatchMessage(Handler.java:101) at android.os.Looper.loop(Looper.java:166) at android.app.ActivityThread.main(ActivityThread.java:7529) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Interesting, commenting in case I see it too.
I reproduce the crash with API level 26 (Android 8.0); no crash with API level 27 (Android 8.1)
Share your build.gradle info (min/target/compile/build sdk versions)
buildscript { ext { buildToolsVersion = "31.0.0" minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 31
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.1.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
You're using java 18, that's probably causing the issue. RN recommends to use jdk 11
@Agontuk , But Im using jdk11 also face this issue on real android device ,but work fine on ndroid emulator
my build gradle: buildToolsVersion = "31.0.0" minSdkVersion = 23 compileSdkVersion = 32 targetSdkVersion = 32 playServicesLocationVersion = "17.0.0"
https://github.com/Agontuk/react-native-geolocation-service/issues/367#issuecomment-1238151760
Hi bro, did u find any solution to fix this already?
Nope ,it just in debug mode .I think maybe is other package conflict it .But I had no idea which package make this conflict .Any one knows? Below is all the dependencies in my project
"dependencies": { "@apollo/client": "^3.6.9", "@firebase/app": "^0.7.33", "@firebase/messaging": "^0.9.16", "@graphql-codegen/cli": "^2.11.6", "@graphql-codegen/typescript": "^2.7.3", "@graphql-codegen/typescript-operations": "^2.5.3", "@notifee/react-native": "^5.7.0", "@react-native-async-storage/async-storage": "^1.17.7", "@react-native-community/checkbox": "^0.5.12", "@react-native-community/geolocation": "^3.0.1", "@react-native-community/hooks": "^2.8.1", "@react-native-community/segmented-control": "^2.2.2", "@react-native-firebase/app": "^15.6.0", "@react-native-firebase/messaging": "^15.6.0", "@react-navigation/bottom-tabs": "^6.3.1", "@react-navigation/native": "^6.0.10", "@react-navigation/native-stack": "^6.6.2", "@react-navigation/stack": "^6.2.1", "@reduxjs/toolkit": "^1.8.2", "@types/react-native-background-timer": "^2.0.0", "apollo-upload-client": "^17.0.0", "axios": "^0.27.2", "dayjs": "^1.11.5", "deprecated-react-native-prop-types": "^2.3.0", "firebase": "^9.10.0", "formik": "^2.2.9", "graphql": "^16.5.0", "jwt-decode": "^3.1.2", "lodash": "^4.17.21", "moment": "^2.29.3", "native-base": "3.3.7", "numeral": "^2.0.6", "patch-package": "^6.4.7", "postinstall-postinstall": "^2.1.0", "query-string": "^7.1.1", "react": "18.0.0", "react-native": "0.69.0", "react-native-background-timer": "^2.4.1", "react-native-blob-util": "^0.16.2", "react-native-bootsplash": "^4.3.2", "react-native-calendar-picker": "^7.1.2", "react-native-calendars": "^1.1286.0", "react-native-checkbox-animated": "^0.0.10", "react-native-collapsible-segmented-view": "^1.2.1", "react-native-confirmation-code-field": "^7.3.0", "react-native-create-thumbnail": "^1.6.3", "react-native-date-picker": "^4.2.3", "react-native-document-picker": "^8.1.1", "react-native-dotenv": "^3.3.1", "react-native-fast-image": "^8.5.11", "react-native-floating-label-input": "1.3.4", "react-native-geolocation-service": "^5.3.1", "react-native-gifted-charts": "^1.2.41", "react-native-image-crop-picker": "^0.37.3", "react-native-image-picker": "^4.10.0", "react-native-linear-gradient": "^2.6.2", "react-native-mime-types": "^2.3.0", "react-native-modal": "^13.0.1", "react-native-pager-view": "^5.4.24", "react-native-pdf": "^6.6.2", "react-native-progress": "^5.0.0", "react-native-reanimated": "1.13.4", "react-native-safe-area-context": "^4.3.1", "react-native-screens": "^3.13.1", "react-native-scrollable-tab-view": "^1.0.0", "react-native-svg": "^12.4.3", "react-native-svg-transformer": "^1.0.0", "react-native-switch": "^1.5.1", "react-native-text-input-mask": "^3.1.4", "react-native-vector-icons": "^9.2.0", "react-native-video": "^5.2.1", "react-native-video-player": "^0.14.0", "react-redux": "^8.0.2", "redux": "^4.2.0", "rn-swipe-button": "^1.3.8" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@graphql-codegen/cli": "2.11.6", "@graphql-codegen/typescript": "2.7.3", "@graphql-codegen/typescript-operations": "2.5.3", "@graphql-codegen/typescript-react-apollo": "3.3.3", "@react-native-community/eslint-config": "^2.0.0", "@types/jest": "^26.0.23", "@types/react-native": "^0.69.0", "@types/react-native-calendar-picker": "^7.0.2", "@types/react-native-scrollable-tab-view": "^0.10.3", "@types/react-test-renderer": "^18.0.0", "@typescript-eslint/eslint-plugin": "^5.29.0", "@typescript-eslint/parser": "^5.29.0", "babel-jest": "^26.6.3", "babel-plugin-module-resolver": "^4.1.0", "eslint": "^7.32.0", "eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-prettier": "^8.5.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.70.3", "react-test-renderer": "18.0.0", "typescript": "^4.4.4" },
https://github.com/Agontuk/react-native-geolocation-service/issues/367#issuecomment-1266983186 I had no idea since it just make the app crash and didnt return any error or warning
happening same for me gives below error
{"code": -1, "message": "Internal error occurred"}
it resolved for me by adding apply plugin: 'com.google.gms.google-services'
on top of android/app/build.gradle
file.
add it, sync the project and run
@codemeall the plugin didn't solve it for me. Experiencing the issue on a Nexus 5X (Android 6.0.1 - API Level 23) in production. The crash happens when the user authorizes geolocation - which subsequently triggers getCurrentPosition
Fatal Exception: java.lang.IncompatibleClassChangeError The method 'boolean java.lang.Object.equals(java.lang.Object)' was expected to be of type interface but instead was found to be of type virtual (declaration of 'com.agontuk.RNFusedLocation.RNFusedLocationModule' appears in /data/app/com.theApp/base.apk)
@Agontuk @virajverlekar-tm did you guys find any solution for this ?
@Agontuk @virajverlekar-tm @EdenMay Found any solution for this?
I am using latest version required for another dependancy in project
implementation 'com.google.android.gms:play-services-location:21.0.1'
// react-native-geolocation-service using different version internally, using 18.0.0
implementation (project(path: ':react-native-geolocation-service')) {
exclude group: 'com.google.android.gms', module: 'play-services-location'
}
The release notes for 21.0.0 https://developers.google.com/android/guides/releases#october_13_2022 mention
FusedLocationProviderClient, ActivityRecognitionClient, GeofencingClient and SettingsClient are now
interfaces instead of classes, which helps enforce correct usage and improves testability.
This seems to relate to the error message.