0

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

Al Lelopath
  • 6,448
  • 13
  • 82
  • 139
APP Bird
  • 1,371
  • 1
  • 20
  • 37

3 Answers3

1

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.

Ruturaj Patil
  • 608
  • 1
  • 10
  • 25
0

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.

Fuat Coşkun
  • 1,045
  • 8
  • 18
  • thanks for the reply. the problem is that coding inserted between debug/androidmanifest.xml and no matter how hard I tried that code doesn't go away. I deleted coding & cleaned project so many times but still that code existing on debug/androidmanifest file – APP Bird Feb 10 '16 at 15:33
  • I think you facing the same issue stated in this post : http://stackoverflow.com/questions/29643274/tag-provider-attribute-authorities-has-invalid-character-in-androidmanifes I think it will be ok after writing your app_id hardcoded and restarting your Android Studio. – Fuat Coşkun Feb 10 '16 at 15:41
  • thank you. that is similar to mine and solution fixed my problem – APP Bird Feb 10 '16 at 15:50
0

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