Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Namespace not specified in unityLibrary:FirebaseApp.androidlib build.gradle #1077

Closed
NudeNULL opened this issue Jul 26, 2024 · 9 comments
Labels

Comments

@NudeNULL
Copy link

Description

I expected the Unity project to build in Android Studio without issues

The actual result is that the project builds with this error:
What went wrong:
A problem occurred configuring project ':unityLibrary:FirebaseApp.androidlib'.

Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

Reproducing the issue

We had to increase the target api level to 34 and respectevily the gradle version to 8.0.
This upgrade introduced some changes, where 2 of them are critical in order to be able to build:

  1. Remove the package attribute from the AndroidManifest.xml, which has to be done manually in Firebase SDK. At least, this step is possible to be done from Unity Editor.
  2. Add the namespace into build.gradle generated for Firebase, can't find how can I patch Firebase to have it set up correctly.

Firebase Unity SDK Version

11.9.0 & 12.1.0

Unity editor version

2022.3.34

Installation Method

.unitypackage

Problematic Firebase Component(s)

Analytics

Other Firebase Component(s) in use

No response

Additional SDKs you are using

I think it doesn't matter

Targeted Platform(s)

Android

Unity editor platform

Mac, Windows

Scripting Runtime

IL2CPP

Release Distribution Type

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

Relevant Log Output

I can't build, so no logs here

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

Expand Podfile.lock snippet
It's not an iOS build
@NudeNULL NudeNULL added new New issue. type: bug labels Jul 26, 2024
@google-oss-bot
Copy link

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

@argzdev
Copy link

argzdev commented Jul 26, 2024

Thanks for the report, @NudeNULL. It looks like it could be a consequental issue, similar to #1070.

That said, could you try the solution by one of the developers:

@argzdev argzdev added the needs-info Need information for the developer label Jul 26, 2024
@NudeNULL
Copy link
Author

As I wrote in my original message, we are already using those
"We had to increase the target api level to 34 and respectevily the gradle version to 8.0."

And the AGP is indeed 8.1.1.

I am not sure why you suggested this solution because specifically because of using AGP 8.1.1 now the build.gradle have to use the namespace property, and remove the package one from Android Manifest, which Firebase SDK is not doing even if it requires 8.1.1.

It is quite contradictional, why would Firebase be released with requirement to use AGP 8.1.1 and target API 34, when it doesn't even support it in the first place. So I am looking forward for discussion, maybe I am wrong and did implement something incorectly :D

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Jul 26, 2024
@argzdev
Copy link

argzdev commented Jul 26, 2024

Thanks for the update, @NudeNULL. Sorry for the misunderstanding, there's been quite a few issues that came up with the API level 34, and I thought this was similar.

It is quite contradictional, why would Firebase be released with requirement to use AGP 8.1.1 and target API 34, when it doesn't even support it in the first place.

So for context, the way Firebase Unity SDK works is that it acts like a wrapper where it bridges the platform specific SDK. In this case, since the Firebase Android SDK released breaking changes. This will be added in the release of the Unity SDK.

  • Breaking change: Changed the required minimum compileSdkVersion to be 34 or higher.
  • Breaking change: Updated minSdkVersion to API level 21 or higher.

The Firebase Android SDK needs to update to compileSdkVersion 34, since Google Play requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs. This is a requirement starting Aug. 31, 2024.

Now for the issue at hand, I'm not sure why the namespace property is missing in your unityLibrary. I tried exporting the Firebase Analytics Quickstart project in Android Studio. So far, it does show the namespace property and seems to run correctly.

Screenshot 2024-07-26 at 11 05 36 PM

The only difference that I can think of is that the Unity Editor's latest version might have some changes related to the API level 34 support. Could you try updating to the latest version 2022.3.39f1 and see if this makes any difference? Thanks!

@argzdev argzdev added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels Jul 26, 2024
@NudeNULL
Copy link
Author

Sure, I will try to update to 2022.3.39 and get back to you

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Jul 26, 2024
@NudeNULL
Copy link
Author

Oh actually sorry, I see that you displayed a screenshot of the build.gradle file from unityLibrary, this one is good on my side as well, but when trying to build it requires me to add namespace for unityLibrary:FirebaseApp.androidlib build.gradle, other file, that is generated separately

@argzdev
Copy link

argzdev commented Jul 26, 2024

That's odd. It should still be generated correctly. Here's the unityLibrary:FirebaseApp.androidlib build.gradle:

Screenshot 2024-07-26 at 11 33 25 PM

@NudeNULL
Copy link
Author

I got it also generated correctly, so the Unity version is the solution indeed, seems like they fixed something specifically in .39 version

Thanks!

@argzdev
Copy link

argzdev commented Jul 26, 2024

Awesome, glad to hear it works.

@firebase firebase locked and limited conversation to collaborators Aug 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants