Android Flutter 启动流程
FlutterMain.startInitialization(context)
- initConfig
.android/Flutter/build/intermediates/flutter/release/app.so
.android/Flutter/build/intermediates/flutter/release/vm_snapshot_data
.android/Flutter/build/intermediates/flutter/release/vm_snapshot_instr
.android/Flutter/build/intermediates/flutter/release/isolate_snapshot_data
.android/Flutter/build/intermediates/flutter/release/isolate_snapshot_instr
.android/Flutter/build/intermediates/flutter/release/flutter_assets
private static void initConfig(Context applicationContext) {
try {
Bundle metadata = applicationContext.getPackageManager().getApplicationInfo(applicationContext.getPackageName(), 128).metaData;
if (metadata != null) {
sAotSharedLibraryPath = metadata.getString(PUBLIC_AOT_AOT_SHARED_LIBRARY_PATH, "app.so");
sAotVmSnapshotData = metadata.getString(PUBLIC_AOT_VM_SNAPSHOT_DATA_KEY, "vm_snapshot_data");
sAotVmSnapshotInstr = metadata.getString(PUBLIC_AOT_VM_SNAPSHOT_INSTR_KEY, "vm_snapshot_instr");
sAotIsolateSnapshotData = metadata.getString(PUBLIC_AOT_ISOLATE_SNAPSHOT_DATA_KEY, "isolate_snapshot_data");
sAotIsolateSnapshotInstr = metadata.getString(PUBLIC_AOT_ISOLATE_SNAPSHOT_INSTR_KEY, "isolate_snapshot_instr");
sFlx = metadata.getString(PUBLIC_FLX_KEY, "app.flx");
sFlutterAssetsDir = metadata.getString(PUBLIC_FLUTTER_ASSETS_DIR_KEY, "flutter_assets");
}
} catch (NameNotFoundException var2) {
throw new RuntimeException(var2);
}
}
- initAot
- initResources
- System.loadLibrary(“flutter”)
FlutterMain.ensureInitializationComplete(context)
private static native void nativeInit(Context var0, String[] var1, String var2, String var3, String var4);
appBundlePath = /data/user/0/com.happy/app_flutter/flutter_assets
appStoragePath= /data/user/0/com.happy/files
engineCachesPath= /data/user/0/com.happy/code_cache
nativeInit(applicationContext, (String[])shellArgs.toArray(new String[0]), appBundlePath, appStoragePath, engineCachesPath);
0 = “—icu-symbol-prefix=_binary_icudtl_dat”
1 = “—icu-native-lib-path=/data/app/com.happy-2Yn7gRujyKyQ2u5McJ0-3g==/lib/x86/libflutter.so”
2 = “—cache-dir-path=/data/user/0/com.happy/code_cache”
3 = “—aot-snapshot-path=/data/user/0/com.happy/app_flutter/flutter_assets”
4 = “—vm-snapshot-data=vm_snapshot_data”
5 = “—vm-snapshot-instr=vm_snapshot_instr”
6 = “—isolate-snapshot-data=isolate_snapshot_data”
7 = “—isolate-snapshot-instr=isolate_snapshot_instr”
runFromBundle
- FlutterNativeView.runFromBundle
final FlutterRunArguments arguments = new FlutterRunArguments();
arguments.bundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext());
arguments.entrypoint = "main";
flutterView.runFromBundle(arguments);
GeneratedPluginRegistrant.registerWith(flutterView.getPluginRegistry());
- FlutterJNI.runBundleAndSnapshotFromLibrary