1

I have menu module setup by 'com.android.dynamic-feature'. Everything working fine when I coding and run by android studio. When package apk by Build -> Build APK(s) it crash Class Not Found when I start activity in module. Notes: the activity path is correct, I guess my module doesn't attach into app

  1. Manifest module:
    <dist:module
        dist:instant="false"
        dist:onDemand="false"
        dist:title="">
        <dist:delivery>
            <dist:install-time />
        </dist:delivery>
        <dist:fusing dist:include="true" />
    </dist:module>
  1. module gradle
apply plugin: 'com.android.dynamic-feature'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: '../shared_dependencies.gradle'

Is there any mistake here? Thanks

Công Hải
  • 4,961
  • 3
  • 14
  • 20

2 Answers2

1

If you use <dist:fusing dist:include="true" /> and sign your app by APK it still not include into your APK. dynamic-feature only use with AAB format.

If you still want to use APK format you have to use bundle-tool to generate universal APK from AAB

https://developer.android.com/studio/command-line/bundletool

Công Hải
  • 4,961
  • 3
  • 14
  • 20
0

Building Android project that has dynamic feature modules will always work on emulator as there is no delivery system as on Google Play. Also you should use Build -> Build Bundle(s)/APK(s)->Build Bundle(s) option when you are using feature modules.

In your main module's build.gradle file you need to set dynamicFeatures, e.g.:

android {
...
  dynamicFeatures = [
        ':module1',
        ':module2',
        ':module3'
   ]
...
}

While in dynamic feature module's build.gradle file you need dependency for main module:

dependencies {
   implementation project(':app')
}
sela
  • 314
  • 1
  • 11
  • I already add some codes above, I have to build APK because my app publishes to another store. it not support AAB – Công Hải Mar 13 '20 at 10:14
  • You can try with removing as that would result with default behavior and include module in build time – sela Mar 13 '20 at 10:25
  • Thanks, but I already try and not working. Maybe it only available in AAB format – Công Hải Mar 13 '20 at 10:31
  • You can try to build release build variant to emulator and you will need to add signing of APK inside build.gradle so that you get signed APK but you could potentially get two APKs one for main module and second one for feature module – sela Mar 13 '20 at 11:27