|
Crosswalk快速构建打包app
这个一般是用于本身内容是web构建的,只需要用android来包个壳的app,官方提供了两种方式:
命令行打包
使用指定的命令参数来构建、打包app
- --arch=arm 只打包出arm/x86的,不填默认打包出两种架构的
- -f 全屏
- --orientation==landscape 横屏
- --use-animatable-view 使用动画效果进入
- --name=应用名称
- -package=应用的包名
- --icon=图标
- --app-url=加载网络的地址
- --manifest=manifest.json文件地址
- --target-dir=生成apk包的地址
- --project-dir=生成android项目的地址
- --project-only 对应只生成项目不编译
demo
- 只生成arm架构的apk包,全屏,使用启动动画效果,指定生成apk的位置
- python make_apk.py --arch=arm -f --use-animatable-view --name=Demo --package=com.act262.demo --app-url=http://www.baidu.com --target-dir=d:\demo
- 指定只生成demo的项目,不打包(可以定制一些其他UI)
- python make_apk.py -f --use-animatable-view --name=Demo --package=com.act262.demo --app-url=http://www.baidu.com --project-dir=d:\demo --project-only
使用manifest.json文件格式
如果不想在命令行中如此复杂的配置,那么可以使用manifest.json文件来配置这个项目的属性。 然后只需在命令行中指定需要使用的manifeset文件即可。
旧版本格式
- {
- "name": "pandakun2e",
- "manifest_version": 1,
- "version": "1",
- "app": {
- "launch":{
- "local_path": "index.html"
- }
- }
- }
新版本格式
- {
- "name": "simple",
- "xwalk_version": "0.0.0.1",
- "start_url": "index.html",
- "icons": [
- {
- "src": "icon.png",
- "sizes": "128x128",
- "type": "image/png",
- "density": "4.0"
- }
- ]
- }
出错问题:
- 在命令行中,使用python打包出现错误
- File "D:\share\dev\crosswalk-12.41.296.9\util.py", line 47, in RunCommand
- return output.decode("utf-8")
- File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
- return codecs.utf_8_decode(input, errors, True)
- UnicodeDecodeError: 'utf8' codec can't decode byte 0xb3 in position 136: invalid
- start byte
意思大概是编码转换问题,查看了源码下是utf-8格式的,我们一般国内的话应该是gb2312的编码,应该是根据当前系统的信息来用的。 只需要把这里的utf-8改成gb2312即可继续跑了。
- def RunCommand(command, verbose=False, shell=False):
- """Runs the command list, print the output, and propagate its result."""
- proc = subprocess.Popen(command, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT, shell=shell)
- if not shell:
- output = proc.communicate()[0]
- result = proc.returncode
- if verbose:
- print(output.decode("utf-8").strip())
- if result != 0:
- print ('Command "%s" exited with non-zero exit code %d'
- % (' '.join(command), result))
- sys.exit(result)
- return output.decode("utf-8")
- else:
- return None
-->
- def RunCommand(command, verbose=False, shell=False):
- """Runs the command list, print the output, and propagate its result."""
- proc = subprocess.Popen(command, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT, shell=shell)
- if not shell:
- output = proc.communicate()[0]
- result = proc.returncode
- if verbose:
- print(output.decode("gb2312").strip())
- if result != 0:
- print ('Command "%s" exited with non-zero exit code %d'
- % (' '.join(command), result))
- sys.exit(result)
- return output.decode("gb2312")
- else:
- return None
来自为知笔记(Wiz) |
|