firebase / firebase-unity-sdk

The Firebase SDK for Unity
http://firebase.google.com
Apache License 2.0
215 stars 35 forks source link

[Bug] Failed to transform jetified-play-services-measurement-api-21.6.2-runtime.jar to match attributes {artifactType=ext-dex-dexBuilderRelease, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. #1073

Closed shuaigedev closed 1 week ago

shuaigedev commented 1 month ago

Description

Minimum API Level : Android 5.1 Target API:Level API Level 34 image

ERROR:D8: com.android.tools.r8.kotlin.H

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

2: Task failed with an exception.

BUILD FAILED in 24s

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:203)

Reproducing the issue

最低API级别:Android 5.1最低API级别:Android 5.1目标API:级别API级别34![图像](https://github.com/user-attachments/assets/775f31d1-afeb-4fdb-a735-54127fa18d95)目标API:级别API级别34![图像](https://github.com/user-attachments/assets/775f31d1-afeb-4fdb-a735-54127fa18d95

use this seeting build android apk

Firebase Unity SDK Version

11.9.0 and 12.1.0

Unity editor version

2022.3.38f1

Installation Method

.unitypackage

Problematic Firebase Component(s)

Analytics

Other Firebase Component(s) in use

Analytics

Additional SDKs you are using

No response

Targeted Platform(s)

Android

Unity editor platform

Mac

Scripting Runtime

IL2CPP

Release Distribution Type

Pre-built SDK from https://firebase.google.com/download/unity

Relevant Log Output

No response

If using CocoaPods for Apple platforms, the project's Podfile.lock

Expand Podfile.lock snippet
```yml 👀 Replace this line with the contents of your Podfile.lock! ```
google-oss-bot commented 1 month ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

zudl commented 1 month ago

I can confirm, the same thing happens to me, but the error is slightly different.

-----------
* What went wrong:
Execution failed for task ':launcher:dexBuilderRelease'.
> Could not resolve all files for configuration ':launcher:detachedConfiguration4'.
   > Failed to transform jetified-play-services-measurement-api-22.0.2-runtime.jar to match attributes {artifactType=ext-dex-dexBuilderRelease, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for DexingExternalLibArtifactTransform: /Users/needle/.gradle/caches/transforms-3/64b0c7447f3c6bbe741650ffe23d8c98/transformed/jetified-play-services-measurement-api-22.0.2-runtime.jar.
         > Error while dexing.

It is impossible to build directly from Unity. However, if you bypass this and build through the Gradle project and Android Studio, everything works without any issues.

Unity 2022.3.38f1 API Level 34 Firebase RemoteConfig + Analytics 12.1.0 Mac IL2CPP

Not reproducible in Unity 2022.3.37

AgentSamad commented 1 month ago

Same thing happpen to me Unity Version : 2022.3.38f1 target Sdk Verion 34

Working fine until i import firebase (tried both versions 12.1 & 11.9

nghuuhieu1994 commented 1 month ago

Bump the AndroidMinSdkVersion from 23 to 24 to temporarily fix the issue.

argzdev commented 1 month ago

Hey folks, could you try the solution provided here:

Export the Unity project to Android Studio, change Gradle and AGP version to 8+. (This page says Android 34 requires AGP 8.1.1+). Change min SDK from 23 to 24.

So far when testing with our Firebase Analytics from the Unity Quickstart, it works correctly with Android 14 emulator.

kevin-redcellgames commented 1 month ago

Changing the minimum SDK to 24 did resolve the issue for us. That solution is undesirable but probably unavoidable.

kevin-redcellgames commented 1 month ago

We've also been able to make a build with minsdk=22 by changing the android gradle plugin versions in baseProjectTemplate.gradle

// Old
// id 'com.android.application' version '7.4.2' apply false
// id 'com.android.library' version '7.4.2' apply false

// New
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false

Don't know what the repercussions of this change are yet, though.

hoanganhnh2009 commented 1 month ago

Bump the AndroidMinSdkVersion from 23 to 24 to temporarily fix the issue.

It work with me. tks

argzdev commented 1 week ago

Closing this thread as this has been resolved. For folks who would like to maintain using version 22. We've discussed a few possible solutions here. Feel free to check it out. Thanks!