简体   繁体   中英

Unity Asset Bundles Google Play Asset Delivery - Proguard Minification

I am having problems configuring Proguard to prevent minification of java libraries in the Google Play Asset Bundles and Asset Delivery Plugins when building a.aab using the Google Android App Bundle Unity Editor tool, using the following configuration:

Build Settings: Create Symbols.zip - Debugging Compression Method - LZ4

Project Settings - Player - Other: API minimum - 5 Target API - 33 Scripting Backend - IL2CPP (.NET Standard 2.1) IL2CPP Generation - Fastest ARMv7 & ARM64 Strip Engine Code - true

Publishing Settings: Custom Proguard file Minify: R8 - false Release - true

The custom Proguard file in Assets\Plugins\Android:

    -keep public class com.google.play.core.**{
    public *;
    }
    -keep public class com.google.play.common.**{
    public *;
    }
    -keep public class com.google.play.appbundle.**{
    public *;
    }
    -keep public class com.google.play.assetdelivery.**{
    public *;
    }
    -keepattributes *Annotation*
    -dontobfuscate

This is linked form the mainTemplate.gradle build file.

Building this with the Google Editor Plugin continues to strip out both Methods and Interfaces resulting in the app crashing on start-up. I have tested the above Proguard by introducing each element which corrects some issues, but is still removing Interfaces from play.core.

Note: I have not included Stack Traces as they are pointing to specific methods and Interfaces in the Plugin libraries which were incrementally fixed by adding each exception to the Proguard file above, but is still not preserving all functions.

I have followed multiple other threads stating the same issue which suggested - deleting the library folder, using custom.gradle, downgrading all of the Google Plugins (1.7.0 release). This had previously worked using R8, but I have not been able to produce a working build since the new updates.

I have also tried multiple combinations of builds but continue to get the same issue to varying degrees of what is and is not kept, all builds cause the app to crash.

Any help in the Proguard configuration or suggestions in build configuration would be greatly appreciated, as this seems to be a popular topic with no clear solution. I am trying not export the project and build in Android Studio as that would be a significant break from our current build process.

If there is any more information I can provide please let me know.

Thanks everyone.

UPDATE: The above issue is not to do with Proguard settings.

Copying in the Proguard settings from the google.play. plugins in to a proguard-user.txt file did not fix the issue as the files were not being correctly handled during gradle build.

R8 minification was not enabled and should have been. The underlying issue is conflicts in class dependencies in the google.play plugins. Specifically;

Assets/GooglePlayPlugins/com.google.play.assetdelivery 2.0.0 Assets/GooglePlayPlugins/com.google.play.core 1.10.3

This is a documented issue in play-unity-plugins for google; https://github.com/google/play-unity-plugins/blob/master/README.md#play-core-conflicts

However, their fix in the link is proving difficult to implement as I am unfamiliar with gradle and using local maven repositories, and difficulties with EDM4U build patching.

I have started a new thread on the issue;

Unity google.play.core dependency conflict with EDM4U maven local repository build error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM