How to reduce the apk size increased by the Admob extension

After adding the admob defold extension without enabling any adapters, the apk size for arm64 increased from 5M to 12M, also the aab from 3M to 10M, it’s too much. How can I reduce the size? thanks.

Well, this is the size of the AdMob NextGen SDK. If you unzip your build you see that all of the size is attributed to big dex files:

The main dependency is com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk:1.3.0:

https://mvnrepository.com/artifact/com.google.android.libraries.ads.mobile.sdk/ads-mobile-sdk/1.3.0

This dependency alone has 6.1 MB of class files:

And then there’s 25 more dependencies:

All of this adds up to an insane amount of class files which need to go into the dex files…

The Admob official document said the next-gen SDK is much lighter, with a file size up to 17% smaller than the previous SDK.
A preview Admob SDK on another game engine I see about 9M increasement in settings for the app size on a device. Compared to a Defold app with the next-gen SDK about 18M increasement. This is a bit unexpected.

I assume you are referring to this post?

In your original post you wrote that the size increased by 7Mb. Where did you get 18Mb from?

I’m also seeing a 7MB increase:

1 Like

18M is the storage on device after installing on an arm64 device , see from settings->apps->app info storage.

7M is from the apk or aab file itself, since it is compressed.

Which engine and what do you mean by “preview Admob SDK”? It’s impossible to draw any conclusions based on this. We need to compare the exact same version of the SDK too (1.3.0).

1 Like

The preview SDK means the legacy version com.google.android.gms:play-services-ads:25.4.0
in the Gideros Engine.
Yes, it’s impossible to draw any conclusions just base on the google document said the next-gen SDK is much lighter.
I will update the SDK to the next-gen in Gideros and compare the result.

We’ve discussed this internally and the conclusion is that we need to enable the Android R8 app optimizer (replacement for ProGuard):

With R8 we’ll be able to significantly reduce class/dex size in dependency heavy Android projects. @AGulev can maybe share updated numbers for Defold with AdMob?

3 Likes

Awesome news! Enabling R8 is a game changer for Android build size. Thanks a lot @britzl and @AGulev for the quick response and action on this!

3 Likes