android / android/app-bundle-samples

Resource Not Found Relaunch Application on-Demand Dynamic Feature Module

Open
#116 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
735
Forks
348
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/googlearchive/android-dynamic-features)

```
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)

Contributor guide

Open the contributing guide

Research direction

Start at MainActivity.kt:158, where AnimationUtils.loadAnimation triggers Resources$NotFoundException after the app is relaunched. Review the dynamic feature sample and the shown BaseActivity and App attachBaseContext implementations, then reproduce the restart flow with the feature installed. Done means the feature activity launches after relaunch without the missing-resource crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
build-system, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.