Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Faisal-Naseer opened this issue Apr 11, 2022 · 4 comments

Comments

@Faisal-Naseer
Copy link

Faisal-Naseer commented Apr 11, 2022

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)

@Eanam
Copy link

Eanam commented Aug 17, 2023

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)

@Faisal-Naseer
Copy link
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

@xeemoo
Copy link

xeemoo commented Sep 8, 2023

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

@Eanam
Copy link

Eanam commented Sep 21, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants