Losses / rune

Experience timeless melodies with a music player that blends classic design with modern technology.
Mozilla Public License 2.0
444 stars 8 forks source link

fix Android compile process #26

Closed Rachel030219 closed 1 day ago

Rachel030219 commented 1 day ago

To be concise, after applying this patch, on a machine already set up Android SDK, executing flutter build apk should give you the apk file correctly.


In detail, this patch does these things:

  1. Replace souvlaki with a dummy implementation when targeting Android. This is because media control on Android should be done through Android code, while when building current souvlaki code targeting Android, the macro cfg conflicts and build fails.
  2. Force libraries with SDK version lower than 31 to use 31, fixing https://issuetracker.google.com/issues/199180389
  3. When platform is Android, in lib/main.dart don't wait for windowManager.ensureInitialized(); since window_manager does not support Android.

With above changes, the build could pass, but when libhub.so loads, it will look for libc++_shared.so , find nothing, and then stop working. Hence the commit #aa78bf1 to manually copy libc++_shared.so from NDK to android/app/src/main/jniLibs so that it will be packaged into the final apk.

There are an open issue on RustAudio: https://github.com/RustAudio/rodio/issues/404 , some "successful attempts" on rinf: https://github.com/cunarist/rinf/issues/280 , and this section of rinf FAQ . But for rune, only such modification to build.rs is still not packaging libc++_shared.so , only fixing some STL identifiers not found. Adding arguments to android{ defaultConfig{ externalNativeBuild { ndkBuild { won't work, too.

I'm pretty confused. But let's just manually copy them at least for now.