2

Usually one has to turn it into a Library to embed it into another app. However, now I want to convert it into a Dynamic Feature instead.

I've put this in the Unity project's manifest:

<dist:module
    dist:onDemand="true"
    dist:title="@string/title_gamejam_as_dynamic_feature">
  <dist:fusing dist:include="true" />
</dist:module>

In addition, I've commented out the bundle{} part of its Gradle file. If I didn't comment that out I end up getting the following error:

Could not find method bundle() for arguments [build_9piysgasfu4pgl4v1ppx46cyn$_run_closure3$_closure12@44175a08] on object of type com.android.build.gradle.AppExtension.

I've also made sure that the UnityPlayerActivity there extends my custom AppCompatActivity that uses SplitCompat.install(this) [though it extends Activity].

Right now my problem is that for some reason the Assets in that Unity project aren't registered in the base APK, so the UnityPlayerActivity ends up crashing on launching.

What am I doing wrong?

EDIT: The error stacktrace is below:

01-15 03:48:18.343 15446-15522/? E/mono: The assembly mscorlib.dll was not found or could not be loaded.
01-15 03:48:18.343 15446-15522/? E/mono: It should have been installed in the `/data/app/test.com.ondemandtest-1/base.apk/assets/bin/Data/Managed/mono/4.5/mscorlib.dll' directory.
01-15 03:48:18.343 15446-15446/? E/CRASH: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
01-15 03:48:18.343 15446-15446/? E/CRASH: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-15 03:48:18.343 15446-15446/? E/CRASH: Build type 'Release', Scripting Backend 'mono', CPU 'armeabi-v7a'
01-15 03:48:18.343 15446-15446/? E/CRASH: Build fingerprint: 'Huawei/ALE-L21/hwALE-H:5.0.1/HuaweiALE-L21/C636B150:user/release-keys'
01-15 03:48:18.343 15446-15446/? E/CRASH: Revision: '0'
01-15 03:48:18.343 15446-15446/? E/CRASH: pid: 15446, tid: 15446, name: om.ondemandtest  >>> test.com.ondemandtest <<<
01-15 03:48:18.343 15446-15446/? E/CRASH:     r0 00000000  r1 ffc2fb10  r2 6f5aec60  r3 00000000
01-15 03:48:18.343 15446-15446/? E/CRASH:     r4 ffc2fb10  r5 e22c0250  r6 00000000  r7 6f5aec60
01-15 03:48:18.343 15446-15446/? E/CRASH:     r8 ffc2fad4  r9 ab3f7930  sl ffc2fa9f  fp ffc2fa50
01-15 03:48:18.343 15446-15446/? E/CRASH:     ip e1fafee8  sp ffc2fa40  lr e1fb0040  pc e1fafca8  cpsr 00003c56
01-15 03:48:18.343 15446-15446/? E/CRASH: backtrace:

EDIT 2:

Upon further inspection, I found out that mscorlib.dll isn't in the mono .so file, but the Assets folder. Copying assets/bin/Data/... of the Unity project into the base project (into the exact same path) works... but that just defeats the point of modularity.

Is there any way the Unity project can use the Assets it brings without having to copy it into the Base APK before deploying?

Gensoukyou1337
  • 1,507
  • 1
  • 13
  • 31

1 Answers1

0

Unity is searching your .dll in the base.apk, which is not what you want since you are using Dynamic Features

I solved it by overiding the getPackageCodePath() of my UnityPlayerActivity to something like this:

override fun getPackageCodePath(): String {
    return super.getPackageCodePath().replace("base.apk", "split_unity_module.apk")
}

PS: My module is named unity_module so the name of the .apk is something like split_{{your_module_name}}.apk

ndelanou
  • 523
  • 5
  • 16