Facebook Unity SDK issues when building for Android - android

I am not being able to solve this build-time issue when building for Android.
Here's the error message:
AndroidManifest.xml:39: Tag <provider> attribute authorities has invalid character '$'.
I found, indeed, in the AndroidManifest.xml produced in the Temp/StagingArea folder the following lines:
<!--
The initialization ContentProvider will call FacebookSdk.sdkInitialize automatically
with the application context. This config is merged in with the host app's manifest,
but there can only be one provider with the same authority activated at any given
point; so if the end user has two or more different apps that use Facebook SDK, only the
first one will be able to use the provider. To work around this problem, we use the
following placeholder in the authority to identify each host application as if it was
a completely different provider.
-->
<provider android:authorities="${applicationId}.FacebookInitProvider" android:exported="false" android:name="com.facebook.internal.FacebookInitProvider" />
It looks like the applicationId substitution is not working, but I correctly place it in the Facebook Settings, as stated in the docs.
Tried it with Facebook SDK 7.10, 7.11 and 7.12 on Unity 2017.2 and 2018.1 in an empty project with just the Facebook SDK plugin installed.
Anyone out there have any idea on what is happening here?

Try replacing this with your app id, $ returns package name not appID.
<provider android:authorities="FacebookInitProvider{APP ID HERE}" android:exported="true" android:name="com.facebook.internal.FacebookInitProvider" />

Related

Ionic - Android authorities: FacebookContentProvider undefined in android manifest

Can’t install because provider name com.facebook.app.FacebookContentProviderundefined (in package io.ionic.sxxxx) is already used by io.ionic.yyyyy]"
This is listed in a few android manifest files
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider"
android:exported="true" />
on build I get
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProviderundefined"
android:exported="true" />
— notice the undefined ----- should I be defining something somewhere? Is there another solution? Basically I have a pair of apps that will not install at the same time on a device because this output is the same. My understanding is undefined should be my facebook id. I do have a variety of values defined in my android strings file. I have seen a few answers from a couple years ago on here (Android Facebook content provider authority) , but the solutions do not work as the files in my android directory are different as are their contents. Any help would be much appreciated!
<string name="title_activity_main">xxxx</string>
<string name="package_name">io.ionic.xxxx</string>
<string name="custom_url_scheme">io.ionic.xxxx</string>
<string name="fb_app_id">xxxxx</string>
<string name="facebook_app_id">xxxxx</string>
<string name="fb_app_name">xxxxx</string>
<string name="fb_login_protocol_scheme">fbxxxxxx</string>
<string name="fb_auto_log_app_events_enabled">true</string>
<string name="fb_advertiser_id_collection_enabled">true</string>
I have tried deleting all of the tags from all of the android manifest files, but they are generated on build. I have tried adding a string called authority in my string.xml file. I have struggeled to figure out how to implement the solutions here, as they dont exactly align with the files in my ionic project. Android Facebook content provider authority.
There is an open issue about this on GitHub:
https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect/issues/100
Did you try the temporary solutions provided in the comments?
HCJSolutions commented on Dec 10, 2021
I found a temporary solution is add ${applicationId}
modified the platforms\android\app\src\main\AndroidManifest.xml find a
node 123456789"
android:exported="true"
android:name="com.facebook.FacebookContentProvider" />
or
change it at
plugin folder plugins\cordova-plugin-facebook-connect\plugin.xml find
the line <provider
android:authorities="com.facebook.app.FacebookContentProvider${applicationId}$APP_ID"
and
apren commented on Apr 24:
Another temporary solution:
Set any APP_ID, for example APP_ID = "app_package_name" After init app
use code
facebookConnectPlugin.setApplicationId('your_facebook_app_id')

cordova_plugin_file_chooser not working in same device for two different apps

I am using cordova cli for creating android app.
I have user cordova_plugin_file_chooser
Where it given that below
Note that like a ContentProvider, the DocumentProvider authority must be unique. You should change com.ianhanniballake.localstorage.documents in your Manifest, as well as the LocalStorageProvider.AUTHORITY field.
By above I have update in my AndroidManifest by changing android:authorities="com.crypho.localstorage.documents" to com.12345.localstorate.documents but when I build app using cordova build android it added new instance in manifest file with existing name android:authorities="com.crypho.localstorage.documents"
Can anybody know where should I changed in the code exactly?
UPDATE:
Still not resolved the issue of provider name confict.
I resolved issue by replacing provider authorities by ${applicationID}.Provider in <provider> of that specific plugin in android.json file.
Thanks

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

