Home>

I used my own Android plugin in Unity, but when I installed GooglePlayGamesPlugin, I couldn't build it.
If i delete your own plugin and use only GooglePlayGamesPlugin, the build will pass. On the other hand, if you only build your own build, the build will not work.

CommandInvokationFailure: Gradle build failed.
C:/Program Files/Unity/Hub/Editor/2019.4.15f1/Editor/Data/PlaybackEngines/AndroidPlayer \ OpenJDK \ bin \ java.exe -classpath "C: \ Program Files \ Unity \ Hub \ Editor \ 2019.4.15f1 \ Editor \ Data \ PlaybackEngines \ AndroidPlayer \ Tools \ gradle \ lib \ gradle-launcher-5.1.1.jar "org.gradle.launcher.GradleMain"-Dorg.gradle.jvmargs = -Xmx4096m "" assembleRelease "
stderr [
Note: C: \ Users \ jwin \ Documents \ Alarm \ Temp \ gradleOut \ unityLibrary \ src \ main \ java \ com \ unity3d \ player \ UnityPlayerActivity.java uses or overrides the deprecated API.
Note: For more information, recompile with the -Xlint: deprecation option.
D8: Program type already present: com.unity3d.player.UnityPlayer $18
FAILURE: Build failed with an exception.
Source code

Library dependencies (alarmplugin-debug is your own plugin)

releaseRuntimeClasspath --Resolved configuration for runtime for variant: release
+ ---: alarmplugin-debug
+ ---: androidx.arch.core.core-runtime-2.0.0
+ ---: androidx.asynclayoutinflater.asynclayoutinflater-1.0.0
+ ---: androidx.coordinatorlayout.coordinatorlayout-1.0.0
+ ---: androidx.core.core-1.0.0
+ ---: androidx.cursoradapter.cursoradapter-1.0.0
+ ---: androidx.customview.customview-1.0.0
+ ---: androidx.documentfile.documentfile-1.0.0
+ ---: androidx.drawerlayout.drawerlayout-1.0.0
+ ---: androidx.fragment.fragment-1.0.0
+ ---: androidx.interpolator.interpolator-1.0.0
+ ---: androidx.legacy.legacy-support-core-ui-1.0.0
+ ---: androidx.legacy.legacy-support-core-utils-1.0.0
+ ---: androidx.lifecycle.lifecycle-livedata-2.0.0
+ ---: androidx.lifecycle.lifecycle-livedata-core-2.0.0
+ ---: androidx.lifecycle.lifecycle-runtime-2.0.0
+ ---: androidx.lifecycle.lifecycle-viewmodel-2.0.0
+ ---: androidx.loader.loader-1.0.0
+ ---: androidx.localbroadcastmanager.localbroadcastmanager-1.0.0
+ ---: androidx.print.print-1.0.0
+ ---: androidx.slidingpanelayout.slidingpanelayout-1.0.0
+ ---: androidx.swiperefreshlayout.swiperefreshlayout-1.0.0
+ ---: androidx.versionedparcelable.versionedparcelable-1.0.0
+ ---: androidx.viewpager.viewpager-1.0.0
+ ---: com.google.android.gms.play-services-auth-18.1.0
+ ---: com.google.android.gms.play-services-auth-api-phone-17.0.0
+ ---: com.google.android.gms.play-services-auth-base-17.0.0
+ ---: com.google.android.gms.play-services-base-17.1.0
+ ---: com.google.android.gms.play-services-basement-17.1.1
+ ---: com.google.android.gms.play-services-drive-17.0.0
+ ---: com.google.android.gms.play-services-games-20.0.1
+ ---: com.google.android.gms.play-services-nearby-17.0.0
+ ---: com.google.android.gms.play-services-tasks-17.0.0
+ ---: com.google.games.gpgs-plugin-support-0.10.11
+ ---: UnityAds
+ ---: UnityAdsAndroidPlugin
+ --- project: unityLibrary: GooglePlayGamesManifest.plugin
\ --- project: unityLibrary: unity-android-resources
What I tried
  • Added ndk.abiFilters to build.gradle on the plugin side to support ARM64.
  • I tried to reverse the import order of my own plug-in and Google Play Service.
  • I tried using Unity's Custom Main Gradle Template.
Supplementary information

Unity 2019.4.15f1

Android Studio 4.0.1
SDK Platfrom 16 --29
NDK 21.3.6528147

GooglePlayGamesPlugin-0.10.11
external-dependency-manager-1.2.156

I tried various things, but none of them succeeded.
Please give me a professor.

  • Answer # 1

    Was self resolved.

    Build.gradle of my own plugin

    Before correction

    dependencies {
        implementation files ('classes.jar full path')
        compileOnly fileTree (dir:'libs', include: ['* .jar'])
        implementation'androidx.core: core: 1.3.2'
        implementation'androidx.appcompat: appcompat: 1.2.0'
    }


    Revised

    dependencies {
        compileOnly fileTree (dir:'libs', include: ['* .jar'], exclude: ['classes.jar'])
        compileOnly files ('libs/classes.jar')
        compileOnly'androidx.core: core: 1.3.2'
        compileOnly'androidx.appcompat: appcompat: 1.2.0'
    }

    I wrote it like this, created aar, and imported it into Unity to build it.

    After that, the plugin didn't work due to java.lang.ClassNotFoundException, so

    https://www.hirohomme.com/2019/05/25/unity-%E3%81%AB-admob-%E5%AE%9F%E8%A3%85%E3%81%97%E3%81% 9F% E6% 99% 82% E3% 80% 81proguard-% E3% 82% 84-minify-% E3% 82% 92% E7% 84% A1% E5% 8A% B9% E3% 81% AB% E3% 81% 9B% E3% 81% 9A% E3% 81% AB-release% E3% 83% 93% E3% 83% AB% E3% 83% 89 /

    By referring to this article, I created proguard-user.txt and was able to operate it safely.