RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
236 stars 28 forks source link

Duplicate Guava with Firebase Analytics Issue #1525

Closed Negatives-One closed 1 year ago

Negatives-One commented 1 year ago

Describe the issue It is impossible to generate an android build with AVPro Video and Firebase Analytics in the same project. A duplicate classes error occurs, and when I delete the guava-31.1-android from AVPro, the build works, but the videos do not play. What is the best way to deal with this problem?

Your Setup (please complete the following information):

To Reproduce

  1. Install AVPro Video Package
  2. Install Firebase Analytics Package
  3. Try to build for Android

Screenshots

image

image

Chris-RH commented 1 year ago

add this to your gradle:

implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

Negatives-One commented 1 year ago

This doesn't work in my case, I already tried all related troubleshooting from Issues section.

I've tried all these solutions too

https://stackoverflow.com/questions/56639529/duplicate-class-com-google-common-util-concurrent-listenablefuture-found-in-modu

Nothing solves my problem so far.

Chris-RH commented 1 year ago

OK, how does your gradle look?

Negatives-One commented 1 year ago

Gradle:

allprojects {
    buildscript {
        repositories {
            google()
            jcenter()
        }

        dependencies {
            // If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
            // See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
            // See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
            // To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
            classpath 'com.android.tools.build:gradle:4.0.1'

        }
    }

    repositories {
        google()
        jcenter()
        flatDir {
            dirs "${project(':unityLibrary').projectDir}/libs"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Negatives-One commented 1 year ago

Main Template:

apply plugin: 'com.android.library'
**APPLY_PLUGINS**

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
**DEPS**}

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 {
        noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }**PACKAGING_OPTIONS**
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
Chris-RH commented 1 year ago

and adding this as suggested?

implementation 'com.google.guava:guava:31.1-android'

Negatives-One commented 1 year ago

This results in the same error

Trying combinations of gradle implementation and with or without AVPRO guava file, nothing works as it should.

I can only actually build without the gradle implementation lines and without the AVPRO guava file

Chris-RH commented 1 year ago

OK, well this does seem to be a common problem and there seem to be a few solutions that I have found online. I'll list a few suggestions. The fix can be a bit of a lottery based on which version is used by the other asset, and which one is loaded first. I'm afraid its just a case of trial and error. Please let me know if any of these work for you. More info: https://blog.gradle.org/guava

Delete AVProVideo\Runtime\Plugins\Android\guava-27.1-android.jar.

Player Settings -> Publishing Settings -> Build -> Custom Main Gradle Templete Checked.

Edit the Assets\Plugins\Android\mainTemplate.gradle file and modify dependencies to:

Code (JavaScript):

dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation("com.google.guava:guava:31.0.1-android") DEPS} Continue to compile, if the compilation reports an error, restart Unity and try again.

. We just found a similar way to do this, but using Google's External Dependency Manager for Unity. Noting it here for other devs:

added a file Asets/AVProVideo/AVProDependencies.xml with

Changed Minimum API Level to Android 5.0

Open build.gradle file.

Do Not replace! Just add this line into dependencies{}:

implementation 'com.google.guava:guava:-jre' Note: To get the version go to https://mvnrepository.com/artifact/com.google.guava/guava and find for the latest version of jre.

add these two implementations to your app level build.gradle / app/build.gradle

implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0' implementation 'com.google.guava:guava:27.0.1-android'

For me, nothing worked. The only thing that fixed it magically was to update the desugaring library to the matching for my AGP version:

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.0'

Negatives-One commented 1 year ago

None of these solutions work for me, I always have to choose which one will work, whether it's going to be AVPRO or Firebase Analytics, both together seem to be impossible.

Is there any alternative solution? perhaps replace AVPRO's guava-31.1-android.jar with something else?

Chris-RH commented 1 year ago

Its a requirement of Exoplayer, so our hands are tied there. They might be able to provide some more suggestions perhaps?

Negatives-One commented 1 year ago

Could you try building on a specific project?

It's just an empty project with AVPRO and Firebase Analytics, which email could I send it to?

Chris-RH commented 1 year ago

unitysupport@renderheads.com

Negatives-One commented 1 year ago

I sent an email, with a test project, as I mentioned before. I await your reply with the result. Thanks

Paulo-Aragao commented 1 year ago

I have the same problem!

Chris-RH commented 1 year ago

@Paulo-Aragao, Have you tried all of the above things that have worked for other people?

Chris-RH commented 1 year ago

@Ste-RH - long term would it be possible to rename exoplayer guava files and references to those (similarly to how we did with exoplayer itself)?

Paulo-Aragao commented 1 year ago

yes, but without success at all

TheCollectorOfSouls commented 1 year ago

Seems like it is impossible to build for android with Firebase 1.0.7 and avpro 2.7.3. I'm trying it in a empty project with unity 2021.3.15f1

Negatives-One commented 1 year ago

@Chris-RH Do you see any possible solution? this asset was expensive, and I need to make it work together with firebase

joangoal8 commented 1 year ago

I have the same issue without any luck @Chris-RH

Chris-RH commented 1 year ago

Have you tried the adapting the solution at the bottom of this: https://stackoverflow.com/questions/61480581/duplicate-class-found-in-modules-guava-26-0-android-jar-and-guava-jdk5-17-0-jar They post a git link to their gradle.

Negatives-One commented 1 year ago

I updated firebase package to version 11.0.0, added "implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'" in custom gradle and deleted "app-1.8. 7-unity-support.aar".

This so far has solved my problem.

ParkJongKyung commented 1 year ago

@Negatives-One I added the 11.0.0 version package, but "app-1.8.7-unity-support.aar" is not visible. Where is "app-1.8.7-unity-support.aar"?

Chris-RH commented 1 year ago

@Negatives-One, Thank you. It seems to be very hit and miss as to what actually solves the issue for an individual project. What made you try deleting "app-1.8. 7-unity-support.aar" ?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jpc1601 commented 7 months ago

1 Uncheck the android under select platform for the plugin as marked in the attached screenshot.

It worked for me.

ethanPDK commented 5 months ago

1 Uncheck the android under select platform for the plugin as marked in the attached screenshot.

It worked for me.

This will work for me but, if I setup the media player to EXO Player on android, the the app will crash. Is there a known solution for this error? Im trying to build for Android Cardboard. Thanks