I'm building a tiny dummy app using the command line (no gradle) with just a single blank activity, no permissions, no support libraries (or any other libraries, Google Play, etc) and yet Android always prompts for these two permissions during installation:
I understand how and why permissions get merged in when other libraries are included during a build, but my app has nothing included. I've extracted and decoded the compiled AndroidManifest.xml from the resulting APK and there's no <uses-permission> tag anywhere inside it.
According to this question, the READ_PHONE_STATE is added if no minSdkVersion value is entered, but I have one declared in the manifest (which I can also see in the compiled manifest).
Here is the source manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dummy.testapp"
versionCode="1">
<uses-sdk minSdkVersion="20" targetSdkVersion="22" />
<application
android:label="TestApp No Perms"
android:icon="#drawable/ic_launcher">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The single activity (MainActivity) just calls setContentView() on a blank layout.
Can anyone shed any light as to why these permissions are always requested or how to prevent them from being prompted for?
The answer came down to the missing android: prefix on the minSdkVersion and targetSdkVersion attributes.
Having no android: prefix doesn't cause any warnings or errors to be emitted from the resource compiler, but because of the missing prefix, the value is ignored when the APK manifest is parsed during installation.
The end result is that Android believes there is no minSdkVersion set and, as reported in Why does my app has the READ_PHONE_STATE permission although it's not declared in manifest?, automagically prompts for the permissions.
Adding in the android: prefix fixed the issue and allows the app to be installed with no permission prompts.
Related
This is my first post on stack overflow so please be easy going here. It's also been a couple years since I've made an app so my conceptual understanding is not what it used to be.
My goal at the moment is to set up RTSP service for my mobile app.
I am having trouble getting the plugin I am using to connect to anything on the internet so one of my first debugging steps is to make sure the AndroidManifest.xml file is okay.
Below, is my AndroidManifest.xml file.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ad_hoc.ad_hoc">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:label="ad_hoc"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Will the flutter build be effected if I have a few errors in my manifest file? I'm able to run the app, but I'm not sure if my internet permissions are working therefore I am unsure.
Here are the following errors I am getting in my manifest file:
"Unresolved class MainActivity" and "Attribute android:launchMode is
not allowed here"
The "is not allowed here" errors are occurring for multiple attributes. Should I resolve these or leave be? I've built new projects to see if this problem persists and it does. Not sure how to solve this.
For the unresolved class, I'm not sure how to get the manifest to recognize the main activity I use in my main.dart.xml file. The name of the primary Activity is not MainActivity.
Any pointers/help would be much appreciated.
Are there any simple tests that I can do to make sure that my app is able to connect to the internet?
So to summarize my question, will the internet permissions be granted although I have these problems in the manifest file?
Thank you!
Yes, when building or running on an android device the manifest will obviously have an effect on running the app. But - if your AndroidManifest.xml would really contain those errors the app would not launch in the first place.
My guess would be you either look at the wrong AndroidManifest.xml or your Android Studio has some problems. First make sure you are actually in the android module, and not in the root flutter project. ie. not in myproject/ but in myproject/android (in Android Studio you can use "Tools -> Flutter -> Open For Editing in Android Studio").
If you are really in the correct module, try to run from inside Android Studio which is opened from your Android app, not from the root folder. This might give you more error messages.
Also: by default the debug variants of the android manifest from the default flutter project template will include the internet permission. So if you don't change anything it's possible that the debug builds work, but the release builds are missing the internet permission.
This question already has answers here:
android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify
(35 answers)
Closed 7 months ago.
Using Android Studio 4.2.1, after changing sdk target to Android 12 in my build.gradle file, I am getting a Manifest merger failed with multiple errors, see logs error.
The errors shown in the Merged Manifest tab are as follows:
Merging Errors:
Error: Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. My_App.app main manifest (this file)
Error: Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. My_App.app main manifest (this file)
Error: Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. My_App.app main manifest (this file)
However the android:exported tag is already applied in my AndroidManifest.xml file. I only have one activity. No services or broadcast receivers. See below:
<?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="com.mydomain.myapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_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.VIBRATE" />
<application
android:name="com.mydomain.myapp.MyApplication"
android:allowBackup="false"
tools:replace="allowBackup"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.mydomain.myapp.ui.MainActivity"
android:exported="true">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>
My build.gradle(:app) file:
android {
compileSdkVersion("android-S")
buildToolsVersion "30.0.3"
defaultConfig {
...
minSdkVersion 23
targetSdkVersion("S")
...
}
Any idea how I could resolve this issue?
The issue was caused by 3 activities missing the android:exported attribute in the androidx.test:core library version 1.3.0. Upgrading to version 1.4.0-beta01 fixed the issue.
If you are getting errors after targeting Android 12, the easiest way to debug this is to:
downgrade to a prior sdk version
rebuild project
after a successful build, open your project's AndroidManifest.xml.
at the bottom of the window, click on the Merged Manifest tab
look for any <activity> that includes an <intent-filter> tag and is missing the android:exported attribute
If you want to make sure these activities are the issue, add them directly to your project's AndroidManifest.xml file with the missing android:exported attribute added and try rebuilding the project.
So if <activity android:name="com.domain.ProblemActivity"> is missing the android:exported attribute, add it to your AndroidManifest.xml file like so:
<activity
android:name="com.domain.ProblemActivity"
android:exported="true" >
Rebuild targeting Android 12 and if it works, then you found the bug!
Thanks #MikePenz for pointing me in the right direction.
If your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute for these app components. In order to solve this we need to follow these steps:
We need to locate the AndroidManifest.xml in the main folder.
android>app>src>main>AndroidManifest.xml
We have to add android:exported="" and set a boolean value inside these quotation marks. Now you might ask when do I need to add android:exported="true" or android:exported="false" to the activities, services, or broadcast receivers that use intent filters.
If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.
This is an example of how it should look like in your AndroidManifest.xml
<service android:name="com.example.app.backgroundService"
android:exported="false">
<intent-filter>
<action android:name="com.example.app.START_BACKGROUND" />
</intent-filter>
</service>
You can check out more info about this topic by following this link:
Safer component exporting for Android 12
If you upgrade your android studio to Bumblebee 2021.1.1.
The below changes are required to do:
Step 1: Your targetSdkVersion must be 30 or higher
Step 2: Update your appcompat library to implementation 'androidx.appcompat:appcompat:1.4.1'
Step 3: In the AndroidManifest file add android:exported = true to your activity launcher.
I had this issue, find it by:
if there's any activity, service, receiver, or provider that does not have exported attribute in your AndroidManifest file then add the below attribute in that activity, service, receiver, or provider
android:exported="false or true"
I had my Activity setup correctly with 'exported=true' and still had the following issue:
Installation failed due to [...] androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present
So I came across this Github post, which could explain why this happens, and applied the workaround yogurtearl suggests and it worked for me.
https://github.com/android/android-test/issues/832
It basically goes like this:
As a workaround, putting this in the app/src/debug/AndroidManifest.xml it will force the these to launch in the same test process.
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
android:exported="true"
android:theme="#android:style/Theme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
android:exported="true"
android:theme="#android:style/Theme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
android:exported="true"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
And added the 'exported=true' to them.
Don't forget to put it also into service tag
<service
android:name=".service.MyIME"
android:exported="true"
android:permission="android.permission.BIND_INPUT_METHOD">
<meta-data
android:name="android.view.im"
android:resource="#xml/method" />
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
</service>
Cleaning and rebuilding the project worked for me
If you're using DexGuard you should update to the latest version which is 9.2.11 (19-01-2022) at the moment.
Quote from the release notes:
Add default configuration for keeping the exported attribute as required by applications targeting Android 12.
As specified in the following link-
https://developer.android.com/about/versions/12/behavior-changes-12#exported ,the components of android that use intent filters must explicitly define component exporting, failing to which your app can't be installed on a device that runs on Android 12 or higher. The app components include activities, services, broadcast receivers and content providers.
If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.
Even after setting the android:exported tag, if you are facing the Manifest Merger failed issue, then check all the libraries that you are using in your app. Open the external libraries in the project view of the Android Studio and try to check all the manifests files of the libraries that you have included in your project. Any one of those libraries might have not updated according to Android 12. So if you find any manifest file of the library with exported tag missing, try to edit the file and add this tag there too. Hope that could help in removing Manifest Merger Error.
So I was doing some refactoring of package names in my project and now i'm no longer able to install my app. Right around the same time that I updated to the most current version of android studio. I believe that may be the problem because I think i did the refactoring before the upgrade, I just don't remember 100%
Here is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dodgingfire" >
<application
android:allowBackup="true"
android:icon="#mipmap/dodging_fire_icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".gamemain.GameMainActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is how I have my packages organized
http://prntscr.com/gcrw99
This is the full error message when I try to run my app
Installation failed with message Failed to finalize session : INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: Invalid manifest package: must have at least one '.' separator.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
Even when I accept to delete the existing application, It still gives me an error and doesn't install my app let alone run it.
The package name in your source manifest file is not actually the one that ends up in the APK being installed. During manifest merging process, the final package name is based on the applicationId value in your app's build.gradle file.
As the error message says, you need at least one . in the package name.
Other reasons for INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME can be found in PackageParser#validateName() source.
of course there are a lot similar questions and I really read through, but none of them completely answered my question:
I want to update my current app (already prod) on Google Play, but it says I need to change the versionCode -> 1 does already exist.
But I changed or added this in the AndroidManifest.xml, also the versionName.
You must know, I didn't add any versionCode or versionName in my first upload, could this cause the problem?
Do I have to delete the app now and re-upload it?
I surely used the same keystore and credentials
Steps done:
updated the AndroidManifest.xml
android:versionCode="2"
android:versionName="1.0">
created a new signed apk
tried to upload
Another question:
Do I really need to use the same apk-filename?
xml manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ibma.ibmaapp"
android:versionCode="2"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19"
android:maxSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.ibma.ibmaapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
For the first question - Are you sure you saved the changes to the manifest? Seems silly, but it's a mistake I make all the time.
For the second question - You can change the .apk filename to whatever you'd like; there's no need to keep it the same.
finally it works...
updated Android Studio to 0.8.0
updated my APIs (to API 20: Android L)
changed following project settings: (under "File > Project Structure")
Compile SDK Version: android-L
Build Tools Version: 20.0.0
changed the selected API for the graphical Layout (see link below)
have a look at this blog
(Thank you, Thodoris Bais! ;-) )
Had to change the build.gradle file and add the correct VersionCode
this was the reason why I could not generate apk's with different VersionCodes
it was still set to versionCode=1 though in the manifest it was set to two
I checked the new apk file with the aapt command and the versionCode was set to 2, finally!
Now my last queston would be:
Do I always have to update the AndroidManifest.xml and the build.gradle file on my own - shouldn't they just synchronize?
Best regards,
Christian
I come across a weird problem, I got an application allowing to freely change the font size on Android Device (Font Size Setter). It uses introspection to call some internal Android apis. To do this call, it needs the following permission : android.permission.CHANGE_CONFIGURATION. It worked like a charm under Android 4.0 and up to 4.2 where it does not work anymore.
Digging into logs I found out that I can't update font size because it misses this permission. Debbuging to check effective permissions, I got these when inspecting the PackageInfo corresponding to my app
requestedPermissions = {java.lang.String[2]#830038778728}
[0] = {java.lang.String#830038778760}"android.permission.CHANGE_CONFIGURATION"
[1] = {java.lang.String#830038778896}"android.permission.WRITE_SETTINGS"
requestedPermissionsFlags = {int[2]#830038779016}
[0] = 1
[1] = 3
Does somebody got any clue about what's going on, or any workaround idea ?
Thanks a lot for reading me.
Per request, the AndroidManifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.gatay.android.fss"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="14"/>
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<application android:label="#string/app_name" android:icon="#drawable/app_icon">
<activity android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
Check this post http://blog.sightidea.com/?p=44
You can ask your user to grant permission to the app with adb tool:
>adb shell
>pm grant com.yourapp.packagename android.permission.CHANGE_CONFIGURATION
The protection level of CHANGE_CONFIGURATION permission has been changed to "system|signature|development" (v4.2) from "dangerous" (v4.1 and below) since Android v4.2
It looks like that no way for 3rd part apps to get CHANGE_CONFIGURATION permission on Android 4.2+ devices. :-(
At least at present, CHANGE_CONFIGURATION requires for your app either to be signed by the firmware signing key or be installed on a system partition. You can see this by examining the framework manifest, where these permissions are defined.