Okay, so Google is telling us "Background location access not declared" and not letting us publish our app. We have no use for background location, so we're trying to elimiate it completely.
Of course my manifest doesn't have it:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="com.android.vending.BILLING" />
<uses-feature android:name="android.hardware.location.gps"/>
I've searched absolutely everywhere for anything that could be adding ACCESS_BACKGROUND_LOCATION to our app, and found nothing.
Using the silver searcher:
ag ACCESS_BACKGROUND_LOCATION .
I've exampined the blame report for a clue, and worked backwards on anything with the word 'background', to no avail:
android/app/build/intermediates/manifest_merge_blame_file/myAppRelease/manifest-merger-blame-myapp-release-report.txt
I did find some extra permissions though:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
But I don't see any red flags there..
I've tried the node remove option:
<manifest ...xmlns:tools="http://schemas.android.com/tools"...>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" tools:node="remove" />
But nothing.
I've also run aapt2
$ aapt2 d permissions android/app/build/outputs/apk/myapp/release/app-myapp-release.apk
package: com.myapp
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.ACCESS_COARSE_LOCATION'
uses-permission: name='android.permission.ACCESS_FINE_LOCATION'
uses-permission: name='android.permission.SYSTEM_ALERT_WINDOW'
uses-permission: name='com.android.vending.BILLING'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.WAKE_LOCK'
Which doesn't tell me much more..
I've also watched the whole youtube video google posted regarding background positions, read the official docs, and checked every stack overflow post on this - but they just recommend the steps I've already taken.
It's an exhausting process! I'm exhausted. My best guess is that one our dependencies is the problem, but I have no good clues as to which one it could be.
Would really appreciate some fresh eyes.. maybe someones encountered this with one of these packages below and is just going to be like, that's the one! Delete it!
Otherwise it's back to desperate searching and brute force rebuilds on minimal information..
"dependencies": {
"#mapbox/geo-viewport": "0.4.1",
"#mapbox/geojson-extent": "0.3.2",
"#mapbox/polyline": "1.1.1",
"#ptomasroos/react-native-multi-slider": "1.0.0",
"#react-native-community/async-storage": "1.12.0",
"#react-native-community/masked-view": "0.1.10",
"#react-native-community/netinfo": "4.7.0",
"#react-native-mapbox-gl/maps": "7.0.8",
"#sentry/react-native": "1.8.2",
"#turf/along": "^6.0.1",
"#turf/bearing": "^6.0.1",
"#turf/distance": "^6.0.1",
"#turf/helpers": "^6.1.4",
"#turf/line-distance": "^4.7.3",
"#turf/nearest": "^4.7.3",
"check-node-version": "4.0.3",
"deprecated-react-native-listview": "^0.0.6",
"eslint-plugin-react": "7.21.2",
"install": "^0.13.0",
"npm": "6.14.8",
"prop-types": "^15.6.0",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-billing": "^3.0.0",
"react-native-config": "^1.4.2",
"react-native-elements": "^1.2.7",
"react-native-gesture-handler": "1.8.0",
"react-native-in-app-utils": "6.1.0",
"react-native-linear-gradient": "^2.5.6",
"react-native-mixpanel": "1.2.5",
"react-native-rate": "1.0.9",
"react-native-safe-area-context": "^3.1.8",
"react-native-screens": "2.8.0",
"react-native-splash-screen": "3.2.0",
"react-native-sqlite-2": "1.7.0",
"react-native-vector-icons": "^6.6.0",
"react-native-webview": "10.9.3",
"react-navigation": "4.0.10",
"react-navigation-stack": "2.0.16",
"url": "^0.11.0",
"util": "0.12.3",
"which-polygon": "2.2.0"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
"eslint": "^6.8.0",
"eslint-plugin-import": "2.22.1",
"fs-extra": "^8.1.0",
"jetifier": "1.6.6",
"metro-react-native-babel-preset": "^0.58.0",
"minimatch": "^3.0.4",
"node-watch": "0.6.4",
"rimraf": "2.7.1"
}
Hopefully the right eyes sees this, or can point to something.. Thanks!
Update, got some more details from google:
Since your app does not need background location, please request to
remove background usage and reach compliance:
If you are targeting Android 10 or newer (SDK level 29 or higher):
Remove the ACCESS_BACKGROUND_LOCATION permission from your app APK or
app bundle. If you’re using ACCESS_COARSE_LOCATION or
ACCESS_FINE_LOCATION, examine your code paths and restrict usage to
foreground purposes only. (learn more:
https://developer.android.com/training/location/background) You should
no longer see the Location declaration listed in console under App
Content. If your are targeting Android 9 or older (SDK level 28 or
lower): If you’re already using ACCESS_COARSE_LOCATION or
ACCESS_FINE_LOCATION, examine your code paths and restrict usage to
foreground purposes only. (learn more:
https://developer.android.com/training/location/background) In your
console declaration, select “No” to the question “Does your app access
location in the background in APKs or app bundles targeting Android 9
or older?
I fixed this not by removing "ACCESS_BACKGROUND_LOCATION" from .js like grep -r "ACCESS_BACKGROUND_LOCATION" . | cut -c1-150 did, but by just removing "ACCESS_BACKGROUND_LOCATION" from .java like:
sed -i -e "s/.*ACCESS_BACKGROUND_LOCATION.*/return true;/g" node_modules/expo-location/android/src/main/java/expo/modules/location/LocationModule.java
Time will tell if this is an actual fix, but I figured I'd share it with other struggling devs.
Google approved both of our apps! 1 of our apps they approved because we just crumbled and told them we use background location, even though we don't. Not a satisfying answer!
The other app, I just cleared the build folder and resubmitted and they accepted it. So this points at the cache of the last uploader as the potential source of the problem. Though I am half expecting Google to take down the app in 2 weeks, we'll see.
Here's all my notes on clearing cache for devs who find themselves unsure if the cache is the root of the problem:
Clear cache inside project
rm android/build
rm ios/build
rm -rf android/.gradle
./gradlew clean
Clear cache inside computer
rm -rf ~/.gradle/caches
Other ios caches (For when you're really desperate)
~/Library/Caches/CocoaPods
~/Library/Developer/Xcode/DerivedData/*
~/Library/Developer/Xcode/Archives/*
Which of course brings to mind the old adage:
When in doubt – it's probably a caching issue.
I had this issue a few weeks ago, what a pain! In my case I had one dependency that was requiring background location without me noticing. Secondly, I had a wrong permission declaration on Google Play so my builds kept being rejected.
1. Find the evil dependency
To do this I used the Merged Manifest inspector in Android Studio. This shows you what your manifest looks like after all project dependencies have been taken into account. Find ACCESS_BACKGROUND_LOCATION and double click on it, this will bring you to the actual manifest where it's requested. Scroll to the top of this file and the package=some.package.name should help you identify what it is. In my case the permission was requested by an old dependency I didn't use anymore so I just uninstalled it.
Note: if you're often working on different branches, make sure you have the correct dependencies installed and make a clean build before checking the merged manifest:
cd android && yarn && ./gradlew clean && yarn android
2. Check Google Play declaration (optional)
Go to the Google Play Console. You can be sure the background location permission is removed from you app bundle by looking at the "Required permissions" in the App Bundle details. Then If you previously filled a background location permission declaration, make sure to review it and select No (your app may be removed from Google Play if it accesses location in the background). After that you should be good and you app should be approved promptly.
✌️
Note*
: Without filling delectation you can't upload your build so please first fill the declaration form on the play console and mention you are taking any background location access.
I have faced a similar kind in my release also, In the current build, I was not using any background location access. but In my previous build which was live in internal test on play console was using background location access. So due to that play console was halting me to upload any build for release before the declaration.
Hence I have to solve the same problem with these steps.
1)Made a declaration app small video and mentioned that we are not using and background location access and posted it in the declaration form.
2)After this step I was able to publish so I have first uploaded my latest build to internal testing and released that.
after a successful internal test release I published it to production.
As well as check alpha, beta test branch also on play console makes sure none of the previous app lives in these branches.
try looking for the permissions with the following command
grep -r ACCESS_BACKGROUND_LOCATION android/*
grep -r ACCESS_COARSE_LOCATION android/*
etc ..
After that, if you already generated the app with bundleRelease, you will notice that the permissions are shown in the build folder.
just look for where the permissions are and see in that same file below which component uses it.
in my case it was the radar.io library.
Since you detect what library it is, it may be due to a component of react or some library that has to be removed from the gradle.
Update 5.21.2021: Welp, we just received a note from google that our apps have been taken down. So the solution below does not work, we just got caught up in the confusion and thought it was working.
Alright! We had a guy who fixed this. Here's how it was done.
Manually delete ACCESS_BACKGROUND_LOCATION from any file anywhere in the react-native project, including node_modules, and bundles generated. Yeah I know, this sounds like a really silly thing, since they will come back next time you install, but we only have to get it approved once to get things working again.
Here's a command that'll work for that:
grep -r "ACCESS_BACKGROUND_LOCATION" . | cut -c1-150
You'll find files like these:
android/app/src/main/assets/index.android.bundle
node_modules/react-native/Libraries/PermissionsAndroid/PermissionsAndroid.js
node_modules/react-native/Libraries/PermissionsAndroid/NativePermissionsAndroid.js
Go through and delete "ACCESS_BACKGROUND_LOCATION"
Then reupload the apk, and clear out any non-production tracks with the uploaded file, because they may have "ACCESS_BACKGROUND_LOCATION" in them.
After this, Google approved it..
The app never used background location, but at some point, someone may have indicated that it did use background location when uploading - Google remembered this, and that's why it took extra steps to get it approved I guess?
Not a very satisfying answer! Very hacky and uncertain.. Yet that's what worked for us. Now I will hope it never happens again.
I am new to programming generally please I need some help!
My app was installing successfully after every update until i decided to add the 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha' library to the app because i need the user to be able to view some data in form of statistical charts.
The library was synced successfully and have used packages and classes therein successful. But when i try to install the app in my android device it returned this error:
Installation failed with message Failed to commit install session 590492354 with command cmd package
install-commit 590492354. Error: INSTALL_FAILED_MISSING_SHARED_LIBRARY: Package couldn't be installed in
/data/app/com.cenitscitech.www.etimebook-jOP-jv2YuNu7_8qnkfqp-A==: Package com.cenitscitech.www.etimebook requires unavailable shared library com.google.android.things; failing!.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing." I have pasted a screenshot here:
I uninstalled the existing version of the apk, cleared some memory space but keep on getting the same message! What should I do next please?
You are most likely installing on a device that is not an Android Things device. I suspect the library you added either has some transitive dependency on com.google.android.things, or something else changed in your project.
To get around this, you must do the following 2 things:
1. Mark that Android Things is not required on the device in your AndroidManifest.xml file:
<uses-library
android:name="com.google.android.things"
android:required="false"
tools:replace="android:required" />
(tools:replace is not strictly required, but it just there in case something in the manifest merge process overrides your setting.)
2. In your app's code, before making any calls to the Things APIs, make sure that they are available on the current device. This can be tested with the following code snippet:
public boolean isThingsDevice(Context context) {
final PackageManager pm = context.getPackageManager();
return pm.hasSystemFeature(PackageManager.FEATURE_EMBEDDED);
}
Only doing 1 should fix the install problem, but your app will crash if you make any Things API calls on a device that isn't an Android Things device.
Had a look in the com.github.PhilJay:MPAndroidChart:v3.1.0-alpha repository and did not find any reference to com.google.android.things inside the source code.
You need to remove the below entry in case it's found in the AndroidManifest.xml of your app for it to work on your device again:
<uses-library android:name="com.google.android.things" />
My App was removed by google because of presence of SMS and Call Permission in manifest. Now I have removed both the permission then also I'm not able to upload the apk .play store asking for the Permissions Declaration Form
Most likely some library you're using is adding the permissions. You can remove them during merge by adding the following to your AndroidManifest.xml:
<uses-permission android:name=”android.permission.RECEIVE_SMS” tools:node=”remove” />
<uses-permission android:name=”android.permission.SEND_SMS” tools:node=”remove” />
<uses-permission android:name=”android.permission.WRITE_SMS” tools:node=”remove” />
<uses-permission android:name=”android.permission.READ_SMS” tools:node=”remove” />
See this SO question for additional information.
You have to release a build with those permissions and fill the form (form will appear automatically on release page), then after that, you have to upload a build without those permissions.
I got the same problem recently and i have to removed those permissions and later my app got published. Please type all your permission you using in your app?
Remove SMS and CALL-Log permission from manifest file and Build new APK upload in Internal Test Track and deactivate previously released APK in internal Test track and roll out, Then release same APK in Alpha and Beta, Then Previously Declared Permissions will be automatically removed and release app to production and roll out
I run ./gradlew connectedAndroidTest and I need my test APK to have a permission which should not be in any non-testing APK (debug, release). I have created a manifest with permission:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypackage">
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE"/>
</manifest>
Then I have copied this manifest to src/androidTest directory, as release notes from gradle android plugin suggest:
0.13.0 (2014/09/18)
Requires Gradle 2.1
It is now possible to provide a manifest for test apps (src/androidTest/AndroidManifest.xml)
However, the permission is not applied during my connected tests.
If I create a src/debug directory and move this manifest there -- the permission is applied correctly during connected tests (but also during regular debug builds, which is undesirable).
Am I doing something wrong or is there a bug?
The problem stems from my misunderstanding of how connectedAndroidTest gradle task works. It creates and deploys 2 android applications - a testable (your project) and a tester (an app which simulates a user who interacts with the testable app). My intent was to add the permission to the testable app. However, adding a manifest to src/androidTest resulted in adding the permission to the tester app. Here's how I figured that out:
If I execute
adb shell pm list packages -f -3
(-3 means to list only third-party packages) I can see something like this
package:/data/app/SmokeTestApp.apk=com.android.smoketest
package:/data/app/GestureBuilder.apk=com.android.gesture.builder
package:/data/app/com.mycompany.myapp-2.apk=com.mycompany.myapp
package:/data/app/SoftKeyboard.apk=com.example.android.softkeyboard
package:/data/app/org.libsdl.app-2.apk=org.libsdl.app
package:/data/app/SmokeTest.apk=com.android.smoketest.tests
package:/data/app/com.mycompany.myapp.test-1.apk=com.mycompany.myapp.test
The app with test-1 suffix is the tester app, another one is my testable app. Checking their permission gives:
root#generic_x86:/ # aapt d permissions /data/app/com.mycompany.myapp-2.apk
package: com.spredfast.android
uses-permission: android.permission.INTERNET
uses-permission: android.permission.WRITE_EXTERNAL_STORAGE
root#generic_x86:/ # aapt d permissions /data/app/com.mycompany.myapp.test-1.apk
package: com.spredfast.android
uses-permission: android.permission.SET_ANIMATION_SCALE
So the permission, SET_ANIMATION_SCALE, which I was intending to put into my testable app is put into the tester app. No wonder that moving the manifest from src/androidTest to src/debug would put the permission into the testable app (correct, but too broad).
Here's how I solved the original problem - putting the permission into the application only in case of the application being run inside connectedAndroidTest task.
I have created an empty build flavor to be used with integration tests:
productFlavors {
/**
* This flavor is to be run only using connectedAndroidTestAnimcontrol
*/
animcontrol {}
regular {}
}
Moved src/androidTest/AndroidManifest.xml with the single permission into src/animcontrol/AndroidManifest.xml
Executed connected tests as
./gradlew connectedAnimcontrolDebugAndroidTest
That did the trick, now I have AndroidManifest.xml which will be merged with main app's manifest only when being run as connectedAndroidTest.
Hope this helps someone.
I try to add a permission on the corodva build apk file to enable in-app products. I tried to add permission from the project tap -- permission. But each time I upload the apk I can't find the billing permission on the uploaded apk.
I always get that
Required permissions 8 permissions
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_WIFI_STATE
android.permission.CAMERA
android.permission.FLASHLIGHT
android.permission.INTERNET
android.permission.READ_PHONE_STATE
android.permission.SEND_SMS
android.permission.VIBRATE
I add the permission
BILLING
and/or
com.android.vending.BILLING
but with no result.
One more thing is that when I open the intelxdk.config.android.xml I found this line
<preference name="android - permission" value="BILLING"/>
please note that there is a space in the "android - permission"
and I can't change that as this file are auto formatted when I build for android.
Many thanks in advance
Try this:
<preference name="android-permission" value="Billing> />
Note that your name contains spaces but the documentation doesnot.