도구 : Android 매니페스트에서 교체하지 않음
다양한 라이브러리 종속성이있는 gradle 프로젝트를 사용하고 새로운 매니페스트 병합을 사용하고 있습니다. 내 <application />
태그에는 다음과 같이 설정했습니다.
<application tools:replace="android:icon, android:label, android:theme, android:name"
android:name="com.example.myapp.MyApplcation"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/application_name"
android:logo="@drawable/logo_ab"
android:theme="@style/AppTheme"
>
....
</application>
그러나 오류가 발생합니다.
/android/MyApp/app/src/main/AndroidManifest.xml:29:9 Error:
Attribute application@icon value=(@drawable/ic_launcher) from AndroidManifest.xml:29:9
is also present at {Library Name} value=(@drawable/app_icon)
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:26:5 to override
/android/MyApp/app/src/main/AndroidManifest.xml:30:9 Error:
Attribute application@label value=(@string/application_name) from AndroidManifest.xml:30:9
is also present at {Library Name} value=(@string/app_name)
Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:26:5 to override
/android/MyApp/app/src/main/AndroidManifest.xml:27:9 Error:
Attribute application@name value=(com.example.myapp.MyApplication) from AndroidManifest.xml:27:9
is also present at {Another Library}
Suggestion: add 'tools:replace="android:name"' to <application> element at AndroidManifest.xml:26:5 to override
/android/MyApp/app/src/main/AndroidManifest.xml:32:9 Error:
Attribute application@theme value=(@style/AppTheme) from AndroidManifest.xml:32:9
is also present at {Library Name} value=(@style/AppTheme)
Suggestion: add 'tools:replace="android:theme"' to <application> element at AndroidManifest.xml:26:5 to override
다음과 같이 매니페스트 헤더를 선언하십시오.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourpackage"
xmlns:tools="http://schemas.android.com/tools">
그런 다음 애플리케이션 태그에 다음 속성을 추가 할 수 있습니다.
<application
tools:replace="icon, label" ../>
예를 들어 아이콘과 레이블을 바꿔야합니다. 행운을 빕니다!
나는 같은 문제를 해결했다. 나를위한 해결책 :
xmlns:tools="http://schemas.android.com/tools"
매니페스트 태그에 줄을 추가하십시오tools:replace=..
매니페스트 태그에 추가android:label=...
매니페스트 태그 로 이동
예:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:replace="allowBackup, label"
android:allowBackup="false"
android:label="@string/all_app_name"/>
gradle 파일에서 종속성을 재정렬하십시오. 문제가되는 라이브러리를 목록의 맨 아래에서 맨 위로 이동해야했는데 효과가있었습니다.
방금 tools:replace=...
OP에서 설명한 것과 동일한 동작을 경험했습니다 .
It turned out that the root cause for tools:replace
being ignored by the manifest merger is a bug described here. It basically means that if you have a library in your project that contains a manifest with an <application ...>
node containing a tools:ignore=...
attribute, it can happen that the tools:replace=...
attribute in the manifest of your main module will be ignored.
The tricky point here is that it can happen, but does not have to. In my case I had two libraries, library A with the tools:ignore=...
attribute, library B with the attributes to be replaced in the respective manifests and the tools:replace=...
attribute in the manifest of the main module. If the manifest of B was merged into the main manifest before the manifest of A everything worked as expected. In opposite merge order the error appeared.
The order in which these merges happen seems to be somewhat random. In my case changing the order in the dependencies section of build.gradle
had no effect but changing the name of the flavor did it.
So, the only reliable workaround seems to be to unpack the problem causing library, remove the tools:ignore=...
tag (which should be no problem as it is a hint for lint only) and pack the library again.
And vote for the bug to be fixed, of cause.
Final Working Solution for me (Highlighted the tages in the sample code):
- add the
xmlns:tools
line in the manifest tag - add
tools:replace
in the application tag
Example:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pagination.yoga.com.tamiltv"
**xmlns:tools="http://schemas.android.com/tools"**
>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
**tools:replace="android:icon,android:theme"**
>
The missing piece for me was this:
xmlns:tools="http://schemas.android.com/tools"
for example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.your.appid">
You can replace those in your Manifest application tag:
<application
tools:replace="android:icon, android:label, android:theme, android:name,android:allowBackup"
android:allowBackup="false"...>
and will work for you.
FIXED IT HAD THE EXACT ERROR, Just add this tools:replace="android:icon,android:theme"
into your application tag in your manifest, it works just fine,
You can replace those in your Manifest application
tag:
<application
...
tools:replace="android:label, android:icon, android:theme"/>
and will work for you.
Explanation
Using such a dependency/library in your gradle
file which has those labels in its Manifest's application tag may produce this problem and replacing them in your Manifest
is the solution.
I was receiving a similar error on a project I was importing:
Multiple entries with same key: android:icon=REPLACE and tools:icon=REPLACE
Fixed after changing the below line within the application tag:
tools:replace="icon, label, theme"
to
tools:replace="android:icon, android:label, android:theme"
I also went through this problem and changed that:
<application android:debuggable="true" android:icon="@drawable/app_icon" android:label="@string/app_name" android:supportsRtl="true" android:allowBackup="false" android:fullBackupOnly="false" android:theme="@style/UnityThemeSelector">
to
<application tools:replace="android:allowBackup" android:debuggable="true" android:icon="@drawable/app_icon" android:label="@string/app_name" android:supportsRtl="true" android:allowBackup="false" android:fullBackupOnly="false" android:theme="@style/UnityThemeSelector">
The following hack works:
- add the
xmlns:tools="http://schemas.android.com/tools"
line in the manifest tag - add
tools:replace="android:icon,android:theme,android:allowBackup,label"
in the application tag
참고URL : https://stackoverflow.com/questions/25981156/tools-replace-not-replacing-in-android-manifest
'Programing' 카테고리의 다른 글
MySQL에서 한 테이블에서 다른 새 테이블로 데이터를 복사하는 방법은 무엇입니까? (0) | 2020.06.28 |
---|---|
자바 스크립트에서 숫자의 길이 (0) | 2020.06.28 |
C #에서 화재를 피하고 방법을 잊는 가장 간단한 방법은 무엇입니까? (0) | 2020.06.28 |
express.js 자산에 응답 헤더를 설정하는 방법 (0) | 2020.06.28 |
AngularJS-ng-Repeat 내에서 속성 이름을 참조하는 방법 (0) | 2020.06.28 |