进入 FlutterMain.startInitialization(this);
进入initConfig(applicationContext);
app怎么依赖assets目录下的这些东西呢?
进入initAot(applicationContext);
读取assets文件
存放的位置
进入initResources(applicationContext);
private static void initResources(Context applicationContext) {
Context context = applicationContext;
(new ResourceCleaner(applicationContext)).start();
Bundle metaData = null;
try {
metaData = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData;
} catch (NameNotFoundException var4) {
Log.e("FlutterMain", "Unable to read application info", var4);
}
if (metaData != null && metaData.getBoolean("DynamicPatching")) {
sResourceUpdater = new ResourceUpdater(applicationContext);
if (sResourceUpdater.getDownloadMode() == DownloadMode.ON_RESTART || sResourceUpdater.getDownloadMode() == DownloadMode.ON_RESUME) {
sResourceUpdater.startUpdateDownloadOnce();
if (sResourceUpdater.getInstallMode() == InstallMode.IMMEDIATE) {
sResourceUpdater.waitForDownloadCompletion();
}
}
}
sResourceExtractor = new ResourceExtractor(applicationContext);
sResourceExtractor.addResource(fromFlutterAssets(sFlx)).addResource(fromFlutterAssets(sAotVmSnapshotData)).addResource(fromFlutterAssets(sAotVmSnapshotInstr)).addResource(fromFlutterAssets(sAotIsolateSnapshotData)).addResource(fromFlutterAssets(sAotIsolateSnapshotInstr)).addResource(fromFlutterAssets("kernel_blob.bin"));
if (sIsPrecompiledAsSharedLibrary) {
sResourceExtractor.addResource(sAotSharedLibraryPath);
} else {
sResourceExtractor.addResource(sAotVmSnapshotData).addResource(sAotVmSnapshotInstr).addResource(sAotIsolateSnapshotData).addResource(sAotIsolateSnapshotInstr);
}
sResourceExtractor.start();
}
FlutterActivity与FlutterActivityDelegate
ensureInitializationComplete是把flutter相关的初始化进来然后使用FlutterView进行行加载显示
每一个FlutterView中包了一个FlutterNativeView然后最终就是FlutterView->runFromBundle调用FlutterNativeView->runFromBundle最后渲染到界面上
app module
依赖完成就可以通过startActivity成功的进入到FlutterActivity
https://zhuanlan.zhihu.com/p/40528502
https://yq.aliyun.com/articles/607014