Unity学习笔记 - apk编译

BUILDING YOUR UNITY GAME TO AN ANDROID DEVICE FOR TESTING

https://unity3d.com/cn/learn/tutorials/topics/mobile-touch/building-your-unity-game-android-device-testing?playlist=17138

1. 安装JDK

2. 安装Android SDK("the command line tools")

Android SDK Manager:

官方说明:

https://developer.android.com/studio/intro/update.html#sdk-manager

网友说明:

http://www.cnblogs.com/kangjianwei101/p/5621238.html

好像带Image 后缀的都是模拟器用的,可以不装。

Android xxx(API xx)我是只装了最高的Android 7的非image的两个,其他没有装,目前是可以在android4.1.2的设备上运行。

3. 准备Project

Switch Platform

Edit>Project Settings>Player:bundle identifier

填写Android SDK路径:Edit>Preferences - External Tools

4. 设备开启USB debugging

5. Build

6. 测试监控

\Android\android-sdk\tools\lib\monitor-x86_64

If you look to the bottom of Android Monitor, you’ll see the LogCat console. This contains all of the information that you’d see in the Unity console, along with information about other things that are happening in the OS. You can use this in the same way that you use the console within Unity, to help you debug your game.

The LogCat console contains a lot of information, so it can be useful to filter it.

Type "tag:Unity" in the textbox at the top of the LogCat console, and you’ll only see messages that relate to Unity.

Android Monitor Overview

https://developer.android.com/studio/profile/android-monitor.html

测试监控还没用过,先记着吧

问题来了

都按照官网说明来的,然而在编译的时候需要输入jdk目录,输入之后却总是提示

Unity学习笔记 - apk编译_第1张图片

研究了半天之后发现应该是安装JDK的时候jre的路径选成了和jdk一样的,所以没有jdk\lib中没有tools.jar 和 dt.jar包,答案在这篇文章里http://blog.sina.com.cn/s/blog_4fcc6ef20100vzo3.html

今天花了几个小时弄JDK,安装后发现jdk\lib中没有tools.jar 和 dt.jar包,网上搜罗了很多解决办法,都没有解决问题。最后看到一个本质的解决方法,出现这个问题的原因是在JDK安装时将JDK和JRE放在了同一目录下,导致了文件的覆盖,致使tools.jar 和 dt.jar包被覆盖。

解决方法:

我的操作系统是win7,在安装JDK过程中,第二次选择目标文件夹是选择与第一次安装目录不同的文件夹目录下即可。

例如:第一次安装目录为c:\jdk

第二次安装目录为c:\jre

安装完后再查看c:\jdk\lib下就可以看到tools.jar 和 dt.jar包。

然后设置环境变量就可以正常运行java程序。

于是我把jdk卸载掉,重新装了一遍,果然有两次需要填路径的,一个jdk一个jre,之前没看清(这坑)。

环境变量的配置在网上查了发现大家写的还不太一样呢。。我是按zero_lb写的配置的:

http://www.jianshu.com/p/3c67fbfbb67c?utm_campaign=haruki&utm_content=note&utm_medium=reader_share&utm_source=qq

然后就打包成功啦!在手机上可以跑起来啦!耶耶耶!

感谢zero_lb。

2016.08.29

你可能感兴趣的:(Unity学习笔记 - apk编译)