googleads / googleads-mobile-unity

Official Unity Plugin for the Google Mobile Ads SDK
https://developers.google.com/admob/unity
Apache License 2.0
1.38k stars 1.08k forks source link

Is exportPackage maintained? #3597

Closed takazawa-gg closed 1 month ago

takazawa-gg commented 2 months ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

Open the project in Android Studio 2023 or other version and run exportPackage from the Task list in Gradle.

I was able to get it to work with version 8.x, but the latest version gives me an error.

I tried to build by updating Gradle, adding dependencies, etc., but even when the build succeeded, there were problems with behavior after importing into the app. Perhaps something is missing.

Can you update the exportPackage task to match the latest version?

NVentimiglia commented 2 months ago

Hi @takazawa-gg

Can you please include the error message you received ?

takazawa-gg commented 2 months ago

Hi @NVentimiglia

For the moment, I will paste the first error.

I cloned the repository and when I run exportPackage in Android Studio 2023.2.1 (or 2024.1.2.14) I get the following error At this point, I have selected Gradle 5.2.1 and JDK 1.8.

Executing tasks: [exportPackage] in project D:\work\googleads-mobile-unity

> Configure project :
clone https://github.com/googlesamples/unity-jar-resolver.git
Cloning into 'D:\work\googleads-mobile-unity\temp\jarresolver'...
Downloaded resolver from https://github.com/googlesamples/unity-jar-resolver.git

> Task :clearAar UP-TO-DATE
> Task :createTempBuildFolder
> Task :downloadResolver UP-TO-DATE
> Task :buildAndroidPluginAar FAILED

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\work\googleads-mobile-unity\source\android-library\app\build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':android-library:app'.
> Failed to apply plugin [id 'com.android.internal.version-check']
   > Minimum supported Gradle version is 6.7.1. Current version is 5.2.1. If using the gradle wrapper, try editing the distributionUrl in D:\work\googleads-mobile-unity\source\android-library\gradle\wrapper\gradle-wrapper.properties to gradle-6.7.1-all.zip

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 19s
3 actionable tasks: 2 executed, 1 up-to-date

I have tried various things after this, including updating Gradle, JDK, and Kotlin, but the errors are too enormous to paste. It seems that the Kotlin version specification is not working on my end.

Is there a version specification for running exportPackage in Android Studio? You may be trying in the wrong environment.

takazawa-gg commented 1 month ago

Hi @NVentimiglia

Please refer to this

These are the changes I made to successfully achieve exportPackage in my development environment. There may be changes included that are not actually necessary.

By using the Unity package exported with this method, we successfully displayed ads on iOS and Android devices.

However, the following error still occurs on the PC Editor:

NullReferenceException: Object reference not set to an instance of an object
GoogleMobileAds.Unity.BannerClient.ShowBannerView () (at Assets/GoogleMobileAds/Platforms/Unity/BannerClient.cs:171)
GoogleMobileAds.Api.BannerView.Show () (at Assets/GoogleMobileAds/Api/BannerView.cs:158)
NullReferenceException: Object reference not set to an instance of an object
GoogleMobileAds.Unity.BannerClient.HideBannerView () (at Assets/GoogleMobileAds/Platforms/Unity/BannerClient.cs:179)
GoogleMobileAds.Api.BannerView.Hide () (at Assets/GoogleMobileAds/Api/BannerView.cs:169)
NullReferenceException: Object reference not set to an instance of an object
GoogleMobileAds.Ump.Unity.ConsentFormClient.Show (System.Action`1[T] onDismissed) (at Assets/GoogleMobileAds/Ump/Platforms/Unity/ConsentFormClient.cs:68)
GoogleMobileAds.Ump.Api.ConsentForm.Show (System.Action`1[T] onDismissed) (at Assets/GoogleMobileAds/Ump/Api/ConsentForm.cs:69)

This error does not occur when using the provided GoogleMobileAds-v9.2.0.unitypackage, so I think something might still be missing in the export settings. I have not yet been able to resolve this issue.

Anyway, given the current situation, I suspect that the exportPackage might not be maintained.

takazawa-gg commented 1 month ago

This change eliminated the error in the Unity Editor. https://github.com/Global-Gear/googleads-mobile-unity/commit/17ae6e6799e45b799035984bf2a39e42fc6a1742