How to remove "android.hardware.location" permission request from ejected Expo project? - react-native

I have an React Native Expo project that started out using the Expo "managed workflow". However, since then I have ejected out of the managed workflow (while still using some expo modules).
The issue I'm experiencing is that Expo seems to have added arbitrary permission requests to my Android app.
I must remove this particular permission request from the app: android.hardware.location.
I've tried many ways to remove it in my AndroidManifest.xml file, for example:
<uses-permission tools:node="remove" android:name="LOCATION_HARDWARE" />
<uses-permission tools:node="remove" android:name="ACCESS_COARSE_LOCATION" />
<uses-permission tools:node="remove" android:name="ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location" android:required="false" tools:node="remove" />
But in the end the bundled Android app still requests the android.hardware.location permission.
How can I remove it before bundling the app?

for excluding any permission that expo is adding automatically, according to the expo documentation you should just add tools:node="remove" to your manifest permission element. now if you want to remove location permission this should solve your issue:
<manifest ... xmlns:tools="http://schemas.android.com/tools">
...
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" tools:node="remove" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" tools:node="remove" />
...
</manifest>
By adding these, hardware location permission should be gone too.
don't forget to add tools namespace to the root element of your manifest

This issue was resolved by removing the expo dependency from package.json.
The expo dependency required expo-location which in turn requested various android location permissions.

Related

React Native Android only crash on real device while using react-native-map

React Native Android crash only on real device while using react-native-map, but it works on simulator. App crash after loading the MapView, I've try to add <uses-library android:name="org.apache.http.legacy" android:required="false"/> into AndroidManifest.xml <application> tag
My device is M1 Mac and my phone is Android 6.0.1 Samsung galaxy S9
Permissions in AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
I'm sure that the application has access to location.Please tell me if I miss any settings.

Play store console detects android.permission.READ_PHONE_STATE requirement for a Vanilla React Native app

I created a react native app using react-native init. Did not change a single line of code. (Note: react-native version is 0.55.4)
I generated a singed release APK by following steps given in the official docs.
I tried to upload this APK to Google Play console.
I got the following error:
Your APK or Android App Bundle is using permissions that require a privacy policy: (android.permission.READ_PHONE_STATE)
This is an unexpected behaviour right? Why will a vanilla app require this permission? How can I solve this issue?
Edit 1
My Android manifest is the default one created by react-native init.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.praveenavtestproject">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:allowBackup="false"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
Edit 2
My app doesn't need any permission to work. It just displays 3 lines of text from a historical literature. It is just for information purpose. In Play Store Console, under Store listing tab, at the bottom, there is a Privacy Policy section. It says If you wish to provide a privacy policy URL for this application, please enter it below. Also, please check out our User Data policy to avoid common violations.
I am not providing a privacy policy URL. My app is not supposed to be accessing any user data or phone state. Does React Native access it by default? Can that be the reason for this issue?
Edit 3
Looks like this issue is already being looked at by React Native team.

Why my rebuilded openfl/lime 2.9.1 for haxeflixel always ingores my own androidmanifest uses permissions?

I use haxeflixel that create lime build android applications.
I rebuild lime 2.9.1 from source that lime can make android target sdk version 26, as google said soon be minimum version for playstore. This is the original article .
As result i can make lime build android with android target sdk api version 26.
-Project.xml <android minimum-sdk-version="9" if="android" /> <android target-sdk-version="26" if="android" />
-AndroidManifest.xml <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="26"/>
But, now lime always ignores my own AndroidManifest.xml
-Project.xml <template path="assets/data/AndroidManifest.xml" rename="AndroidManifest.xml" if="android"/>
as result, my apk in time of installation show me "app no need special permissions". But my own AndroidManifest.xml have syntax
AndroidManifest.xml
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
If i switch lime version to "prebuilded lime 2.9.1" installed by default in haxeflixel , which can't make android target sdk version 26, but can only 19, then all work normal. In time of apk installing process i see the messages about require special permissions for app, and android app work as expected.
I test it on both windows / linux , the result is same. Prebuilded lime work done, but rebuilded lime ingnore all uses permissions, but use rebuilded lime i still can set portrait/landscape screen orientation inside my own AndroidManifest.xml.
How fix ingnoring android uses permissions from rebuilded lime side?
Have you tried putting the permissions into the Project.hxml? Something like:
<android permission="android.permission.WRITE_EXTERNAL_STORAGE" />
<android permission="android.permission.ACCESS_NETWORK_STATE"/>
<android permission="android.permission.INTERNET"/>
<android permission="android.permission.WAKE_LOCK"/>
<android permission="android.permission.VIBRATE"/>
<android permission="android.permission.READ_EXTERNAL_STORAGE"/>

