Skip to content

Resource Not Found Relaunch Application on-Demand Dynamic Feature Module #116

Open

Description

@Faisal-Naseer

When I download the on demand dynamic feature module it works fine as soon as I restart application I get the crash "Resource not found" .
Heres the code that i copied from google dynamic features sample repo

private fun onSuccessfulLoad(moduleName: String, launch: Boolean) {
    if (launch) {
        when (moduleName) {
           pagesfeatures -> launchActivity(mainActivity)
        }
    }

}

I have already overridden the code in BaseActivity and App class

 open class BaseActivity: AppCompatActivity() {
    override fun attachBaseContext(newBase: Context?) {
        super.attachBaseContext(newBase)
        SplitCompat.install(this)
    }
}
 public class App extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        SplitCompat.install(base);
    }
}

But its crashing when i revisit the application

The Exception thats occurring in my logs Crashlytics

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.qp.readquranoffline.holybookreading/com.mycode.pagesfeature.activities.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7e010000
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3621)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3866)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2190)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:268)
at android.app.ActivityThread.main(ActivityThread.java:8004)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:627)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:997)

Caused by android.content.res.Resources$NotFoundException: Resource ID #0x7e010000
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:248)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2400)
at android.content.res.Resources.getAnimation(Resources.java:1277)
at android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:138)
at com.mycode.quranpagesfeature.activities.MainActivity.onCreate(MainActivity.kt:158)
at android.app.Activity.performCreate(Activity.java:8058)
at android.app.Activity.performCreate(Activity.java:8042)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1315)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3594)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3866)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2190)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:268)
at android.app.ActivityThread.main(ActivityThread.java:8004)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:627)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:997)

Activity

  1. Eanam commented on Aug 17, 2023

    @Eanam

    The same problem happened to our app. But still no solution.

    There are some clues:

    1. After call SplitCompat.install(context) at Application.attachBaseContext, the applicationContext.resource.asserts do have contain the dynamic module apk (on-demand)
    2. Then the WebView apk loaded, it refreshed the ResourcesImpl instance. At then, applicationContext.resource.asserts don't contain the dynamic module apk (on-demand)
    3. We guess that the installed dynamic module apk (on-demand) must be injected manually by calling SplitCompat.install every time the ResourcesImpl created, So after Step 2, the new ResoucesImpl instance don't contain the dynamic module apk (on-demand)
  2. Faisal-Naseer commented on Aug 17, 2023

    @Faisal-Naseer
    Author

    Don't know why Android team is no more interested in stability of such features...
    They always move to new stuff and leaving unresolved the old stuff

  3. xeemoo commented on Sep 8, 2023

    @xeemoo

    I have the same problem in my app, the resources of the third-party aar in the dynamic feature module cannot be found.

  4. Eanam commented on Sep 21, 2023

    @Eanam

    Our Solution:
    We monitor the property assert of resources(Application), and call SplitCompat.install() every time the assert changed in method getResources (Application)

  5. Armen101 commented on Dec 19, 2025

    @Armen101

    The same issue happened in our app too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions