Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 55097ad

Browse files
committed
Initialize the AssetManager from the application context so that assets from dynamic feature modules can be loaded.
1 parent d18c3ea commit 55097ad

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
package io.flutter.embedding.engine;
66

77
import android.content.Context;
8+
import android.content.pm.PackageManager.NameNotFoundException;
9+
import android.content.res.AssetManager;
810
import androidx.annotation.NonNull;
911
import androidx.annotation.Nullable;
1012
import io.flutter.FlutterInjector;
@@ -264,7 +266,13 @@ public FlutterEngine(
264266
@Nullable String[] dartVmArgs,
265267
boolean automaticallyRegisterPlugins,
266268
boolean waitForRestorationData) {
267-
this.dartExecutor = new DartExecutor(flutterJNI, context.getAssets());
269+
AssetManager assetManager;
270+
try {
271+
assetManager = context.createPackageContext(context.getPackageName(), 0).getAssets();
272+
} catch (NameNotFoundException e) {
273+
assetManager = context.getAssets();
274+
}
275+
this.dartExecutor = new DartExecutor(flutterJNI, assetManager);
268276
this.dartExecutor.onAttachedToJNI();
269277

270278
accessibilityChannel = new AccessibilityChannel(dartExecutor, flutterJNI);

0 commit comments

Comments
 (0)