使用工具 unity 2017.4.40c1 Android studio 3.6.3
Android 简要流程 :
1.创建Android项目
2. 添加unity 安装目录下的classes.jar包 并依赖
3.配置AndroidManifeast.xml 文件
4.gradle 目录配置
5.MainActivity修改
6.创建打包jks 文件并转换为keystore文件
8.编译打出aar包
Android 微信登录SDK配置:
百度吧 (提醒一点,通过Build.Gradle 导入依赖方式引入的jar包要在打aar包的时候把jar包放在lib目录重新依赖)
unity 简要流程:
1.创建unity项目
2.编写C#代码
3.配置Android打包环境
4.配置player setting 数据
5.打 apk 包
1.创建Android项目



2.添加unity 安装目录下的classes.jar包
classes.jar在unity安装目录下
如

D:\unityInstallPath\unityPath\2017.4.40c1\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\mono\Release\Classes
ps:因为我打的是release 包 也就是签名发布包,所以选择的是Release 目录下的Classes.jar

把classes.jar copy到Android项目的libs文件夹下
Ps:1.把classes.jar 放在libs目录下,Android 打包后会把classes.jar 打到arr包中,需要手动删除后才能试用aar 包(因为unity项目中已经有cleass.jar了。
我们就从里面copy出来的,只是为了引用)
2.在Android project 目录下新建一个存放临时jar包的tempLibs 文件存放classes.jar这样打包出来的aar 文件不会有classes.jar 。

依赖classes.jar

3.配置AndroidManifeast.xml 文件



4 build.gradle 目录配置

5.MainActivity修改


6.创建打包jks 文件并转换为keystore文件





将jks 转为 keystore文件
打开cmd 把目录切换到Keys文件夹下(前提是要配置AndroidSDK环境变量,可百度)

keytool -importkeystore -srckeystore G:\AndroidProject\MyApplication2\Keys\test.jks -srcstoretype JKS -deststoretype PKCS12 -destkeystore G:\AndroidProject\MyApplication2\Keys\test.p12
keytool -v -importkeystore -srckeystore G:\AndroidProject\MyApplication2\Keys\test.p12 -srcstoretype PKCS12 -destkeystore G:\AndroidProject\MyApplication2\Keys\test.keystore -deststoretype JKS
中划线为文件路径,自行替换

8.编译打出aar包


1.创建unity项目
创建Plugins ->Android目录把Android 项目下的AndroidManifest文件和aar 复制过来
再创建一个C#文件用来调用Android代码 界面上写两个button


2.编写C#代码

3.配置Android打包环境
Edit->Preferences->External tools:配置SDK JDK 路径

4.配置player setting 数据


5.打 apk 包
Build 打包



完成
网友评论