unity doc
Editor\Data\PlaybackEngines\AndroidPlayer\Variations\mono\Release\Classes
sdk path : Edit -> Preference -> Externel tool -> Android
C:/Users/XXX/AppData/Local/Android/sdk
Android build:
exportJar: in gradle tasks "other"
built jar: in ProjectName/app/release
trouble shooting:
just copy Android manifest to Unity
delete Theme light, Theme Dark related resources
copy (Android) app/res to (Unity)Plugins/Android
remove unused lib(jar) in Android
一、编译apk时。================================================
1.编译输出apk时报错。
Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
D:\android-sdk-windows\build-tools\19.1.0\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "D:/android-sdk-windows/platforms/android-21\android.jar" -F bin/resources.ap_
D:\android-sdk-windows\build-tools\19.1.0\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "D:/android-sdk-windows/platforms/android-21\android.jar" -F bin/resources.ap_
stderr[
res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
]
答:在styles.xml没有 'Theme.AppCompat.Light 和 Theme.AppCompat.Light.DarkActionBar 这两个皮肤。。。
android 皮肤的使用 在这里。。
http://developer.android.com/guide/topics/ui/themes.html
res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
]
答:在styles.xml没有 'Theme.AppCompat.Light 和 Theme.AppCompat.Light.DarkActionBar 这两个皮肤。。。
android 皮肤的使用 在这里。。
http://developer.android.com/guide/topics/ui/themes.html
或者改为:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light.NoTitleBar">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light.NoTitleBar">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
这样也可解决。
2、如果Unity打包过程出现类似下面这样的错误提示:
Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
X:\Android SDK\adt-bundle-windows-x86-XXXXXX\sdk\build-tools\X.1.0\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "E:/Android SDK/adt-bundle-windows-x86-XXXXXX/sdk/platforms/android-X\android.jar" -F bin/resources.ap_
表示在Android外挂项目里的res文件夹里有的地方的xml设置文件里的设置内容找不到,比如一条设置指向一个名为bnt的png图片文件,但这个图片的名字不是这个。
Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
X:\Android SDK\adt-bundle-windows-x86-XXXXXX\sdk\build-tools\X.1.0\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "E:/Android SDK/adt-bundle-windows-x86-XXXXXX/sdk/platforms/android-X\android.jar" -F bin/resources.ap_
表示在Android外挂项目里的res文件夹里有的地方的xml设置文件里的设置内容找不到,比如一条设置指向一个名为bnt的png图片文件,但这个图片的名字不是这个。
3、如果Unity打包过程出现类似下面这样的错误提示:
Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
X:\Program Files\Java\jdk1.X.X_XX\bin\java.exe -Xmx1024M -Dcom.android.sdkmanager.toolsdir="X:/Android SDK/adt-bundle-windows-x86-20130729/sdk\tools" -Dfile.encoding=UTF8 -jar "X:/Program Files/Unity/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" -
表示你的你复制过来的libs文件夹里的东西和Unity的有冲突,通常是含有和Unity的classes.jar相同内容的jar文件。
二、安装后运行报错。================================================================
1.如果单独在运行没问题,接到Unity打包后在Android机子上一运行就退出,特别是那些拿来demo修改一下就用的人好碰到这种情况。检查代码都没有问题。这种情况原因很多,有一个可能性很大,就是在继承UnityPlayerActivity的那个Activity里用了finish函数,把这句删掉就行了,因为继承了UnityPlayerActivity就是Unity程序了,设置时还让它和Unity一起启动的,finish它,就是把你的游戏程序finish了。
沒有留言:
張貼留言