transistorsoft / react-native-background-fetch

Periodic callbacks in the background for both IOS and Android
MIT License
1.43k stars 191 forks source link

error when running the app on Android #468

Closed kabitacode closed 7 months ago

kabitacode commented 7 months ago

Your Environment

Expected Behavior

Hi, Thank you for creating this amazing package, but when I run it there is an error as seen in this picture.

Context

in android/build.gradle buildscript { ext { buildToolsVersion = "30.0.2" minSdkVersion = 21 compileSdkVersion = 33 targetSdkVersion = 33 googlePlayServicesVersion = "+" ndkVersion = "21.4.7075529" kotlinVersion = '1.5.20' firebaseIidVersion = "19.0.1" // default: "19.0.1"

        supportLibVersion = '1.0.2' // Use '28.0.0' or don't specify for old libraries, '1.0.2' or similar for AndroidX
        mediaCompatVersion = '1.0.1' // Do not specify if using old libraries, specify '1.0.1' or similar for androidx.media:media dependency
        supportV4Version = '1.0.0' // Do not specify if using old libraries, specify '1.0.0' or similar for androidx.legacy:legacy-support-v4 dependency

    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        // classpath("com.android.tools.build:gradle:3.5.2")
        // classpath("com.android.tools.build:gradle:4.2.2")
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath 'com.google.gms:google-services:4.3.12'
        // classpath "com.google.gms:google-services:4.3.3"
        // 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 {
        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 {
       // react-native-background-fetch
      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()
        maven { url 'https://www.jitpack.io' }
    }
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.66, as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }
}

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 28
                buildToolsVersion "28.0.3"
            }
        }
    }
}

Debug logs

Screenshot 2023-10-11 at 10 23 34
christocracy commented 7 months ago

Your error has nothing to do with the plug-in. Your error message seems quite clear about what you need to do. Have you actually read it?

kabitacode commented 7 months ago

Hi @christocracy , thank you for replying, yes I have read it correctly, I tried adding this in android/build.gradle but it still gives an error

maven {
        // react-native-background-fetch
       url("${project(':react-native-background-fetch').projectDir}/libs")
     }
christocracy commented 7 months ago

If I were you, I'd be having a look at my compileSdkVersion, targetSdkVersion in my app/build.gradle

kabitacode commented 7 months ago

in my app/build.gradle, I tried changing it to 33 but it's still the same

defaultConfig {
        applicationId "com.example"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 41
        versionName "1.1.1"
        multiDexEnabled true
    }
christocracy commented 7 months ago

Well, your app thinks otherwise, so keep digging.

kabitacode commented 7 months ago

Hi, thank you for helping me, apparently this was my error in android/build.gradle I tried deleting this and it worked

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 28
                buildToolsVersion "28.0.3"
            }
        }
    }
}
christocracy commented 7 months ago

close your issues when complete