现在项目接入UniwebView同时需要接入其他SDk,所以这里记录一下UniwebView的重编译过程。仅供参考。有点东西想吐槽,这个插件是中国人写的但是文档并不友好。最后呼吁支持正版,花点钱支持一下这个项目。哈哈

解决方案如下

  1. 解压 Assets/UniWebView/Source.zip 下脚本,复制到新工程中

创建PluginLibrary

因为采用AndroidStudio Labrary打包的方式所以可以直接导出 aar的包,省去了很多麻烦。最终的unity工程直接添加aar进行编译

  1. 在Unity工程中的Build.Gradle脚本的dependencies下添加:

    1
    compile(name: 'uniwebview-release', ext: 'aar')
  2. 删除在unity工程的libs下与aar之中重复的jar包。

题外话

Document Link

  1. You need the SDK of Android installed. Please refer to the Android developer site for more information.
  2. You need Apache Ant installed to compile java from command line. This tool is installed on Mac by default, you can run which ant in terminal to confirm if it is installed. If not, please refer to this post or the ant’s official site for more information to install it.
  3. Download the UniWebView’s customize compile script package from here and unzip it to a folder (we will call it “compile folder” later). This package is for Unix based system (such as Mac), but you can adapt it for Windows if needed easily.
  4. And of course, you need the source code of UniWebView Android, which is bundled with this package under the folder /Assets/UniWebView/Source/Android/ after you import it.

我并没有采用ant构建而是使用Gradle构建Labrary 下面是查看本机ant环境的小技巧

这里我检查了下本机Ant是否存在which ant

1
2
keyle@keyles-MacBook-Pro  ~/keylexiao/source/_posts  which ant
ant not found

如果像我一样没有ant就用 SDKMan 安装一下

1
2
3
4
5
6
7
8
9
10
11
12
keyle@keyles-MacBook-Pro  ~/keylexiao/source/_posts  sdk install ant
Downloading: ant 1.10.1
In progress...
######################################################################## 100.0%
Installing: ant 1.10.1
Done installing!
Setting ant 1.10.1 as default.