Android Studio 6.0 merger fail - android

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.

Related

Can I safely replace usesCleartextTraffic in my Manifest?

I am trying to use hCaptcha library on my project. However, it seems that hCaptcha library comes with a usesCleartextTraffic tag defined on the Manifest which is already defined by another library. When I add hCaptcha and try to run the project I get the following error:
Attribute application#usesCleartextTraffic value=(true) from [com.theoremreach:theoremreach:3.5.1] AndroidManifest.xml:15:9-44
is also present at [com.github.hcaptcha:hcaptcha-android-sdk:3.3.6] AndroidManifest.xml:11:9-45 value=(false).
Suggestion: add 'tools:replace="android:usesCleartextTraffic"' to <application> element at AndroidManifest.xml:17:5-132:19 to override.
Great, there is a suggestion. Now by adding the following to my application tag on the Manifest, I can avoid any errors and run my application:
tools:replace="android:usesCleartextTraffic"
android:usesCleartextTraffic="true"
My question is, replacing this value with true will not influenciate the hCaptcha Manifest false value for usesCleartextTraffic?
What would be the correct way to solve this error, without affecting each library security?

Where is ${applicationName}? [duplicate]

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.

React Native: Error: Package name not found

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">

What does the ${applicationName} in flutter AndroidManifest.xml means?

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.

Error in configuring network security xml in android

In the android network security docs , it says to create a network_security_config.xml file in res/xml folder.
In order to make an entry in manifest file, it says to make an entry in this way
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="#xml/network_security_config"
... >
...
</application>
</manifest>
But I am getting the error No resource identifier found for attribute 'networkSecurityConfig' in package 'android'
I also checked for the valid attributes in application tag ( android docs ), there is no attribute as "networksecurityconfig"
You need to set your compileSdkVersion to 24 or higher and set your buildToolsVersion to 24.0.0 or higher.
With regards to the documentation, that's a documentation bug.
The documentation is fixed, the xml should live inside res/xml which is not in the root but inside android/app:
android/app/src/main/res/xml/network_security_config.xml
From minimumSDK 20 you will need the file and be sure to whitelist localhost and 10.0.2.2 and 10.0.3.2 or you'll have trouble on development

Categories

Resources