目前只做了Android,两天时间,坑很多,后面还要踩ios的坑。
说实话,这个社区已经无力吐槽了。
安卓部分
-
下载离线SDK,使用其中的UNIPLUGIN-HELLO-AS(文中使用HA代替)项目进行扩展
-
开发者中心创建了新的项目,配置证书相关内容
-
更新了整个HA项目中的
appid
、keystore
等配置 -
离线打包成功运行
-
使用AndroidStudio,在HA项目中新建了一个gesture library,包名为
com.morphling.gesture
, 内部只有一个GestureComponent.java
文件。因为没有第三方依赖,所以配置很简单。
build.gradle
配置如下:apply plugin: 'com.android.library' android { compileSdkVersion 29 defaultConfig { minSdkVersion 16 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } repositories { flatDir { dirs 'libs' } } dependencies { compileOnly fileTree(dir: 'libs', include: ['*.jar']) compileOnly fileTree(dir: '../app/libs', include: ['uniapp-v8-release.aar']) compileOnly 'androidx.recyclerview:recyclerview:1.0.0' compileOnly 'androidx.legacy:legacy-support-v4:1.0.0' compileOnly 'androidx.appcompat:appcompat:1.0.0' compileOnly 'com.alibaba:fastjson:1.2.83' }
-
更新了
dcloud_uniplugins.json
,添加如下配置:{ "plugins": [ { "type": "component", "name": "MGesture", "class": "com.morphling.gesture.GestureComponent" } ] }
-
新增测试
ext-gesture.nvue
文件,并配置好pages.json,并生成本地打包APP资源
,然后替换HA项目对应的www文件目录 -
在
AndroidStudio
中run
真机调试,新增的插件可以正常运行 -
按照官网说明,使用gradle编译插件的
.aar
文件,并在已有项目中添加nativeplugins
文件夹,以及相关内容其结构为:nativeplugins └── MGesture ├── android │ ├── gesture-release.aar │ └── libs └── package.json
其中的
package.json
文件内容如下{ "name": "MGesture", "id": "MGesture", "version": "1.0.0", "description": "Gesture Detector Component", "_dp_type":"nativeplugin", "_dp_nativeplugin":{ "android": { "plugins": [ { "type": "component", "name": "MGesture", "class": "com.morphling.gesture.GestureComponent" } ], "integrateType": "aar" } } }
-
提交云打包调试基座,中途没有遇到异常,顺利生成
android_debug.apk
-
使用自定义基座运行模式生成的apk文件,我自己新建的插件不起作用,通过weex查看渲染结果,自定义组件只有一个
div
,没有生成对应的GestureComponent
。 -
请在真机卸载app后重新生成,具体原因我没有分析,但是我终于搞定了。o(╯□╰)o
0 个评论
要回复文章请先登录或注册