APP Bird
APP Bird

Reputation: 1381

Android Studio debug/android manifest doesn't change & giving error

I worked on a android project all day today. Now I am trying to load a project into android studio. It gives me error on > debug/android manifest even though I corrected the error . It keeps repeating the same error on same place. It looks like coding doesn't change

Error:(45) Tag attribute authorities has invalid character '@'.

 <provider
    android:name="com.facebook.FacebookContentProvider"
    android:authorities="com.facebook.app.FacebookContentProvider@string/facebook_app_id"
    android:exported="true" />

It automatically inserted between permissions on debug/android manifest. original manifest file has no error nor any unnecessary coding between permissions

Upvotes: 0

Views: 3323

Answers (3)

Ruturaj Patil
Ruturaj Patil

Reputation: 608

In Android Studio, try File -> Invalidate Cache and Restart. I'd similar problem where changes in res/AndroidManifest.xml were not being reflected in debug\AndroidManifest.xml and above step did the trick for me.

Upvotes: 1

pontiac_ventura
pontiac_ventura

Reputation: 79

It's failing because you're accessing an @string reference in the middle of the value of the authorities attribute, and references need to appear by themselves to be interpreted correctly. There are a couple approaches around this.

First, you can hardcode the facebook app id by appending it to the end of FacebookContentProvider like so (assume 22222222 is the facebook app id):

<provider android:authorities="com.facebook.app.FacebookContentProvider22222222"
              android:name="com.facebook.FacebookContentProvider"
              android:exported="true" />

But this is not ideal if you have different facebook app ids (for example, one for development, one for staging, and one for production). To set the authorities attribute dynamically, you first need to set the specific values in your build.gradle file:

...
buildTypes {
    release {
        resValue "string", "facebook_content_provider_app_id", "\"com.facebook.app.FacebookContentProvider55555555555\""
    }
    debug {
        resValue "string", "facebook_content_provider_app_id", "\"com.facebook.app.FacebookContentProvider22222222222\""
    }
}

Once you have that in place, you can reference the facebook app id regardless of the build type dynamically in the AndroidManifest.xml:

<provider android:authorities="@string/facebook_content_provider_app_id"
              android:name="com.facebook.FacebookContentProvider"
              android:exported="true" />

Upvotes: 0

Fuat Coşkun
Fuat Coşkun

Reputation: 1055

Did you checked sample project on facebook-android-sdk repo?

https://github.com/facebook/facebook-android-sdk/blob/master/samples/RPSSample/AndroidManifest.xml

Here

<provider android:authorities="com.facebook.app.FacebookContentProvider157578437735213"
                  android:name="com.facebook.FacebookContentProvider"
                  android:exported="true" />

app_id is entered as hard-coded instead of string parameter. You can try this or ensure that you have "facebook_app_id" parameters in strings.xml.

Upvotes: 0

Related Questions