其他分享
首页 > 其他分享> > Unity打Android包报错总结 长期更新

Unity打Android包报错总结 长期更新

作者:互联网

报错1 Failed to compile resources with the following parameters:-bootclasspath "E:\software\Android\AndroidSDK_ForUnity5\platforms\android-24\android.jar" -d "D:\h5\UnityProjects\IceClimber\Temp\StagingArea\bin\classes" -source 1.6 -target 1.6 -encoding UTF-8 "android\support\customtabs\R.java" "android\support\graphics\drawable\R.java" "android\support\graphics\drawable\animated\R.java" "android\support\v4\R.java" "android\support\v7\appcompat\R.java" "android\support\v7\cardview\R.java" "com\facebook\R.java" "com\facebook\android\R.java" "com\herofun\iceclimber\R.java"解决方案: 可能是jdk版本低了,使用jdk8解决。报错2 IOException: Failed to Move File / Directory from 'Temp/StagingArea\android-libraries\app-debug\classes.jar' to 'Temp/StagingArea\android-libraries\app-debug\libs\classes.jar'.UnityEditor.Android.PostProcessor.Tasks.ProcessAAR.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry)UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (BuildPostProcessArgs args)UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, System.String downloadWebplayerUrl, System.String manualDownloadWebplayerUrl, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.BuildReporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:186)UnityEditor.HostView:OnGUI()解决方案删除aar中的libs/classes.jar报错3 Error: [Temp\StagingArea\AndroidManifest-main.xml:12, D:\h5\UnityProjects\Test\AARTest\Temp\StagingArea\android-libraries\app-debug\AndroidManifest.xml:3] Main manifest has <uses-sdk android:minSdkVersion='9'> but library uses minSdkVersion='15'UnityEditor.HostView:OnGUI()解决方案在Unity的PlayerSetting中把minSdkVersion设成与第三方库中的minSdkVersion一致报错4 CommandInvokationFailure: Failed to re-package resources.E:\software\Android\AndroidSDK_ForUnity5\build-tools\24.0.1\aapt.exe package --auto-add-overlay -v -f -m -J "gen" -M "AndroidManifest.xml" -S "res" -I  "E:\software\Android\AndroidSDK_ForUnity5\platforms\android-25\android.jar"  -F bin/resources.ap_ --extra-packages com.zwwx.game.gamesupport -S  "D:\h5\UnityProjects\Test\AARTest\Temp\StagingArea\android-libraries\app-debug\res"错误原因build-tools用的版本是24,platforms版本用的是android-25, 两个版本不一致导致报错。解决方案使用platforms/android-24打包报错5 CommandInvokationFailure: Unable to merge android manifests. See the Console for more details. E:\software\Java\jdk8\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="E:\software\Android\AndroidSDK_ForUnity5\tools" -Dfile.encoding=UTF8 -jar "E:\software\Unity5_5\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -stdout[Warning: [Temp\StagingArea\AndroidManifest-main.xml:12, D:\h5\UnityProjects\Test\AARTest\Temp\StagingArea\android-libraries\app-debug\AndroidManifest.xml:3] Main manifest has <uses-sdk android:targetSdkVersion='23'> but library uses targetSdkVersion='25']错误原因第三方库与Unity中用的SDK的targetSdkVersion版本不一致。解决方案Unity使用targetSdkVersion='25'打包。Android SDK升级到以下版本platforms/android-25、tools_r25.2.5-windows、build-tools_r25.0.2-windows注意:最新版本的tools下没有android.bat命令,打包会报Error:Invalid command android错误报错6 CommandInvokationFailure: Unable to list target platforms.Please make sure the android sdk path is correct. See the Console for more details. E:\software\Java\jdk8\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="E:\software\Android\AndroidSDK\tools" -Dfile.encoding=UTF8 -jar "E:\software\Unity5_5\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -stderr[Error:Invalid command android]错误原因新版本的tools下没有android.bat命令,所以打包时报Error:Invalid command android解决方案下个旧版本的tools再打包。tools_r25.2.5-windows.zip报错7 UnityException: Adding Android library projects failed!UnityEditor.Android.AndroidLibraries.AddLibraryProject (System.String projectPropertiesPath)UnityEditor.Android.AndroidLibraries.FindAndAddLibraryProjects (System.String searchPattern)UnityEditor.Android.PostProcessor.Tasks.AddAndroidLibraries.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)错误原因aar中的某些文件被删除了,比如aar中的AndroidManifest.xml被删除了。解决方案重新生成个aar报错8 Error:Execution failed for task ':processReleaseGoogleServices'.> No matching client found for package name 'com.zwwx.game.WinterJump'原因:google-services.json中的包名与build.gradle中的包名不一致。解决方案:改成一致就行了。报错9 用gradle build打包时报以下错 To run dex in process, the Gradle daemon needs a larger heap.It currently has 1024 MB.For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.For more information see https://docs.gradle.org/current/userguide/build_environment.html原因:gradle需要更大内存 解决方案: 修改gradle-wrapper.properties文件。 在gradle-wrapper.properties文件中添加一条配置 set  org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=2048m报错10 Parsing json file: D:\xxx\google-services.json:processDebugGoogleServices FAILEDFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':processDebugGoogleServices'.> No matching client found for package name 'com.xx.xxx.xxxxx'* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.原因:google-services.json中定义的包名与AndroidManifest.xml中定义的包名不一致。 解决方案:包名改一致。报错11Rejecting re-init on previously-faile d class java.lang.Class<com.helpshift.support.adapters.QuestionListAdapter>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/widget/RecyclerView$Adapter;解决方案: 删除libs下的android-support-v4.jar保留android-support-v7-appcompat.jar报错12CommandInvokationFailure: Unable to convert classes into dex format.E:/JavaJDK/jdk\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="E:/androidsdk\tools" -Dfile.encoding=UTF8 -jar "F:\unity\Editor\Data\PlaybackEngines\Player/Tools\sdktools.jar" -stderr[Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0我出现这个问题的时候下面的提示还没有看只看上面红字部分,说明jdk版本太低,我原来是1.7的换成1.8果断好使报错13Error:(26, 9) Attribute application@icon value=(@drawable/logo) from AndroidManifest.xml:26:9Error:(28, 9) Attribute application@theme value=(@style/ThemeActionBar) from AndroidManifest.xml:28:9is also present at XXXX-trunk:XXXXLib:unspecified:15:9 value=(@style/AppTheme)Suggestion: add 'tools:replace="android:theme"' to <application> element at AndroidManifest.xml:24:5 to overrideError:Execution failed for task ':XXXX:processDebugManifest'.> Manifest merger failed with multiple errors, see logs原因:AS的Gradle插件默认会启用Manifest Merger Tool,若Library项目中也定义了与主项目相同的属性(例如默认生成的android:icon和android:theme),则此时会合并失败,并报上面的错误。解决方法有以下2种:方法1: 在Manifest.xml的application标签下添加tools:replace="android:icon, android:theme"(多个属性用,隔开,并且记住在manifest根标签上加入xmlns:tools="http://schemas.android.com/tools",否则会找不到namespace哦)方法2: 在build.gradle根标签上加上useOldManifestMerger true (懒人方法)报错14:Library Project里面的 BuildConfig.DEBUG永远都是false 。这是Android Studio的一个已知问题,某Google的攻城狮说,Library projects目前只会生成release的包。Issue 52962: https://code.google.com/p/android/issues/detail?id=52962解决方法: (某Google的攻城狮推荐的方法)Workaround: instaed of BuildConfig.DEBUG create another boolean variable at lib-project's e.g. BuildConfig.RELEASE and link it with application's buildType. https://gist.github.com/almozavr/d59e770d2a6386061fcb参考stackoverflow 上的这篇帖:http://stackoverflow.com/questions/20176284/buildconfig-debug-always-false-when-building-library-projects-with-gradle报错15:每次保存的时候,每行多余的空格和TAB会被自动删除(例如结尾、空行的多余空格或TAB)特别是每次准备提交SVN,Review代码时候你就蛋疼了,显示一堆不相关的更改,看的眼花。解决方法:Settings->IDE Settings->Editor->Other->Strip trailing spaces on Save->None问题四:编译的时候,报:Failure [INSTALL_FAILED_OLDER_SDK]。一般是系统自动帮你设置了compileSdkVersion 解决方法:修改build.gradle下的compileSdkVersion 'android-L'为compileSdkVersion 19(或者你本机已有的SDK即可)

标签:UnityEditor,java,Unity,报错,Android,tools,android
来源: https://www.cnblogs.com/grassgarden/p/10467849.html