The AndroidManifext.xml has this code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.skeleton">
<application
android:label="skeleton"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
On what real value the applicationName is interpolated?
This value is set by the Flutter Gradle plugin.
It can have 2 value :
If you have multidex enabled and your app has a minSdk less than 20, this value will be io.flutter.app.FlutterMultiDexApplication.
Else, it will be android.app.Application.
You can override this value by setting the base-application-name property (in the gradle.properties of your android folder for example).
Source : https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/flutter.gradle#L261
Remember that you can always inspect the resulting APK (in build/app/outputs/flutter-apk) to see what value is in the final Manifest. Or you can just read the merged manifest in build/app/intermediates/merged_manifests/debug/AndroidManifest.xml.
Related
Problem: I get the following error when trying to run the Xamarin.Android application:
"he application does not have the 'android:debuggable' attribute set in the AndroidManifest.xml"
Even though I do have it set in the manifest:
<application android:label="SomeAPP" android:debuggable="false" android:theme="#style/SOMETheme" android:icon="#drawable/some_icon_180px" android:requestLegacyExternalStorage="true">
I don't want to set it to true, because I am about to upload to the Google Play Store.
I also looked for debuggable in the entire project. It does not exist in any other files in this project.
Why is it still stating that?
At first, the 'android:debuggable' attribute doesn't need the developer to set, it will be set as false when you run it in the release mode and as true when you run it in the debug mode.
And I have checked a number of my projects' AndroidManifest.xml, all of them don't have this attribute in the file.
You can try to create a new project to test this or update the packages you added into your project. The third-party package may cause this error.
After integrating RN into an existing Android project, I get the following error:
Error: Package name not found in /home/.../AndroidManifest.xml at Object.projectConfig (/home/.../rn_integrated_app/node_modules/#react-native-community/cli-platform-android/build/config/index.js:74:11) at Object.get project [as project]
As I understand the problem is that there is no package attribute in the relevant AndroidManifest.xml file. Since my project has many flavors, the package attribute is added dynamically, while compiling, through app/build.gradle:
def pkgDataEntry = getRightValue(packagesData, variantMap)
variant.getMergedFlavor().applicationId = pkgDataEntry.pkg
So that the final merged manifest file does have the package attribute.
The error occurs here(#react-native-community/cli-platform-android/build/config/index.js):
const packageName = userConfig.packageName || getPackageName(manifest);
if (!packageName) {
throw new Error(`Package name not found in ${manifestPath}`);
}
Is there a way to make RN read the merged manifest file?
If not, how can I modify userConfig to contain the package name? I couldn`t find anything about it in the docs.
Thank you
For me, the solution was to add the "package" tag to the manifest tag.
I didn't have to create another dummy folder.
The manifest open tag now looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourProjectName">
If anybody encounters the same issue, when having multiple flavors and AndroidManifest.xml files,here`s my conclusion:
RN has some kind of a bug that it requires the first folder alphabetically, in android/app/src, which has AndroidManifest.xml file,to have the package attribute. Otherwise, it will throw an error.
A simple solution would be to create a dummy folder, e.g aaa (first alphabetically) and to create AndroidManifest.xml inside of it, with the following attribute - package:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="aaa"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission
android:name="android.permission.GET_ACCOUNTS"
tools:node="remove"/>
</manifest>
For me, this error start after upgrade the sdkVersion from 31 to 33 and gradle version.
I did check the changes in git, and notice that the package attribute was removed from AndroidManifest.xml.
So I did add this attribute again.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.yourpackage">
The AndroidManifext.xml has this code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.skeleton">
<application
android:label="skeleton"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
On what real value the applicationName is interpolated?
This value is set by the Flutter Gradle plugin.
It can have 2 value :
If you have multidex enabled and your app has a minSdk less than 20, this value will be io.flutter.app.FlutterMultiDexApplication.
Else, it will be android.app.Application.
You can override this value by setting the base-application-name property (in the gradle.properties of your android folder for example).
Source : https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/flutter.gradle#L261
Remember that you can always inspect the resulting APK (in build/app/outputs/flutter-apk) to see what value is in the final Manifest. Or you can just read the merged manifest in build/app/intermediates/merged_manifests/debug/AndroidManifest.xml.
I'd like to mock locations in release build type of Android app. I've created a special flavour "mockable" manifest in app/src/mockable/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
</manifest>
But it seems that Android lint blocks from using this permissions in release build type. For command:
./gradlew assembleRelease
I got output:
:app:lintVitalMockableRelease
/home/fr/app/src/mockable/AndroidManifest.xml:3: Error: Mock locations should only be requested in a debug-specific manifest file (typically src/debug/AndroidManifest.xml) [MockLocation]
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Explanation for issues of type "MockLocation":
Using a mock location provider (by requiring the permission
android.permission.ACCESS_MOCK_LOCATION) should only be done in debug
builds. In Gradle projects, that means you should only request this
permission in a debug source set specific manifest file.
To fix this, create a new manifest file in the debug folder and move the
<uses-permission> element there. A typical path to a debug manifest
override file in a Gradle project is src/debug/AndroidManifest.xml.
1 errors, 0 warnings
Is it possible to generate release app with location mocking permission?
Disable the MockLocation lint check for that particular permission, i.e.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission
android:name="android.permission.ACCESS_MOCK_LOCATION"
tools:ignore="MockLocation" />
</manifest>
(Refer to http://tools.android.com/tips/lint-checks)
The only solution I know for sure is to let lint report errors but don't let that abort the build process:
To enable that just add
lintOptions {
abortOnError false
}
inside the android block.
You will still get lint errors and warnings but the build will continue.
I am not sure if you can put that inside the flavor definition or use a custom buildType for that. I have no project where I could test that.
This is a caution. If you want a user to "mock location" then the user must enable mock locations in Android.
A production release is definitely possible, I have done this. You need to prompt the user to allow for "Mock Locations" like a developer/debug would.
Just updated to the latest version of Android Studio and i get this error in the AndroidManifest file
Manifest merger failed : Attribute application#icon value=(#drawable/project_launcher_icon) from AndroidManifest.xml:48:9
is also present at com.github.anupcowkur:reservoir:1.1.1:6:45 value=(#drawable/ic_launcher)
Suggestion: add 'tools:replace="icon"' to element at AndroidManifest.xml:44:5 to override
I tried adding tools:replace="#drawable/ic_drawer" in my manifest but i get this error:
Error:(44, 5) tools:replace specified at line:44 for attribute tools:drawable/ic_drawer, but no new value specified
Any ideas?
Following Android Studio's suggestion and adding the following attribute tools:replace="icon" should allow it to build your app successfully, without resorting to using the old manifest merger (which isn't a very forward-looking solution indeed).
Of course, you'll first have to declare the namespace "tools" in order to use it:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.sample.app" >
You should add tools:replace="icon", just like the error message says.
Additional attributes can be replaced using the syntax tools:replace="icon,name,theme"
look here:
All markers belong to the Android tools namespace, therefore you must declare the namespace in any AndroidManifest.xml containing at least one marker :
xmlns:tools="http://schemas.android.com/tools"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.tests.flavorlib.app"
**xmlns:tools="http://schemas.android.com/tools"**>
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
**tools:replace=”icon, label”**/>
</manifest>
you should add xlms:tools and tools:replace those two lines in manifest file.
Android Studio 0.6 use the new manifest merger tool. This new merger was introduced in version 0.10 of the plugin. As of 0.11, this tool is used by default by the gradle plugin.
In order to revert to the old manifest merger, please add to your build.gradle the following configuration :
android {
useOldManifestMerger true
}
For me this worked. Try adding the code in the main module(project) manifest file:
add
xmlns:tools="http://schemas.android.com/tools" in your manifest tag
add
tools:replace="android:icon,android:label,android:theme" in your application tag
These will let Android Studio know that the icon, label and theme to be used are from that manifest and not from other projects included.