Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可以加载打包到android_asset目录内的文件吗? #211

Closed
CarlTien opened this issue Apr 23, 2021 · 6 comments
Closed

可以加载打包到android_asset目录内的文件吗? #211

CarlTien opened this issue Apr 23, 2021 · 6 comments
Assignees
Labels
enhancement New feature or request P4
Milestone

Comments

@CarlTien
Copy link

把js bundle放到android assets目录下提示无法加载
flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Unable to load asset: file:///android_asset/app.js
#0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:225:7)

#1 AssetsBundle.resolve (package:kraken/src/launcher/bundle.dart:171:38)
#2 KrakenBundle.getBundle (package:kraken/src/launcher/bundle.dart:61:20)
#3 KrakenController.loadBundle (package:kraken/src/launcher/controller.dart:655:36)

#4 launch (package:kraken/src/launcher/launcher.dart:37:20)
#5 main (package:kraken_sdk_module/main.dart:4:3)
#6 _runMainZoned.. (dart:ui/hooks.dart:231:25)
#7 _rootRun (dart:async/zone.dart:1190:13)
#8 _CustomZone.run (dart:async/zone.dart:1093:19)
#9 _runZoned (dart:async/zone.dart:1630:10)
#10 runZonedGuarded (dart:async/zone.dart:1618:12)
#11 _runMainZoned. (dart:ui/hooks.dart:223:5)
#12 _startIsolate. (dart:isolate-patch/isolate_patch.dart:301:19)
#13 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

@CarlTien CarlTien added the enhancement New feature or request label Apr 23, 2021
@CarlTien
Copy link
Author

image
实测这样可以加载assets目录下的js文件,哪位发现如何加载sdcard上的js文件方法的话辛苦贴一下

@wssgcg1213
Copy link
Member

loadUrl 目前只支持了远程地址, 需要支持 loadPath 的功能

@wssgcg1213
Copy link
Member

Widget 侧可以传入 bundlePath 来指定

@andycall
Copy link
Member

andycall commented Apr 26, 2021

现在可以用个临时办法:先读取 flutter assets 里面的文件,然后将纯文本传给 Kraken

https://flutter.dev/docs/development/ui/assets-and-images#loading-flutter-assets-in-android

@wssgcg1213 wssgcg1213 self-assigned this Apr 27, 2021
@wssgcg1213
Copy link
Member

  1. Native API 支持 loadPath
  2. bundlePath 目前仅支持 flutter assets, 不支持 local path (document)

Assign to myself.

@andycall
Copy link
Member

移动到这里 #232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P4
Projects
None yet
Development

No branches or pull requests

4 participants
@wssgcg1213 @andycall @CarlTien and others