标签:androi 代码 man single 创建 over bsp tco manifest
1、新建一个Android Studio工程,选择空Activity
2、创建一个Module
3、将Unity的依赖jar包拷贝到工程的libs下
4、增加Java代码
内容修改如下
package com.example.mylibrary; /** * Created by Bruce on 2017/7/11. */ import com.unity3d.player.UnityPlayerActivity; import android.app.Activity; import android.os.Bundle; public class MainActivity extends UnityPlayerActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.activity_main); } }
5、修改mylibary的gradle,增加
task makeJar(type: Copy) { //删除存在的 delete ‘build/libs/mylibrary.jar‘ //设置拷贝的文件 from(‘build/intermediates/bundles/debug/‘) //打进jar包后的文件目录 into(‘build/libs/‘) //将classes.jar放入build/libs/目录下 //include ,exclude参数来设置过滤 //(我们只关心classes.jar这个文件) include(‘classes.jar‘) //重命名 rename (‘classes.jar‘, ‘mylibrary.jar‘) } makeJar.dependsOn(build)
6、修改app的gradle,增加
7、在Android Studio的命令行里输入gradlew makeJar
8、查看输出
9把mysdk.jar拷贝到Unity工程
10、修改AndroidManifest文件启动Activity为MainActivity
<activity android:label="@string/app_name" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale" android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LEANBACK_LAUNCHER" /> </intent-filter> <meta-data android:name="unityplayer.UnityActivity" android:value="true" /> </activity>
11、导出Apk
标签:androi 代码 man single 创建 over bsp tco manifest
原文地址:http://www.cnblogs.com/mrblue/p/7149952.html