How to fix android manifest.xml naming conflict?
Asked Answered
C

2

16

For some reason, even though my app name appeared correctly next to the app icon, when I looked for the app under settings->app, the name appeared to be "libcocos2dx" instead of the correct name.

So I added the following line in my AndroidManifest.xml:

    android:label="@string/app_name"

But it caused the error:

app/AndroidManifest.xml:12:6 Error:
    Attribute application@label value=(@string/app_name) from AndroidManifest.xml:12:6
    is also present at proj.android-studio:libcocos2dx:unspecified:13:9 value=(libcocos2dx)
    Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:11:5 to override

How can I fix the above error ? I have no idea where libcocos2dx is specified as the name. I am using cocos2d-x v3.7, which uses libcocos2dx.

EDIT: I can see the suggestion to use "tools:replace" , but I feel like I'm masking the problem instead of fixing it. Is there a better way to fix the root cause ?

EDIT: Does anyone know how to add tools:replace ? This might seem obvious to you, but when I add it, I get the error:

the prefix "tools" for attribute "tools:replace" associated with an element type "application" is not bound

Cudbear answered 14/8, 2015 at 4:37 Comment(6)
add tools:replace="android:label in your Application Tag in your Androidmanifest.Ornis
Yes I saw that, but why is my app being named libcocos2dx ? How do I fix the original error. I feel like I'm masking the error instead of fixing it.Cudbear
Its telling you that that attribute has already been used by libcocos and you have to replace it to override it. Just read the error carefully, its all thereInterject
can you check your @string/ where it is pointing you?Ornis
@Interject Yes - I see it. But I don't know how to fix it. I'm new to Android, and don't know these things.Cudbear
@Ornis I don't know what you mean. It clearly says app_nameCudbear
C
45

Had to add to the manifest header:

xmlns:tools="http://schemas.android.com/tools"

For example:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.yourpackage"
    xmlns:tools="http://schemas.android.com/tools">

Then in the element:

'tools:replace="android:label"'
Cudbear answered 16/8, 2015 at 9:26 Comment(1)
where 'tools:replace="android:label"' we use?Inspire
C
2

The answer from Kaizer Sozay in this thread helped me a lot while I was looking to set android:allowBackup in my NativeScript project.

I ended up with the complete file like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
    <application tools:replace="android:allowBackup" android:allowBackup="true">
    </application>
</manifest>
Catharinecatharsis answered 20/9, 2019 at 21:19 Comment(4)
Take a look at who asked the question :)Cudbear
Actually both my question and the answer you linked to are mine :)Cudbear
Yeah @KaizerSozay I realised that after I posted the answer. I wanted to make sure people searching for NativeScript with the same error came across this answer too. :)Catharinecatharsis
Haha I have no idea what nativescript is. Have a good one beeman! Can’t wait for your movie!! 😆Cudbear

© 2022 - 2024 — McMap. All rights reserved.