Advice on native Android integration with filesize control/asset bundle download

Hey there,
I’ve been working on this setup for a bit now but can’t seem to get a proper way of doing it fully working.
So essentially what I am trying to achieve is this:

We have a native Android app with buttons to launch various Unity-developed applications/games.
These are camera-based apps like an AR experience.

I’ve already got it working to just integrate my Unity build into the app and it works as intended. But since this bloats the app size into not-okay territory I’ve developed a minimal base Scene in Unity which after the fact can download asset bundles to launch my games. Each game is represented in a single scene.
It does work alright in editor aswell as standalone mode, but once I export and integrate the project into the native Android App it behaves differently.
The actual problem varies (interestingly runs further in emu than on devices), but once I load the new scene after downloading the bundles and instantiate the scene content it stops.

On devices I get SIGSEGV code 1 (apparently to do with memory), in emu it pretty much works but I get an error I used to struggle with when integrating (DllNotFoundException: arcore_unity_api). Might be an emu issue.

Does anyone have advice on a good structure for my archtitecture? Maybe my approach isn’t ideal but I only ever find topics on how to integrate single Unity projects or to download asset bundles on standalone Unity apk, not the combined problem. Is there a better way to have isolated scenes with all related assets as a downloadable resource and how would I instantiate/load it?

A nice bit of advice would be appreciated, thanks a lot!

Alright just for reference if someone comes across this, I did manage the problem.
To be precise, I did everything right anyway - it was just a Proguard issue.
using -keep class com.unity3d.** { *; } instead of com.unity3d.player.* resolves this.
And as a brief reiteration of what my design looks like:

  • Put scene content in empty
    GameObject, which in turn is saved
    into a prefab so we can instantiate it.

  • Have a SceneNavigator scene with loading screen plus just a script to handle asset bundle downloads and switching scene afterwards

  • I switch to an empty scene with a single script, which instantiates the prefab from within the assetbundle into itself

  • Export project mostly according to this guide , except we dont make an aar but copy the android project as is into a library directory

  • Depending on both your projects specs, you might need to adjust a bunch of stuff in gradle and the manifest. These can include ndk abiFilters and exclude support library modules to resolve duplicates

  • Start your UnityPlayerActivity from intent and pray it works :wink:

If you have similar struggles, don’t hesitate to hit me up!

Hey @Pilzkopf , Thanks for the suggestion. One question though? Were you able to pass messages from native android to unity application? If so, how? I have been stuck for days, trying to achieve the same.