cordova build android AndroidManifest.xml bad lines - android

I'm extending an ios app to the android platform - I'm unfamiliar with the android tools but following the tuts.
I have added the platform but when I run the 'cordova build android' I get errors on the AndroidManifest.xml
When I trace this it seems that lines are being added in the uses-permission section (see the last 3) that have no android namespace
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission name="android.permission.READ_PHONE_STATE" />
if I add the namespace and rebuild, the error becomes one of duplication. If I delete the offending lines, then the rebuild just re-writes them.
The ios version of my app works perfecto, so I'm assuming its something to do with how the plugins write to this file on android build.
Before I start to debug by unpicking the plugins, has anyone else been here before and resolved it, and are hungry for upvotes?

I am afraid you need to setup the issue manually as that is not resolved yet, its still alive.
You have to open your plugins/android.json and remove the duplicate keys in there. In your case search for WRITE_EXTERNAL_STORAGE, MODIFY_AUDIO_SETTINGS, READ_PHONE_STATE in android.json and remove the duplicates.
Then open up platforms/android/AndroidManifest.xml and remove the duplicate <uses-permission... /> tags. And then rebuild and try again.

Related

Android React Native App asking for permissions that are not defined within android/app/src/main/AndroidManifest.xml

I have a Android build of a react native app that I have uploaded to the Google Play console.
I am having issues with the build of the app requesting more permissions than I have defined inside my apps android/app/src/main/AndroidManifest.xml
I am having troubles with the QUERY_ALL_PACKAGES permission in particular which Google says my app is not compliant with.
The permissions defined inside my app android/app/src/main/AndroidManifest.xml are the below:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.vending.BILLING"/>
I then did a global search for QUERY_ALL_PACKAGES in my project and found it was defined in several places like:
android/app/build/intermediates/merged_manifests/release/AndroidManifest.xml
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- Required to access Google Play Licensing -->
<uses-permission android:name="com.android.vending.CHECK_LICENSE" /> <!-- Required by older versions of Google Play services to create IID tokens -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" />
and the android/app/build/intermediates/bundle_manifest/release/bundle-manifest/AndroidManifest.xml
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!--
Required to access Google Play Licensing -->
<uses-permission android:name="com.android.vending.CHECK_LICENSE" /> <!-- Required by
older versions of Google Play services to create IID tokens -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission
android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE"
/>
What are these files and why are they requiring permissions I have not set inside my android/app/src/main/AndroidManifest.xml
How would I go about removing a permission requested by these files like the android.permission.QUERY_ALL_PACKAGES
Any help or guidance would be greatly appreciated.
Best,
Matt
By default, some permissions are added to your Android APK. To remove them, just add few lines in android/app/src/main/AndroidManifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myappid"
+ xmlns:tools="http://schemas.android.com/tools"
>
+ <uses-permission tools:node="remove" android:name="android.permission.QUERY_ALL_PACKAGES" />
.....
</manifest>
Also you can find the reference here in the official documentation : https://reactnative.dev/docs/0.62/removing-default-permissions
I would recommend in addition to the other answer provided find out which library in your project is trying to add that permission and remove it. That permissions should be rarely used as it's able to grab the package names of every app the user has installed. It's not a recommended practise.

App installation fails in Android 12 devices

Our app fails to install after migrating to the targetSdkVersion 31. On trying to find the issue we found that a library was using FLASHLIGHT permission and we were getting this error while installing:
Installation failed due to: 'Failed to commit install session
130765275 with command cmd package install-commit 130765275. Error:
-127: Package com.xxxx.yyyy.zzzz attempting to declare permission android.permission.FLASHLIGHT in non-existing group
android.permission-group.HARDWARE_CONTROLS'
Permissions used in the manifest file of library:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<permission
android:name="android.permission.FLASHLIGHT"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="normal" />
Is there any workaround to this issue?
android.permission-group.HARDWARE_CONTROLS is deprecated in targetSdkVersion 31 . The work around is to remove the permission used by library in your manifest by
<permission
android:name="permissionOne"
tools:node="remove"
tools:selector="com.example.lib1">
tools:node="remove"
will remove the permission from the App if its used in any of your libraries

How reinstall application after changes in androidManifest without removing previous version of application

How reinstall application after changes in android.manifest without removing previous version of application?
I have ready installed application on phone. Then I changed something in AndroidManifest.xml and build apk file. Now I want install application on phone,
but I get "The application has not been installed."
When I remove old version and then install new everything is ok, but another device I want reinstall app without removing previous version, because I don't want lost data.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="eu.treative.fca_pops">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29"
tools:ignore="ScopedStorage" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
android:minSdkVersion="30"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:name="com.orm.SugarApp"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:networkSecurityConfig="#xml/network_security_config"
android:roundIcon="#mipmap/ic_launcher_round"
android:usesCleartextTraffic="true"
android:supportsRtl="true"
android:theme="#style/Theme.Fcapops"
android:requestLegacyExternalStorage="true"
tools:replace="android:icon">
The application has not been installed.
Sometimes that error not because of the android manifest.
Make sure that the apk had signed by the same certificate.
That case sometimes happens to me, when I install the release version from google play, then I install debug version from my local project.
After making sure that the apps signed by the same certificate, make sure that the app had the same or bigger number build version.
You can't replace apk with build versionCode 12 with build versionCode 11, should be 12 or higher.

"Falling back on PROMPT mode since _cordovaNative is missing" error in older Android SDK versions

I am Developing an Android Application using Cordova-2.2.0, Android sdk I'm using is 4.1 and my application working Fine.
when I tried to test this Application on Android 2.2 and 2.3.3 I'm getting some log indicating like below and and my application page is not opening.
LOG is:
01-02 15:42:08.166: D/CordovaLog(486): Falling back on PROMPT mode since _cordovaNative is missing.
01-02 15:42:08.166: D/CordovaLog(486): file:///android_asset/www/js/ext/cordova-2.2.0.js: Line 1032 : Falling back on PROMPT mode since _cordovaNative is missing.
01-02 15:42:08.166: I/Web Console(486): Falling back on PROMPT mode since _cordovaNative is missing. at file:///android_asset/www/js/ext/cordova-2.2.0.js:1032
I don't know why it is appearing and how to solve it.
There is nothing to fix. When the PhoneGap framework detects that you are running on a version of Android that does not support the regular way of passing information between the Java and JavaScript code it reverts back to the safer PROMPT mode.
seems a problem with the connection to your native code or proof Android project in Eclipse project clean and recompile to see what happens, or be sure to put the libs folder in your project with the corresponding. jar PhoneGap
#dagavi90
Add this to your manifest:
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />

New apk uploaded and getting "Supported devices 0" on my developer console

Just uploaded 2 new apks and on both I'm getting supported devices 0.
Just looked around and I can't think of anything suspicious with my manifest.
Can someone shed some light on this?
thanks
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I had a similar problem when I used commons.jar in build.gradle as follows:
compile 'org.apache.directory.studio:org.apache.commons.io:2.4
I solved it by doing this instead:
compile 'commons-io:commons-io:2.4'
Alternatively one can manually download the library and put it in a libs folder, thus applying it as follows instead:
compile files('libs/commons-io-2.4.jar')
I encountered the same problem when I published my app recently. If I recall correctly, I had to click on the APK tab and select the APK file (possibly by clicking an "Activate" button). I hope this helps you in the right direction. Since I already fixed it, I can't see the same options that you see.

Categories

Resources