BUILDING YOUR UNITY GAME TO AN ANDROID DEVICE FOR TESTING
1. 安裝JDK
2. 安裝Android SDK("the command line tools")
Android SDK Manager:
官方說明:
https://developer.android.com/studio/intro/update.html#sdk-manager
網(wǎng)友說明:
http://www.cnblogs.com/kangjianwei101/p/5621238.html
好像帶Image 后綴的都是模擬器用的,可以不裝。
Android xxx(API xx)我是只裝了最高的Android 7的非image的兩個,其他沒有裝,目前是可以在android4.1.2的設(shè)備上運行。
3. 準(zhǔn)備Project
Switch Platform
Edit>Project Settings>Player:bundle identifier
填寫Android SDK路徑:Edit>Preferences - External Tools
4. 設(shè)備開啟USB debugging
5. Build
6. 測試監(jiān)控
\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
測試監(jiān)控還沒用過,先記著吧
問題來了
都按照官網(wǎng)說明來的,然而在編譯的時候需要輸入jdk目錄,輸入之后卻總是提示

研究了半天之后發(fā)現(xiàn)應(yīng)該是安裝JDK的時候jre的路徑選成了和jdk一樣的,所以沒有jdk\lib中沒有tools.jar 和 dt.jar包,答案在這篇文章里http://blog.sina.com.cn/s/blog_4fcc6ef20100vzo3.html
今天花了幾個小時弄JDK,安裝后發(fā)現(xiàn)jdk\lib中沒有tools.jar 和 dt.jar包,網(wǎng)上搜羅了很多解決辦法,都沒有解決問題。最后看到一個本質(zhì)的解決方法,出現(xiàn)這個問題的原因是在JDK安裝時將JDK和JRE放在了同一目錄下,導(dǎo)致了文件的覆蓋,致使tools.jar 和 dt.jar包被覆蓋。
解決方法:
我的操作系統(tǒng)是win7,在安裝JDK過程中,第二次選擇目標(biāo)文件夾是選擇與第一次安裝目錄不同的文件夾目錄下即可。
例如:第一次安裝目錄為c:\jdk
第二次安裝目錄為c:\jre
安裝完后再查看c:\jdk\lib下就可以看到tools.jar 和 dt.jar包。
然后設(shè)置環(huán)境變量就可以正常運行java程序。
于是我把jdk卸載掉,重新裝了一遍,果然有兩次需要填路徑的,一個jdk一個jre,之前沒看清(這坑)。
環(huán)境變量的配置在網(wǎng)上查了發(fā)現(xiàn)大家寫的還不太一樣呢。。我是按zero_lb寫的配置的:
然后就打包成功啦!在手機上可以跑起來啦!耶耶耶!
感謝zero_lb。
2016.08.29