productFlavors application Id

I'm trying to make two types of builds in Android Studio usung productFlavors.
I need to have unique applicationId for each buld type.
And here is an issue:
First of all I add this code to my gradle file
productFlavors {
base {
applicationId "ru.Public.lib"
}
city {
applicationId "ru.Public.lib.city"
}
Then when I'm trying to build app with city type, Android Studio shows an error:
"Error:Execution failed for task ':app:processBaseDebugGoogleServices'.
No matching client found for package name 'ru.Public.lib.debug'"
After this I decided that I need to change package name at my Manifest file.
I tryed to change package name in Manifest by three ways:
In project structure I created new Manifest app > src > city > AndroidManifest.xml. At this file I use package="ru.Public.lib.city"
I didn't create a new Manifest. Instead of it I used a placehilder for package name like this: package="${applicationId}"
I combined these two methods: "using placeholder at new Manifest in app > src > city >"
All shown ways gives me an error in the Manifest: Android Studio colored activity names by red and says unsolved class 'Activity Name'
Here is a part of my Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.Public.lib">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:name="ru.Public.lib.app.Application"
android:hardwareAccelerated="true"
android:icon="#mipmap/icon"
android:label="#string/app_name"
android:largeHeap="true"
android:resizeableActivity="false"
android:supportsRtl="true"
android:theme="#style/AppTheme.NoActionBarDefault">
<activity
android:name=".activities.ActivityMain"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity
android:name=".activities.ActivityEdition"
android:configChanges="orientation|screenSize|keyboardHidden">
</activity>
.....................................................................etc.
</manifest>
So. It looks like I need to recreate all my acivities in new directories acording to every packege name I need. But it is too complicated way. I'm sure that Google solved this problem.
Do anybody have some ideas about this issue?
Thanks!
Here are some step to solve it.
Go to your firebase console
Select your previous project and Add another app
Register another applicationId (Register all of your applicationID one by one)
Then Download new google-services.json
And place new google-services.json in your project
Thats it

Xamarin Android app crashes when using GCM

Im following the tutorial to add Google Cloud Messaging to your xamarin android project (Walkthrough - Using Remote Notifications in Xamarin.Android).
But im having trouble trying to connect to Google Services.
Everytime i try to build/ run my app, Visual Studio just trys to launch the app but then stops about a second later.
Heres the output message:
Android application is debugging. The application could not be
started. Ensure that the application has been installed to the target
device and has a launchable activity (MainLauncher = true).
Additionally, check Build->Configuration Manager to ensure this
project is set to Deploy for this configuration.
Here is my manifest file also:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="PushNotificationsAndroid.PushNotificationsAndroid"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<user-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="PushNotificationsAndroid.PushNotificationsAndroid.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="PushNotificationsAndroid.PushNotificationsAndroid.permission.C2D_MESSAGE" />
<application android:label="PushNotificationsAndroid"></application>
</manifest>
I commented out some of the permission lines and this issue seems just to happen when i added the line:
<permission android:name="PushNotificationsAndroid.PushNotificationsAndroid.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
Can anyone give me some advice to why this is happening?
Found a solution. I just had to make the package name lowercase for some reason
com.notifications.pushnotificationsandroid