White labeling with a ContentProvider

I am attempting to white label my app by changing my Android Application Project into an Android Library Project and then importing the library into a new Android Application Project.
I am running into a problem with the fact that my app (read: Library Project) contains a ContentProvider.
When I attempt to install my new Android Application Project onto an emulator, console tells me:
[2014-01-24 13:35:39 - WhitelabelTest] Installation error: INSTALL_FAILED_CONFLICTING_PROVIDER
[2014-01-24 13:35:39 - WhitelabelTest] Please check logcat output for more details.
[2014-01-24 13:35:39 - WhitelabelTest] Launch canceled!
According to the logcat:
01-24 13:38:52.217: W/PackageManager(58): Can't install because provider name com.myapp.app.db.providers.MyProvider (in package com.example.whitelabeltest) is already used by com.myapp.app
01-24 13:38:52.227: W/PackageManager(58): Package couldn't be installed in /data/app/com.example.whitelabeltest-2.apk
Does this simply mean you cannot have both applications installed on the same device because they use the same ContentProvider? Or is there a way around this? Do I need to create a new ContentProvider in my new Android Project with a new name instead?
Here is the Provider as listed in my WhitelabelTest project's Manifest:
<provider
android:name="com.myapp.app.db.providers.MessagesProvider"
android:authorities="com.myapp.app.db.providers.MessagesProvider"
android:exported="false" />
I attempted to change the name parameter with the same result.
Does this simply mean you cannot have both applications installed on the same device because they use the same ContentProvider?
You cannot have both applications installed on the same device because they both attempt to declare the same authority (in android:authorities) in a <provider>. There can only be one provider for a given authority.
This is similar to how you cannot have two apps installed with the same package.
Do I need to create a new ContentProvider in my new Android Project with a new name instead?
I'd start by considering whether a ContentProvider is necessary, and perhaps drop it if it is not.
Otherwise, the implementation of the ContentProvider can be the common one from the library project. However, the android:authorities must be unique, and therefore any clients of that ContentProvider need to know the right authority to use to reach the right provider.

Install shows error in console: INSTALL FAILED CONFLICTING PROVIDER

