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.
You need to uninstall test package
On Mon, 7 Jan 2019 at 04:21, yarrichar [email protected] wrote:
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.
— 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/344, or mute the thread https://github.com/notifications/unsubscribe-auth/AAV8Go3sISBVOsa8VZsEhYiLpYgH7DoDks5vAr00gaJpZM4ZyzBX .
-- 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.
Sorry, for being a bit slow, how do I do that? I just added it with:
yarn add react-native-mauron85-background-geolocation
I didn't explicitly add any test packages.
Have you run tests? Eg. From android studio?
Thanks for the reply. I haven't explicitly run any tests. This is happening when I try and run my code on my device with: react-native run-android
This had previously been working.
Try to uninstall com.marianhello.backgroundgeolocation.test and com.marianhello.bgloc.react.test.
with adb uninstall
I just tried, but it failed with the same error. This uninstalled: com.marianhello.bgloc.react.test This didn't exist: com.marianhello.backgroundgeolocation.test
There is something wrong with your setup:
Installing APK 'react-native-mauron85-background-geolocation-common-debug-androidTest.apk'
don't understand why library is installed as apk, but I guess this is your problem
Do you have any thoughts about what could cause that? Not sure where to start.
Thanks for your help on this.
Not sure. Can you post your gradle and manifest files?
We haven't worked out why it started breaking, but it appears to be to do with android build flavours.
Basically we have different build flavours for dev / prod / etc. Executing run-android by itself tries to install the debug version of all the flavours
Passing in the flavour using --flavor DevDebug or using gradle to build a specific one gets rid of the problem.
One thing I noticed though is that the provider name mentioned in the error: "com.swiftfare.fleet.mauron85.bgloc.provider" doesn't include the suffix specified as part of the flavour definition. E.g ".dev" below:
productFlavors {
dev {
dimension "env"
applicationIdSuffix ".dev"
Happy for this to be closed, if the above is correct
It makes sense. You can not have multiple content providers registered with same name, which is case if you're using flavors (and you do). Not sure if this can be handled by plugin. Please share your experience with adding applicationIdSuffix.
EDIT: can -> can not
I was able to resolve this issue by adding the following configuration in my gradle file:
resValue "string", "mauron85_bgloc_content_authority", "${fullApplicationIdentifier}.mauron85.bgloc.provider"
where fullApplicationIdentifier is the concat of my applicationId and my applicationIdSuffix
I was able to resolve this issue by adding the following configuration in my gradle file:
resValue "string", "mauron85_bgloc_content_authority", "${fullApplicationIdentifier}.mauron85.bgloc.provider"where
fullApplicationIdentifieris the concat of myapplicationIdand myapplicationIdSuffix
In which gradle file and which section? @BjornRombaut
@jl-ib check react-native-background-geolocation-common gradle, I had to change the folder name in the @mauron85_react-native-background-geolocation-common from provider to providers to get it to work
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
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" }`
Thanks @munduu, this works for me
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:
flavorDimensions "build"
productFlavors {
beta {
dimension "build"
applicationIdSuffix ".beta"
resValue "string", "mauron85_bgloc_content_authority", "com.marianhello.app.mauron85.bgloc.provider.beta"
}
}
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:
<string name="mauron85_bgloc_content_authority">com.marianhello.app.mauron85.bgloc.provider.beta</string>
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)
Thanks @munduu, this works for me too!!!
Fixed in version 0.6.0