react-native-background-geolocation: INSTALL_FAILED_CONFLICTING_PROVIDER when installing on android
Your Environment
- Plugin version: 0.5.0-alpha.50
- Platform: Android
- OS version: 9 (Pie)
- Device manufacturer and model: Pixel 1
- Running in Simulator:
- React Native version: 0.57
- Plugin configuration options: N/A
- Link to your project: N/A
Context
My application was working previously (on alpha.40), but has since stopped installing onto my device. Failing with the following error:
> Task :react-native-mauron85-background-geolocation-common:installDebugAndroidTest Installing APK 'react-native-mauron85-background-geolocation-common-debug-androidTest.apk' on 'Pixel - 9' for react-native-mauron85-background-geolocation-common:debugAndroidTest Unable to install /home/yarrichar/git/ccc-ondemand-driver/node_modules/react-native-mauron85-background-geolocation/android/common/build/outputs/apk/androidTest/debug/react-native-mauron85-background-geolocation-common-debug-androidTest.apk com.android.ddmlib.InstallException: INSTALL_FAILED_CONFLICTING_PROVIDER: Package couldn't be installed in /data/app/com.marianhello.backgroundgeolocation.test-6_0HNOxBIjwCW9F94eEiKA==: Can't install because provider name com.swiftfare.fleet.mauron85.bgloc.provider (in package com.marianhello.backgroundgeolocation.test) is already used by com.marianhello.bgloc.react.test at com.android.ddmlib.Device.installRemotePackage(Device.java:1004) at com.android.ddmlib.Device.installPackage(Device.java:911) at com.android.builder.testing.ConnectedDevice.installPackage(ConnectedDevice.java:122) at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.java:172) at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.java:106) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
I have tried downgrading the alpha.40, but that fails with a different error:
> Task :react-native-mauron85-background-geolocation-common:processDebugAndroidTestManifest FAILED /home/yarrichar/git/ccc-ondemand-driver/node_modules/react-native-mauron85-background-geolocation/android/common/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger6665148362615969861.xml:5:5-74 Error: uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.intentfilter:android-permissions:0.1.6] /home/yarrichar/.gradle/caches/transforms-1/files-1.1/android-permissions-0.1.6.aar/cdd83aa9ae5f6c5aeabd535badab803d/AndroidManifest.xml as the library might be using APIs not available in 15 Suggestion: use a compatible library with a minSdk of at most 15, or increase this project's minSdk version to at least 16, or use tools:overrideLibrary="com.intentfilter.androidpermissions" to force usage (may lead to runtime failures)
The command I am using to try and run it on my device is: react-native run-android
Expected Behavior
It should install successfully onto my device
Actual Behavior
It fails with the above errors
Possible Fix
I’m not sure, but should it be trying to run code on a device during a normal build.
Steps to Reproduce
- Try and install an depending on react-native-background-geolocation on an android device
dependencies from package.json:
"dependencies": { "@mapbox/polyline": "^1.0.0", "axios": "^0.18.0", "hoist-non-react-statics": "^3.1.0", "moment": "^2.22.2", "moment-timezone": "^0.5.23", "native-base": "^2.7.2", "react": "16.4.1", "react-native": "0.57.0", "react-native-dropdownalert": "^3.5.0", "react-native-firebase": "4.3.8", "react-native-google-signin": "react-native-community/react-native-google-signin", "react-native-maps": "^0.21.0", "react-native-material-buttons": "^0.5.0", "react-native-mauron85-background-geolocation": "0.5.0-alpha.50", "react-native-permissions": "1.1.1", "react-native-size-matters": "^0.1.3", "react-native-sound": "^0.10.9", "react-native-vector-icons": "^5.0.0", "react-navigation": "^2.9.3", "react-redux": "^5.0.7", "redux": "^4.0.0", "redux-persist": "^5.10.0" }
ext section from android/build.gradle:
ext { buildToolsVersion = "27.0.3" minSdkVersion = 16 compileSdkVersion = 27 targetSdkVersion = 26 supportLibVersion = "27.1.1" googlePlayServicesVersion = "15.0.1" androidMapsUtilsVersion = "0.5+" gradle3EXPERIMENTAL = "yes" }
Let me know if any other config is relevant.
Context
I am not able to develop currently.
Debug logs
Relevant errors included above.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 25 (7 by maintainers)
You don’t need to modify anything in the library’s files to support different build variants, especially since such changes would get overwritten during any future updates.
The provider label is just a string, so you can update it in a couple ways:
In your app/build.gradle where you define the build variants:
Or if you have separate resource folders per variant, you can put this in the file app/src/VARIANT/res/values/strings.xml:
So for example, in app/src/beta/res/values/strings.xml:
Both approaches work for me, using 0.5.3 of this library, building under Android Studio 3.4.1 w/ gradle 5.4.1.
(edit: corrected gradle version)
I was able to resolve this issue by adding the following configuration in my gradle file:
where
fullApplicationIdentifier
is the concat of myapplicationId
and myapplicationIdSuffix
We find one way to do this:
Node_modules/@mauron85/android/common/build.gradle
`// ADD THIS ON TOP def getDate() { return new Date().format(‘yyyyMMddHHmmss’) }
//CHANGE THIS ALL defaultConfig { resValue “string”, resourcePrefix + “account_name”, ‘Locations’ resValue “string”, resourcePrefix + “account_type”, applicationId + getDate() + ‘.mauron85.bgloc.account’ resValue “string”, resourcePrefix + “content_authority”, applicationId + getDate() + ‘.mauron85.bgloc.provider’ testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner” minSdkVersion project.ext.getMinSdkVersion() versionCode 1 versionName “1.0” }`
You need to uninstall test package
On Mon, 7 Jan 2019 at 04:21, yarrichar notifications@github.com wrote:
– S pozdravom,
Marián Hello freelance programmer
About.me http://about.me/marian.hello | LinkedIn https://www.linkedin.com/in/marianhello/ | Twitter http://twitter.com/mauron85
In case of sensitive data, please consider using encryption using my public PGP key https://keybase.io/mauron85/key.asc.
Not fixed, afaik.
Fixed in version 0.6.0
Thanks @RodneyOnyi, this actually worked, could you explain me why though? I submitted a PR for this if you wanna take a look https://github.com/mauron85/background-geolocation-android/pull/33