I am experimenting with the NotesList sample program in the Android SDK. I've made a slight variation in the program, but when I install my edited version I keep getting the message INSTALL_FAILED_CONFLICTING_PROVIDER in the console when I try to install it when the original notes program is already on the device. What do I need to change in the Provider to make it a unique database? It works fine if I uninstall the original notes program and then install my edited version.
The authority, as listed in android:authorities must be unique. Quoting the documentation for this attribute:
To avoid conflicts, authority names should use a Java-style naming convention (such as com.example.provider.cartoonprovider). Typically, it's the name of the ContentProvider subclass that implements the provider
If you have different flavors and you want to avoid collisions in the authority name you can add an applicationIdSuffix to build types and use the resulting applicationId in your manifest, like this:
<...
android:authorities="${applicationId}.contentprovider"/>
This can also happen when you have an older version of your app installed and made changes to the (support) library or the manifest file. Deleting the old applications from your device (Settings --> Application --> <your application> --> Uninstall) will solve the issue then.
If you are using Google Maps + Google Play Services inside a library project (especially if you recently migrated from Eclipse to Android Studio), you can encounter this error when you try to run an app that uses your library, while a different app that uses the same library is already installed on your device.
Fix:
make sure that defaultConfig.applicationId is defined in android section of the build.gradle file for each project using your library
android {
defaultConfig.applicationId = "com.company.appname"
}
I would recommend using the package name of the specific app. With this fix, the provider names will no longer conflict, and your app will run as expected.
Symptoms
1.) Your users are seeing the dreaded "-505" install error when installing your app from the Play Store.
2.) You will see this error message when you try to install a second app that uses your library via Android Studio [INSTALL_FAILED_CONFLICTING_PROVIDER]:
In your console, you will see a message like this:
Package couldn't be installed in /data/app/com.company.appname-1
com.android.server.pm.PackageManagerException:
Can't install because provider name
com.google.android.gms.measurement.google_measurement_service
(in package com.company.appname) is already used by
com.company.otherInstalledAppName
The fix is to make sure that defaultConfig.applicationId is defined in android section of the build.gradle file for each project using your library
android {
defaultConfig.applicationId = "com.company.appname"
}
More reading can be found here in the original bug report: Issue 784: Multiple apps using same authority provider name
If you are using the Facebook SDK then the issue might be in the "authorities" value you provide for the Facebook provider.
REPLACE -
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.FacebookContentProvider"
android:exported="true" />
WITH ->
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.FacebookContentProvider[YOUR_APP_ID]"
android:exported="true" />
You might need to change the defaultConfig.ApplicationId also as suggested in other answers.
The same error may occur after renaming packages. Check the value in string.xml for android:authorities from AndroidManifest.xml.
<provider
android:authorities="#string/content_authority"
android:name=".data.Provider"
... />
In string.xml the value should be the same as your package name, declared in manifest.
<string name="content_authority">com.whatever.android.sunshine.app</string>
Basically this happened with me, when i tried to change the package name of the app.
So, in emulator, same app was installed before. When i tried to install app after changing package name, it said, authority already used by older application in device.
Simply after uninstalling the application, it solved my problem.
Also, Authority name should always be : your.package.name.UNIQUENAME;
example :
<provider
android:name="com.aviary.android.feather.cds.AviaryCdsProvider"
android:authorities="your.package.name.AviaryCdsProvider"
/>
I have tried many solution but could not find solution... but this link helped me... I want to give detail about issue...
I was running Instrumented test cases so my app was not visible in launcher... but it was installed and thus using Same Content Provider. So, I should uninstall it somehow. So Settings -> Application Manager -> All Downloaded Apps -> uninstall all apps from your current development package
Now, try to run... This will work...
The Authority + Provider name that you have declared in the manifest probably
I had a similar problem when I used one library in several applications. It was necessary just update your AndroidManifest.xml with this exact provider declaration below.
<manifest ...>
<application ...>
<provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.here.this.library.provider" android:exported="false" android:grantUriPermissions="true" tools:replace="android:authorities">
</provider>
</application>
</manifest>
I thought uninstalling the app by dragging its icon to "Uninstall" would solve the problem, but it did not.
Here is what solved the problem:
Go to Settings
Choose Apps
Find your app (yes I was surprised to still find it here!) and press it
In the top-right, press the 3 dots
Select "Uninstall for all users"
Try again, it should work now.
Stating the obvious, but also make sure you have not silently messed up the reference to the applicationId in android:authorities.
In my case I made a typo and omitted the damn dollar sign :
android:authorities="{applicationId}.myprovider"
instead of :
android:authorities="${applicationId}.myprovider"
That did not cause any immediate error (since it is a valid authority name). But a couple days later, when I tried to install different variants of an application, it was a real pain to understand what was wrong, as the error message does not give much info about what is wrong with the content providers.
Another way to troubleshoot this is to compare your merged manifests, looking for identical authorities.
If you are using Facebook inside app check for provider tag inside AndroidManifest file and check your project Id is correct for android:authorities
<provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider112623702612345" android:exported="true" />
Encountered this issue.
Resolved it by:
1 - open AndroidManifest.xml
2 - ctrl+f find "provider"
3 - find provider and update your root directory name there.
run project. hopefully issue will be fixed!
If you are using the emulator, you may try the following. The below worked for me.
Go to Tools --> AVD Manager --> (Pick Your emulator) --> Wipe Data.
The error went away.
install using adb with command ./adb install -r abc.apk will solve the problem (it will overwrite even when the device has higher app version)
i had this problem :
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER
but it was not from provider of manifest
the below library in my app has conflict with other app and the others can not be install:
implementation 'com.iceteck.silicompressorr:silicompressor:2.2.1'
I´ve got this error, when implementing an library with following AndroidmManifest.xml
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="library.path.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths"/>
</provider>
I solved this when i put following Code in Project AndroidManifest.xml (app/src/main):
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
</provider>
Yeah! I have the same problem as you。As you said,you use "variation". keep the "authorities" unique, you can write as this
android:authorities="${applicationId}.provider"
if you have a lib use in an app more than one,The same reason as above.
If you are on Xamarin and you get this error (probably because of Firebase.Crashlytics):
INSTALL_FAILED_CONFLICTING_PROVIDER
Package couldn't be installed in [...]
Can't install because provider name dollar_openBracket_applicationId_closeBracket (in package [...]]) is already used by [...]
As mentioned here, you need to update Xamarin.Build.Download:
Update the Xamarin.Build.Download Nuget Package to 0.4.12-preview3
On Mac, you may need to check Show pre-release packages in the Add Packages window
Close Visual Studio
Delete all cached locations of NuGet Packages:
On Windows, open Visual Studio but not the solution:
Tools -> Option -> Nuget Package Manager -> General -> Clear All Nuget Cache(s)
On Mac, wipe the following folders:
~/.local/share/NuGet
~/.nuget/packages
packages folder in solution
Delete bin/obj folders in solution
Load the Solution
Restore Nuget Packages for the Solution (should run automatically)
Rebuild
You can uninstall package name "com.example" from the device in which you run the app after than you run the app . This worked for me
It helped me: Go AndroidManifest and paste or replace with this code
<provider
android:authorities="${applicationId}.here.this.library.provider"
android:name="androidx.core.content.FileProvider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities" >
</provider>
if your are using provider check and do it by following method
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="androidx.multidex.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_path" />
</provider>
or use it
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.contentprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_path" />
</provider>
also if the applciation already exits in your mobile uninstall and then check
In my android device I had different flavors of the same app install. This gives me error INSTALL FAILED CONFLICTING PROVIDER.
so I uninstall my all flavors of the same app.
and tried
adb install -r /Users/demo-debug-92acfc5.apk
It solved my problem.
need to use android:name="androidx.core.content.contentprovider
or android:name="androidx.core.content.provider insteadof
android:name="androidx.core.content.fileprovider
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.contentprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/filepaths" />
</provider>
Solution 1
Run the app on a physical device instead of the emulator. I encountered this issue and my app didnt have a content provider defined.
Solution 2
In the other instance, i had an instrumented test app installed matching the same applicationId.
To fix the issue i had to run ./gradlew uA - uA short for uninstallAll task.
You can alternatively use the Gradle panel and choose navigate to app\install\uninstallAll task
If you using an emulator, you can wipe out the data
If you are using Audience Network Content Provider you need to add this code in your app AndroidManifest.xml
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider165632208074623"
android:exported="true" />
Your Facebook app id ---> 165632208074623
If you only need to use facebook for sign in to your app here is a tip:
(this fix worked in cordova project)
Step 1 and 2 must be completed to fix the problem.
1.
locate the file: platform/android/android.json
inside that file:
remove this code:
,{"xml": "<provider android:authorities=\"com.facebook.app.FacebookContentProvider<FACEBOOK_APP_ID>\" android:exported=\"true\" android:name=\"com.facebook.FacebookContentProvider\" />","count": 1
}
Then locate file: platforms/android/app/src/main/androidManifest.xml
remove this code:
<provider android:authorities="com.facebook.app.FacebookContentProvider<FACEBOOK_APP_ID>" android:exported="true" android:name="com.facebook.FacebookContentProvider" />
Now the application can run fine..
Im sorry if this answer is not relevant for the OP, but it may help many others that have this problem. I could not find this exact answer anywhere else.
I tried many solutions but couldn't find a solution:
I changed this in AndroidManifest
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.com.shareFile"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths" />
</provider>
Make the authorities changes as said by #Jose L Ugia.
(You can find the provider in the manifest(merge manifest))
Mostly it will be connected to an SDK that you implemented, So remove the SDK implementation line and sync the Gradle, and then again add the implement line and sync the Gradle.
The implementation line:
implementation files(<your SDK>)
Provider code: (you have to scroll down in merge-manifest to find it )

Categories

Resources