googlesamples / android-dynamic-code-loading Goto Github PK
View Code? Open in Web Editor NEWAndroid dynamic code loading sample for Dynamic Feature Modules.
License: Other
Android dynamic code loading sample for Dynamic Feature Modules.
License: Other
This app is crashed with the following stacktrace:
2019-05-12 00:14:54.688 19151-19151/com.google.android.samples.dynamiccodeloading E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.android.samples.dynamiccodeloading, PID: 19151
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.samples.dynamiccodeloading/com.google.android.samples.dynamiccodeloading.MainActivity}: java.util.NoSuchElementException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.util.NoSuchElementException
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:366)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:416)
at java.util.ServiceLoader$1.next(ServiceLoader.java:494)
at com.google.android.samples.dynamiccodeloading.MainViewModel.initializeStorageFeature(MainViewModel.kt:67)
at com.google.android.samples.dynamiccodeloading.AbstractMainViewModel.loadCounter(AbstractMainViewModel.kt:81)
at com.google.android.samples.dynamiccodeloading.MainActivity.onCreate(MainActivity.kt:65)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
The crashed app is built with the buildType of serviceLoaderDebug
.
The crash seems to be fixed by modifying app/src/serviceLoader/java/com/google/android/samples/dynamiccodeloading/MainViewModel.kt
to pass a classloader to ServiceLoader.load()
like
val serviceLoader = ServiceLoader.load(
StorageFeature.Provider::class.java, StorageFeature.Provider::class.java.classLoader
)
It's a great sample for dynamic code loading but normally we don't have just one dynamic feature module, at least add one more dynamic feature module and tell the best practice
gradlew reflectDebug or ./gradlew serviceLoaderDebug or ./gradlew daggerDebug
In the feature module, I created some viewModels, some fragments, ...
I want to load in on dagger, can you suggest or sample?
I just follow this post on medium and make some feature with same structure.
on debug variant everything is fine, but on release variant and upload it to playstore didn't work as expected.
I use latest dagger version : 2.42
I guess this line return null instance :
I have asked on SO and not have answer yet. Thanks in advance.
Hi ,
I am getting the crash while opening the module from the app. I was uploaded the .aab file into play store. I run the app downloaded from the play store. some times the module was opening after uninstall and reinstall the app then the module get crash some times.
PLease help me to resolve this issue. I struck over this.
I got this crash report in the logcat.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.testDynamic, PID: 5047
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.testDynamic/com.testDynamic.module.NumberFacts}: java.lang.ClassNotFoundException: Didn't find class "com.testDynamic.module.NumberFacts" on path: DexPathList[[zip file "/data/app/com.testDynamic-1/base.apk", zip file "/data/app/com.testDynamic-1/split_config.en.apk", zip file "/data/app/com.testDynamic-1/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/com.testDynamic-1/lib/arm64, /system/lib64, /vendor/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2785)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1532)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6342)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.testDynamic.module.NumberFacts" on path: DexPathList[[zip file "/data/app/com.testDynamic-1/base.apk", zip file "/data/app/com.testDynamic-1/split_config.en.apk", zip file "/data/app/com.testDynamic-1/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/com.testDynamic-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2616)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2785)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1532)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6342)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.testDynamic-1/split_config.en.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:373)
at dalvik.system.DexFile.(DexFile.java:113)
at dalvik.system.DexFile.(DexFile.java:78)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:359)
at dalvik.system.DexPathList.makeElements(DexPathList.java:323)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:263)
at dalvik.system.DexPathList.(DexPathList.java:126)
at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.(PathClassLoader.java:64)
at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:58)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:522)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:555)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:1925)
at android.app.LoadedApk.getResources(LoadedApk.java:768)
at android.app.ContextImpl.(ContextImpl.java:2078)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2023)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5393)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1602)
... 6 more
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.testDynamic-1/split_config.xxhdpi.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:373)
at dalvik.system.DexFile.(DexFile.java:113)
at dalvik.system.DexFile.(DexFile.java:78)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:359)
at dalvik.system.DexPathList.makeElements(DexPathList.java:323)
2019-06-13 12:24:23.493 5047-5047/? E/AndroidRuntime: at dalvik.system.DexPathList.makeDexElements(DexPathList.java:263)
at dalvik.system.DexPathList.(DexPathList.java:126)
at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.(PathClassLoader.java:64)
at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:58)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:522)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:555)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:1925)
at android.app.LoadedApk.getResources(LoadedApk.java:768)
at android.app.ContextImpl.(ContextImpl.java:2078)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2023)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5393)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1602)
Font from assets not rendering in PDF view which is downloaded and installed using dynamic feature.
Detailed Question: https://stackoverflow.com/questions/64191100/using-dynamic-feature-module-fonts-downloaded-and-installed-in-asset-folder-but
the resources of dynamic module are defined in app module??
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.