weex打包android apk的坑
16lz
2021-01-23
1.首先装个weexpack
使用npm build [web|ios|android]
这样的命令总是会报错no such file or directory, open '***.package.json'
,也找不到相关文档说明。所以还是装个weexpack来用的好。
npm install weexpack -g
当然也得安装好android的开发环境。
2.cd进项目目录然后安装依赖
npm install
3. 运行或打包
$ weexpack build android
报错
Error:Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
这是由于升级Android studio3以后,buide.gradle里老的写法不顶用了,要改成如下:
android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "weex-app.apk" } }
4.再次运行及打包
再次报错误
Error:Execution failed for task ':app:javaPreCompileDebug'.Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.- weexplugin-processor-1.3.jar (com.taobao.android:weexplugin-processor:1.3)Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
需要在build.gradle文件的defaultConfig中添加相关设置
javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true } }
5. Will start Android app 或 No android devices found
到这里卡住没有动静了。一般是adb没连上。然而并不知具体怎么了。最后还是在Android studio里打开项目build了事。
更多相关文章
- Android Studio - 第四十六期 不会ANR的轮播写法
- android中app升级的两种常用写法
- android按钮监听器的写法
- android View长按事件简单写法
- Android中点击事件的四种写法
- 8.1、Android中为Intent附加数据的两种写法
- 点击事件XML里的写法
- Android横竖屏的写法、及savedInstanceState的使用
- android ViewHolder模式超简洁写法