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

Application crashed due to BackgroundGeolocation.ready #2143

Closed PrasadFeker closed 3 weeks ago

PrasadFeker commented 2 months ago

Your Environment

const LOCATIONURL = Config.LOCATION_URL;

const TransistorSoftBackgroundLocation = async (driverData) => { BackgroundGeolocation.ready({ desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH, distanceFilter: 0, stopOnTerminate: false, startOnBoot: true, enableHeadless: true, // debug: true, fastestLocationUpdateInterval: 5000, foregroundService: true, }).then((state) => { console.log('MYSTATE==>', JSON.stringify(state)); console.log('================================================'); if (!state.enabled) { console.log('MyStateEnable', state.enabled); //BackgroundGeolocation.start(); } });

// This handler fires whenever bgGeo receives a location update. BackgroundGeolocation.onLocation( (location) => { postLocationsToServer( location.coords.latitude, location.coords.longitude, driverData, );

  //  console.log('[location] ', location);
},
(error) => {
  console.log('[location] ERROR: ', error);
},

);

// This handler fires when movement states changes (stationary->moving; moving->stationary) BackgroundGeolocation.onMotionChange((location) => {});

// This handler fires on HTTP responses BackgroundGeolocation.onHttp((response) => { console.log('[http] ', response); });

// This event fires when a change in motion activity is detected BackgroundGeolocation.onActivityChange((activityEvent) => { console.log('[activitychange] ', activityEvent); });

// This event fires when the user toggles location-services authorization BackgroundGeolocation.onProviderChange((providerEvent) => { console.log('[providerchange] ', JSON.stringify(providerEvent)); }); };


## Expected Behavior
<!--- Tell us what should happen -->
It should be worked properly without app crash
## Actual Behavior
<!--- Tell us what happens instead -->
App getting crashed with out showing any error
## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1. I just invoked the TransistorSoftBackgroundLocation function
2. App getting crashed

## Context
<!--- What were you trying to do? -->

## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog #emailLog methods (@see docs)
- Android: $ adb logcat -s TSLocationManager
-->
<details><summary>[providerchange]  {"accuracyAuthorization":0,"gps":true,"status":3,"enabled":true,"network":false}
</summary>

``` <!-- Syntax highlighting:  DO NOT REMOVE -->
PASTE_YOUR_LOGS_HERE

PrasadFeker commented 2 months ago

`apply plugin: "com.android.application" apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

project.ext.envConfigFiles = [ envQa: ".env.qa", envProd: ".env.prod", ]

apply from: project(":react-native-config").projectDir.getPath() + "/dotenv.gradle"

import com.android.build.OutputFile

/**

project.ext.react = [ entryFile: "index.js", enableHermes: false, // clean and rebuild if changing ]

// apply from: "../../node_modules/react-native/react.gradle"

/**

/**

/**

/**

android { ndkVersion rootProject.ext.ndkVersion compileSdkVersion rootProject.ext.compileSdkVersion lintOptions { checkReleaseBuilds false } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }

defaultConfig {
    applicationId "com.tinting"
    // missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    vectorDrawables.useSupportLibrary = true
    versionCode 58
    versionName "4.2.2"
    multiDexEnabled true
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
signingConfigs {
    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
        }
    }
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://facebook.github.io/react-native/docs/signed-apk-android.
        signingConfig signingConfigs.release
        // signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

 flavorDimensions "default"
     productFlavors {
            envProd {
                 resValue "string", "build_config_package", "com.tinting"
             }
             envQa {
                 resValue "string", "build_config_package", "com.tinting"
             }
         }
// 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
        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 =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }

    }
}

} dependencies { // compile 'com.google.android.gms:play-services:16.0.1' // compile project(':reactnativenotifications') // compile project(':react-native-otp-verify') // compile project(':react-native-otp-verify') implementation fileTree(dir: "libs", include: ["*.jar"]) // implementation project(':@mauron85_react-native-background-geolocation') implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' implementation project(':react-native-permissions') implementation project(':react-native-localize') implementation "com.facebook.react:react-native:+" implementation "com.google.android.gms:play-services-auth:16.0.1" // implementation 'com.google.android.gms:play-services-base:10.0.1' implementation "com.google.android.gms:play-services-base:+" implementation ("androidx.appcompat:appcompat:1.3.1") { version { strictly '1.3.1' } } implementation ('com.google.android.material:material:1.6.0'){ version { strictly '1.6.0' } }

// implementation 'com.google.android.gms:play-services-base:10.0.1'
// implementation project(':reactnativenotifications');
// implementation 'com.google.firebase:firebase-analytics'
// implementation fileTree(dir: "libs", include: ["*.jar"])
// implementation 'com.google.android.gms:play-services-auth:+'
// implementation 'com.google.firebase:firebase-core:16.0.7';
// implementation "com.google.android.gms:play-services-gcm:+"
// implementation platform('com.google.firebase:firebase-bom:26.0.0')
// implementation 'com.google.android.gms:play-services-base:16.0.1'
// compile ("com.google.android.gms:play-services-auth:16.1.0") {
//     force = true;
// }
// implementation(project(":react-native-google-signin"))
// compile 'com.android.support:multidex:1.0.1'
    // Import the BoM for the Firebase platform
// Declare the dependencies for the Firebase Cloud Messaging and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies

if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}

}

// Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' }

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

apply plugin: 'com.google.gms.google-services' apply plugin: "kotlin-android" apply plugin: "kotlin-android-extensions" Project background_geolocation = project(':react-native-background-geolocation') apply from: "${background_geolocation.projectDir}/app.gradle" `

PrasadFeker commented 2 months ago

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

// apply plugin: 'com.google.gms.google-services' // apply plugin: 'com.android.application'

buildscript {

ext {
   googlePlayServicesLocationVersion = "17.0.0"  // Or higher.

    buildToolsVersion = "30.0.2"
    minSdkVersion = 23
    compileSdkVersion = 33
    targetSdkVersion = 33
    supportLibVersion = "30.0.0"
    googlePlayServicesAuthVersion = "16.0.1"
    googlePlayServicesVersion = "17.0.0" // default: "+"
    gradle3EXPERIMENTAL="yes"
    kotlin_version = '1.4.10'
    // gradle_version = '4.1.0'
    appCompatVersion = "1.4.2"
      // Or higher.  Required for new AndroidX compatibility.
       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()
    jcenter()

    mavenCentral()
    maven { url "https://dl.bintray.com/android/android-tools" }
}
dependencies {
    classpath('com.android.tools.build:gradle:4.0.1')
    classpath 'com.google.gms:google-services:4.3.4'
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
    classpath 'com.google.android.gms:play-services-auth:16.0.1'
    // classpath 'com.android.tools.build:gradle:3.0.1'
    // classpath 'com.google.gms:google-services:4.1.0'
    // classpath 'com.google.gms:google-services:16.1.0'
    // classpath("com.google.gms:google-services:+")
    // classpath("com.google.android.gms:google-services-auth:16.1.0")

    // classpath 'com.google.gms:google-services:4.3.4'

    // classpath 'com.google.gms:google-services:4.1.0'
    // classpath 'com.android.tools.build:gradle:3.1.2' // <--- use this version or newer
    // classpath 'com.google.gms:google-services:4.3.4'
    // classpath 'com.google.gms:google-services:4.3.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 { repositories { google() mavenLocal() jcenter() mavenCentral()

    maven { url 'https://maven.zohodl.com' }

    // maven { url "https://maven.google.com" }

    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 'https://maven.google.com'
    // }

    maven { url "https://www.jitpack.io" }

    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")
  }

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

//   maven { url 'https://maven.google.com' }
    // google()
    // maven { url 'https://jitpack.io' }
}

configurations.all {
    resolutionStrategy {
        // Remove this override in 0.65+, as a proper fix is included in react-native itself.
        force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        force 'androidx.core:core-ktx:1.8.0'
        force 'androidx.core:core:1.9.0'
    }
}

} `

christocracy commented 2 months ago

When there’s a crash, the first thing you do (before posting an issue) is fetch the stacktrace from $ adb logcat. There is always a stacktrace, showing what what wrong and where.

christocracy commented 2 months ago

Plugin version:

You failed to provide the version of the plugin you're using.

ext {
   googlePlayServicesLocationVersion = "17.0.0"  // Or higher.

Why would you use v17 from 2019? The latest version is 21.3.0 https://maven.google.com/web/index.html?q=location#com.google.android.gms:play-services-location

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 3 weeks ago

This issue was closed because it has been inactive for 14 days since being marked as stale.