fix(android): 适配 Flutter 3.29+,用 FlutterLoader 替换已移除的 FlutterMain#2261
Open
xianjianlf2 wants to merge 1 commit into
Open
fix(android): 适配 Flutter 3.29+,用 FlutterLoader 替换已移除的 FlutterMain#2261xianjianlf2 wants to merge 1 commit into
xianjianlf2 wants to merge 1 commit into
Conversation
`io.flutter.view.FlutterMain` was removed in Flutter 3.29 (deprecated throughout 3.x), which breaks the Android build with "cannot find symbol: FlutterMain" for everyone on Flutter 3.29+. Replace the only usage with the official replacement `FlutterInjector.instance().flutterLoader().findAppBundlePath()`. It returns the same String and has existed since Flutter 1.20, so the change stays backward compatible with this package's min SDK (3.0.0). At the call site the engine is already constructed, so the loader is guaranteed initialized. Closes alibaba#2222 Closes alibaba#2217 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
io.flutter.view.FlutterMain在 Flutter 3.29 已被移除(3.x 期间一直 deprecated),导致升级到 3.29+ 的用户 Android 编译失败:cannot find symbol: FlutterMain。对应 #2222、#2217。改动
全仓库仅
FlutterBoost.java一处用到该 API,替换为官方等价写法:import io.flutter.view.FlutterMain→import io.flutter.FlutterInjectorFlutterMain.findAppBundlePath()→FlutterInjector.instance().flutterLoader().findAppBundlePath()两者返回值均为
String;调用点在new FlutterEngine(...)之后,FlutterLoader 已初始化,调用安全。兼容性
FlutterInjector自 Flutter 1.20 起即存在,远早于本包要求的最低版本 3.0.0,低版本用户不受影响,无需版本分支或反射。验证
对照真实 Flutter 3.32.0 引擎产物(
flutter_embedding,engine hash18818009…)用javac核验:import io.flutter.view.FlutterMain→ 编译失败(找不到符号),复现该 bugString正确传入DartExecutor.DartEntrypoint(String, String)Closes #2222
Closes #2217