Open AAulicino opened 4 years ago
HI @KylinChang , are there any updates on this?
We are not able to build the project on Unity 2019.3. On Android because of this issue, and on iOS, because of #359.
Hey @mcrvaz , can you try v7.18.1?
Facing same issue with Facebook SDK v7.18.1 as well.
Facing the same issue with Facebook SDK v7.18.1. Our game can't build right now. Firebase or Facebook temporary disable.
@kashiftasneempro did you delete the old plugin first?
@kashiftasneempro did you delete the old plugin first?
Yes, I did.
I am running into the same problem, has anyone make any progress on this? Seems like a androidx vs support library conflict?
Actually: I haven't test this fully yet, but removing
implementation(name: 'com.android.support.support-compat-27.0.2', ext:'aar')
From build.gradle gets me building apk's again. Gonna do some testing to see if anything is broken though.
Update 1: Looks like things are working on my end, Facebook still works and i'm getting Firebase push token initialization correctly.
Update 2: I forgot to mention I also have to remove a line in the Firebase AndroidManifest file the one that is uses-sdk ... 14 When removing those two lines, everything is working great. i've been able to test everything related to my use cases. Hopefully this helps others.
Actually: I haven't test this fully yet, but removing
implementation(name: 'com.android.support.support-compat-27.0.2', ext:'aar')
From build.gradle gets me building apk's again. Gonna do some testing to see if anything is broken though.
Update 1: Looks like things are working on my end, Facebook still works and i'm getting Firebase push token initialization correctly.
Update 2: I forgot to mention I also have to remove a line in the Firebase AndroidManifest file the one that is uses-sdk ... 14 When removing those two lines, everything is working great. i've been able to test everything related to my use cases. Hopefully this helps others.
Are you working in Unity?
Unity has mainTemplate.gradle not build.gradle.
Yes this is Unity, instead of building the apk/aab from the editor, I export to Android Studio so I can work through dependencies. It helps a lot when debugging things like this.
Hi @ncinoadam , which Firebase modules are you using? Just push notifications?
@ncinoadam @kashiftasneempro I managed to solve this by enabling Jetifier and modifying the mainTemplate.gradle file like this:
dependencies {
implementation 'androidx.multidex:multidex:2.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
implementation 'androidx.appcompat:appcompat:1.0.0'
// Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'androidx.cardview:cardview:1.0.0'
// Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'androidx.cardview:cardview:1.0.0'
// Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'androidx.browser:browser:1.0.0'
// Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:6
...
Hi @ncinoadam , which Firebase modules are you using? Just push notifications?
I'm currently just using the Messaging module, but it wouldn't be hard to figure out the conflicts and fix them for others as well.
The problem can be solved by exporting project and build with Android Studio, then migrate with AndroidX by replacing almost old dependencies following @hex mentioned. But that it's not the way it supposed to be, the conflicts now go around package still using old dependencies while AndroidX is enabled after Force Resolve, so hope there is a fix available or official way to build without Exporting project.
Actually: I haven't test this fully yet, but removing
implementation(name: 'com.android.support.support-compat-27.0.2', ext:'aar')
From build.gradle gets me building apk's again. Gonna do some testing to see if anything is broken though.
Update 1: Looks like things are working on my end, Facebook still works and i'm getting Firebase push token initialization correctly.
Update 2: I forgot to mention I also have to remove a line in the Firebase AndroidManifest file the one that is uses-sdk ... 14 When removing those two lines, everything is working great. i've been able to test everything related to my use cases. Hopefully this helps others.
Thanks @ncinoadam, this worked for me using the analytics module.
I agree with @GunLengend, it is a hack to have to mess with files in Android Studio and it should be handled inside Unity without the need to export every time you want build
EDIT: I also want to mention that this problem had nothing to do with the Facebook SDK as I don't have it in my project. I opened an issue here (https://github.com/firebase/quickstart-unity/issues/607) because I had pretty much the same Unity logs output and fixed the issue with what @ncinoadam mentioned, so this seems to be more of a Firebase thing
What I'm considering right now it's not only Facebook and Firebase issue, but also it can belong to Unity itself. Because enableJetifier and useAndroidX were enabled in Unity mainTemplate.gradle file but when Unity starts the build process, the Jetifier doesn't do its job, it should be migrating all old dependencies to force use AndroidX, but it isn't, and Android Studio can do that trick.
What I'm considering right now it's not only Facebook and Firebase issue, but also it can belong to Unity itself. Because enableJetifier and useAndroidX were enabled in Unity mainTemplate.gradle file but when Unity starts the build process, the Jetifier doesn't do its job, it should be migrating all old dependencies to force use AndroidX, but it isn't, and Android Studio can do that trick.
After upgrading to the newest version of Unity, Facebook SDK, Firebase SDK all Android build issues have gone away. Now I'm battling with iOS in Xcode, but it is unrelated to this SDK.
EDIT: This could be because I had Firebase Analytics enabled previously and now I do not. I wasn't using Facebook SDK when I first got the issue, it was an issue with Mapbox SDK which and it seems they redistribute java libraries instead of updating to Android resolver. I got rid of Mapbox and started using Google maps, so good there, but then I introduced an older version of the Facebook SDK because the documentation of one of my assets requests the older version and I had multiple duplicate classes when introducing it. So I got the new Facebook SDK and I had to adjust the code in the asset that required the older version. Currently I just have Firebase Authentication working, but it still seems to be utilizing androidx.core.core-1.0.0 and that was where most of the duplicate classes were for me. Hopefully this helps
I have same conflict when adding FB to my project where I have AdMob
Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
After adding suggested
tools:replace="android:appComponentFactory" android:appComponentFactory="whateverString"
I am getting
java.lang.RuntimeException: Duplicate class android.support.customtabs.ICustomTabsCallback found in modules classes.jar (androidx.browser:browser:1.0.0) and classes.jar (com.android.support:customtabs:28.0.0)
And more ... I have newest versions of all SDKs and Unity.
I don't know why you gave me a thumbs down and furthermore why I want to help you after doing so, but I suggest that you delete the com.android.support:customtabs:28.0.0, usually stored at Assets/Plugins/Android/ and see if that fixes your problem.
Problem is that I am using mainTemplate.gradle
instead of having tons of libs in Assets/Plugins/Android/ folder. (have limited space in repository).
I did remove all implementation 'com.android.support.XXXX'
from it and still have the same problem.
You got thumbs down because Your solution is not for me, When Admin is reading such post like yours, He can close this issue because he will assume that everything is done, when it is NOT.
I am supporting lot of projects and solutions like: Export to Android Studio
orremove library
with is not existing in my project is not a solution.
Good luck bud
What I'm considering right now it's not only Facebook and Firebase issue, but also it can belong to Unity itself. Because enableJetifier and useAndroidX were enabled in Unity mainTemplate.gradle file but when Unity starts the build process, the Jetifier doesn't do its job, it should be migrating all old dependencies to force use AndroidX, but it isn't, and Android Studio can do that trick.
The problem is both a Google/Unity problem and a Facebook problem. Facebook needs to upgrade their SDK to use AndroidX, pure and simple and this problem goes away. Google/Unity have developed their own version of Jetifier that runs within Unity to patch the problem until companies like Facebook fix it, but Unity's Jetifier doesn't work with the Facebook SDK!
Luckily, Android Studio's Jetifier works fine... and that's literally the only solution to running a Unity game with Facebook SDK and any other library that uses AndroidX.
I had the same issue and switch to v7.19.2 from V7.16 which fixed the issue for me.
@LunarInteractiveArts I tried 7.19.2 but it didn't work, sadly. However, there's a solution posted on this bug: https://github.com/googlesamples/unity-jar-resolver/issues/360 that does work!
@doom-goober I did try this and it not working or me. Code looks similar to this what Google dependencies resolver is generating:
Looks like I've found the fix in OneSignal help section. Fix is for Unity ofc. https://documentation.onesignal.com/docs/troubleshooting-unity#section-android-x-compatibility
I solved it in two steps for Unity 2019.3.11f1:
Edit
->Project Settings
->Player
->Publishing settings
->Tick Custom Properties Gradle Template
gradleTemplate.properties
and add these lines to the top:
android.useAndroidX=true
android.enableJetifier=true
In Unity 2019.2.21, the duplicate class errors are still there even with jetfiier enabled like below
([rootProject] + (rootProject.subprojects as List)).each { ext { it.setProperty("android.useAndroidX", true) it.setProperty("android.enableJetifier", true) } }
@jackatfp Did you try @gromilQaaaa 's solution? Here's a direct link to the section of the document that got my build working from Unity again: https://documentation.onesignal.com/docs/troubleshooting-unity#unity-20193-or-newer
It's the section where you have to add a file called Assets/Plugins/Android/settingsTemplate.gradle.
This problem frustrated me to no end and I was about resolve myself to building from Android Studio. Only this solution worked consistently for me (I thought the previous one worked but it stopped working for me when I added some other plugins back into my project.) And logically it made some sense: The gradle system was clearly not picking up the jetifier from Unity's post processor and settings but clearly the jetifier was working because it worked in Android Studio which uses gradle. So, a solution that's gradle based seems to make sense.
Anyways it worked for me and I was so annoyed and delighted to find a solution I hope it works for you. Please give it a try! Good luck.
You're right that it wasn't picking up the jetifier in that case, but you don't need to use the OneSignal solution anymore.
Using newest 2019.3 official version (mine is 2019.3.12f1 atm) you can just use Custom Gradle Properties Template on top of the Main Gradle Template, and add:
android.useAndroidX=true
android.enableJetifier=true
to the newly generated gradleTemplate.properties file.
I have been exporting to Android studio to build with all the SDKs my publisher wants and working through the miseries of Android build errors ever since, as a junior dev I think I encountered every issue, but now I can finally build from within Unity. Jetifier wasn't working with Facebook SDK properly except in Android studio, so if you used enough AndroidX migrated plugins it would be hard to build from within Unity without some hacky changes.
I also usually have to change Plugins/Android/AndroidManifest.xml to have this in application tag:
tools:replace="android:appComponentFactory" android:appComponentFactory="leavemealone"
also xmlns:tools="http://schemas.android.com/tools"
in manifest tag
Yes, it's a random string as I'm not sure what the purpose of this is but it works and fixes my manifest merger build error, oh well.
I can now build with Ironsource (many adapters with it), Facebook SDK, GameAnalytics, Adjust, Firebase, whatever else. Basically just get latest Unity Jar Resolver, check settings remove auto resolve, remove resolve on build, set patch maintemplate and use jetifier to true, force resolve, add any extra dependencies/repos you want, do the gradleproperties trick, build within Unity, done.
@doom-goober yes, we tried everything include the solution you mentioned but still doesn't work
@doom-goober yes, we tried everything include the solution you mentioned but still doesn't work
Did you try the @ruslanmamonov option?
This is also happening to me. I have tried all of the solutions above with no success. Facebook SDK is injecting old dependencies that clash with androidX and EDM4U is not able to solve them.
Example below:
implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency implementation 'com.android.support:cardview-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency implementation 'com.android.support:cardview-v7:26.0.2' // Assets/Packages/XXX.CustomerSupport/Helpshift/Editor/HelpshiftDependencies.xml:9
Facebook added cardview and another local plugin added it also. Jetifier seems to do nothing. The fix suggested by OneSignal also doesn't solve this issue.
Yeah I've resorted to making my own custom version of the Facebook.Unity.Editor.dll so that it doesn't inject the conflicting implementations. But wow, it was not easy to build the facebook SDK... but worked out in the end :)
I'm struggling with the same issue, however duplicated class is different:
java.lang.RuntimeException: Duplicate class androidx.vectordrawable.graphics.drawable.Animatable2Compat found in modules classes.jar (:vectordrawable-animated-1.0.0:) and classes.jar (androidx.vectordrawable:vectordrawable-animated:1.1.0)
Facebook doesn't seem to be importing this library.
I've tried jetifier tricks, I've tried creating mainTemplate.gradle, including androidx counterparts of legacy libraries, even including vectordrawable library, yet still I'm always getting the same error.
mainTemplate.gradle looks like this:
// Android Resolver Repos Start
([rootProject] + (rootProject.subprojects as List)).each {
ext {
it.setProperty("android.useAndroidX", true)
it.setProperty("android.enableJetifier", true)
}
}
([rootProject] + (rootProject.subprojects as List)).each { project ->
project.repositories {
def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
maven {
url "https://maven.google.com"
}
maven {
url (unityProjectPath + "/Assets/GeneratedLocalRepo/Firebase/m2repository") // Assets/Firebase/Editor/AnalyticsDependencies.xml:18, Assets/Firebase/Editor/AppDependencies.xml:22, Assets/Firebase/Editor/AuthDependencies.xml:20, Assets/Firebase/Editor/MessagingDependencies.xml:20
}
mavenLocal()
jcenter()
mavenCentral()
}
}
// Android Resolver Repos End
apply plugin: 'com.android.library'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
//implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:cardview-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:support-v4:27.1+' // Assets/Editor/VoxelBusters/NativePlugins/NPDependencies.xml:6
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
implementation 'com.facebook.android:facebook-applinks:[8.0, 9)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:6
implementation 'com.facebook.android:facebook-core:[8.0, 9)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:5
implementation 'com.facebook.android:facebook-gamingservices:[8.0, 9)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:9
implementation 'com.facebook.android:facebook-login:[8.0, 9)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:7
implementation 'com.facebook.android:facebook-share:[8.0, 9)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:8
implementation 'com.google.android.gms:play-services-base:17.4.0' // Assets/Firebase/Editor/AppDependencies.xml:17
implementation 'com.google.firebase:firebase-analytics:17.5.0' // Assets/Firebase/Editor/MessagingDependencies.xml:15
implementation 'com.google.firebase:firebase-analytics-unity:6.16.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
implementation 'com.google.firebase:firebase-app-unity:6.16.0' // Assets/Firebase/Editor/AppDependencies.xml:22
implementation 'com.google.firebase:firebase-auth:19.3.2' // Assets/Firebase/Editor/AuthDependencies.xml:13
implementation 'com.google.firebase:firebase-auth-unity:6.16.0' // Assets/Firebase/Editor/AuthDependencies.xml:20
implementation 'com.google.firebase:firebase-common:19.3.1' // Assets/Firebase/Editor/AppDependencies.xml:13
implementation 'com.google.firebase:firebase-messaging:20.2.4' // Assets/Firebase/Editor/MessagingDependencies.xml:13
implementation 'com.google.firebase:firebase-messaging-unity:6.16.0' // Assets/Firebase/Editor/MessagingDependencies.xml:20
implementation 'com.parse.bolts:bolts-android:1.4.0' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:4
// Android Resolver Dependencies End
**DEPS**}
// Android Resolver Exclusions Start
android {
packagingOptions {
exclude ('/lib/armeabi/*' + '*')
exclude ('/lib/mips/*' + '*')
exclude ('/lib/mips64/*' + '*')
exclude ('/lib/x86/*' + '*')
exclude ('/lib/x86_64/*' + '*')
}
}
// Android Resolver Exclusions End
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}
lintOptions {
abortOnError false
}
aaptOptions {
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}**REPOSITORIES****SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
Other ideas what can be done? I've basically just added facebook sdk to my project and got this error right from the start.
I have latest jar resolver, facebook sdk and firebase sdk.
I'm still using same method I suggested above (god bless gradle properties) and never had issues since, only things that have changed is that I stopped using Unity's Android SDK and downloaded it myself and changed the path to it in preference, to be able to set the target to api 30 a bit more peacefully. That shouldn't affect much though. Main thing is having EDM settings use jetifier, mainTemplate patching, and force resolving before you build (if you prefer not to have auto resolve on like me). In publishing settings I use custom gradle properties, main template, custom android manifest (i dont really touch main template or the android manifest anymore, I let them be filled by edm and facebook menu edit settings' "regenerate android manifest". If you get duplicate class error with all that being done, then you probably have extra ones in your project that you should remove. If using Adjust for instance you might resolve install referrer and still have another one in your project Plugins folder sitting there that u should delete, but yeah, most of the time if you use the settings I suggested all of these issues simply.. fade away.
TL;DR: Custom Gradle Properties Template, and add:
android.useAndroidX=true
android.enableJetifier=true
Custom Main Template, let EDM4U patch it, Jetifier on, Force resolve before build Custom Main Manifest, let Facebook Regenerate Manifest from its menu Edit Settings thingy, also make sure there are no errors there like PATH or whatever annoying thing facebook has I promise you you can build with a million sdks as I do daily, and I'm just a random junior game developer who went through this stuff a bit too much and resorted to Android Studio until custom gradle properties came out
Okay, so finally I've found an issue - I had vectordrawable aar file floating around in files - this was causing the issue. Not sure which library copied it, but I've removed this file and all errors went away. Thanks for the hints anyway :)
@mohamad-al-amaary Could you help me too? I have multiple SDKs implemented (admob, facebook, firebase, etc) and it all builds fine. But when I add a custom plugin (https://assetstore.unity.com/packages/tools/integration/android-install-referrer-179422) I get this error while building: https://pastebin.com/6eRHyi7a
Has somebody found a solution? I have reached to the same error, and while tracking down the issue looks like Firebase SDK uses a newer version of the InstallReferrer lib (2.2) while Facebook SDK stills uses 1.0.
I copy the dependecy tree I got from gradle for further reference
Same problem in 2024
Checklist
Environment
2019.3.0f6
7.18.0
and7.18.1
[Android]
versionany
Goals
Build the project
Expected Results
Project is successfully built
Actual Results
Project is failing to build with the following output:
Steps to Reproduce
OR
Code Samples & Details
If I build with just Facebook SDK, it works. If I build with just Firebase SDK, it works. If I build with both Facebook SDK and Firebase SDK, it fails.
I made a Repro project following the steps I mentioned before. https://drive.google.com/file/d/1ngzavtEftODND1EpRyNchq3qClpyXl0C/view?usp=sharing