ios剛上線,這邊著手改成android版本,我開始使用的是unity2017.4.1版本 上傳谷歌商店是出現這兩個警告: 要支持64位,但是在2017版本上沒有找到64位的打包選項,猜測應該是版本的問題,上網查詢果然是 以下是我查詢的: https://www.cnblogs.com/cnxkey ...
ios剛上線,這邊著手改成android版本,我開始使用的是unity2017.4.1版本
上傳谷歌商店是出現這兩個警告:
要支持64位,但是在2017版本上沒有找到64位的打包選項,猜測應該是版本的問題,上網查詢果然是
以下是我查詢的:
https://www.cnblogs.com/cnxkey/articles/9760391.html
http://tieba.baidu.com/p/5496282855
http://dy.163.com/v2/article/detail/E9LQND6M0526E124.html
怎樣打包64位和Androi APP Bundle上面他們講解的都很詳細,而且還講解了為什麼google要支持64位,非常感謝他們分享。
一:我下載了新的unity2018.4.1,開始先鍵一個demo,裡面就隨便建了個ui,然後開始打包
1:在PlaySettings->other settings->Scriptiing Backend 選擇IL2CPP(預設是Mono),
c++ Compiler Configuration 選擇Release
Target Architectures 裡面的Arm64就是可以說勾選的了,勾選打包即可
2:Androi APP Bundley優化在Build Sttings 勾選Build App Bundle(Google Play)即可,打出的是aab包
打包運行成功。
註:要死測試的話就用Mono打包吧,畢竟IL2CPP打包要慢上幾倍
二:2017.4.1轉成2018.4.1時產生的部分bug
1:google admob 產生廣告bug
在2017.4.1廣告是沒問題的,移植到2018版本出現此問題
E/Unity: AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.ads.AdRequest$Builder
java.lang.ClassNotFoundException: com.google.android.gms.ads.AdRequest$Builder
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:308)
at java.lang.Class.forName(Class.java:272)
at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
at com.unity3d.player.UnityPlayer.c(Unknown Source)
at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source)
at android.os.MessageQueue.next(MessageQueue.java:211)
at android.os.Looper.loop(Looper.java:122)
at com.unity3d.player.UnityPlayer$e.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.AdRequest$Builder" on path: DexPathList[[zip file "/data/app/com.newqwx.crushminer-1/base.apk"],nativeLibraryDirectories=[/data/app/com.newqwx.crushminer-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.la
beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.newqwx.crushminer, PID: 13331
java.lang.Error: FATAL EXCEPTION [main]
Unity version : 2018.4.1f1
Device model : motorola Nexus 6
Device fingerprint: google/shamu/shamu:5.0/LRX21O/1570415:user/release-keys
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/MobileAds;
at com.google.unity.ads.RewardBasedVideo$1.run(RewardBasedVideo.java:65)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAds" on path: DexPathList[[zip file "/data/app/com.newqwx.crushminer-1/base.apk"],nativeLibraryDirectories=[/data/app/com.newqwx.crushminer-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.google.unity.ads.RewardBasedVideo$1.run(RewardBasedVideo.java:65)?
at android.os.Handler.handleCallback(Handler.java:739)?
at android.os.Handler.dispatchMessage(Handler.java:95)?
at android.os.Looper.loop(Looper.java:135)?
at android.app.ActivityThread.main(ActivityThread.java:5221)?
at java.lang.reflect.Method.invoke(Native Method)?
at java.lang.reflect.Method.invoke(Method.java:372)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)?
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.ads.MobileAds
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 10 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
解決方法:Assets->Play services Resolver ->Android Resolver->Resolve 解決
但由此可能產生下麵打包的bug
2:產生的打包的Gradle錯誤
CommandInvokationFailure: Gradle build failed.
D:/java/jdk1.8.0_181\bin\java.exe -classpath "D:\Unity2018.4\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4086m" "assembleRelease"
stderr[
D8: Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForRelease'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\27.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\35.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\73.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\31.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\74.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\57.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\29.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\34.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\58.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\36.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\26.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\32.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\37.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\30.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\65.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\22.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\48.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\0.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\14.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\1.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\23.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\9.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\49.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\41.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\15.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\59.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\7.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\46.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\33.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\63.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\16.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\40.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\6.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\8.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\47.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\64.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\21.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\17.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\52.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\60.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\51.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\44.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\18.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\4.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\45.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\28.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\53.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\10.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\19.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\50.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\5.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\54.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\11.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\2.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\24.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\38.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\12.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\25.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\62.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\55.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\42.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\39.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\61.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\43.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\13.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\56.jar, F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\3.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 7s
]
stdout[
Observed package id 'tools' in inconsistent location 'F:\Environment\SDK\Android_SDK_Tools\android-sdk-windows\tempToolsDir' (Expected 'F:\Environment\SDK\Android_SDK_Tools\android-sdk-windows\tools')
:checkReleaseClasspath
:preBuild UP-TO-DATE
:GoogleMobileAdsPlugin:preBuild UP-TO-DATE
:GoogleMobileAdsPlugin:preReleaseBuild UP-TO-DATE
:GoogleMobileAdsPlugin:checkReleaseManifest
:GoogleMobileAdsPlugin:processReleaseManifest
:IronSource:preBuild UP-TO-DATE
:IronSource:preReleaseBuild UP-TO-DATE
:IronSource:checkReleaseManifest
:IronSource:processReleaseManifest
:unity-android-resources:preBuild UP-TO-DATE
:unity-android-resources:preReleaseBuild UP-TO-DATE
:unity-android-resources:checkReleaseManifest
:unity-android-resources:processReleaseManifest
:preReleaseBuild
:GoogleMobileAdsPlugin:compileReleaseAidl NO-SOURCE
:IronSource:compileReleaseAidl NO-SOURCE
:unity-android-resources:compileReleaseAidl NO-SOURCE
:compileReleaseAidl NO-SOURCE
:GoogleMobileAdsPlugin:packageReleaseRenderscript NO-SOURCE
:IronSource:packageReleaseRenderscript NO-SOURCE
:unity-android-resources:packageReleaseRenderscript NO-SOURCE
:compileReleaseRenderscript UP-TO-DATE
:checkReleaseManifest UP-TO-DATE
:generateReleaseBuildConfig
:prepareLintJar UP-TO-DATE
:mainApkListPersistenceRelease
:generateReleaseResValues UP-TO-DATE
:generateReleaseResources UP-TO-DATE
:GoogleMobileAdsPlugin:compileReleaseRenderscript
:GoogleMobileAdsPlugin:generateReleaseResValues
:GoogleMobileAdsPlugin:generateReleaseResources
:GoogleMobileAdsPlugin:packageReleaseResources
:IronSource:compileReleaseRenderscript
:IronSource:generateReleaseResValues
:IronSource:generateReleaseResources
:IronSource:packageReleaseResources
:unity-android-resources:compileReleaseRenderscript
:unity-android-resources:generateReleaseResValues
:unity-android-resources:generateReleaseResources
:unity-android-resources:packageReleaseResources
:mergeReleaseResources UP-TO-DATE
:createReleaseCompatibleScreenManifests
:processReleaseManifest
:splitsDiscoveryTaskRelease UP-TO-DATE
:GoogleMobileAdsPlugin:generateReleaseRFile
:IronSource:generateReleaseRFile
:unity-android-resources:generateReleaseRFile
:processReleaseResources
:generateReleaseSources
:GoogleMobileAdsPlugin:generateReleaseBuildConfig
:GoogleMobileAdsPlugin:prepareLintJar UP-TO-DATE
:GoogleMobileAdsPlugin:generateReleaseSources
:GoogleMobileAdsPlugin:javaPreCompileRelease
:GoogleMobileAdsPlugin:compileReleaseJavaWithJavac
:GoogleMobileAdsPlugin:processReleaseJavaRes NO-SOURCE
:GoogleMobileAdsPlugin:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease
:IronSource:generateReleaseBuildConfig
:IronSource:prepareLintJar UP-TO-DATE
:IronSource:generateReleaseSources
:IronSource:javaPreCompileRelease
:IronSource:compileReleaseJavaWithJavac
:IronSource:processReleaseJavaRes NO-SOURCE
:IronSource:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease
:unity-android-resources:generateReleaseBuildConfig
:unity-android-resources:prepareLintJar UP-TO-DATE
:unity-android-resources:generateReleaseSources
:unity-android-resources:javaPreCompileRelease
:unity-android-resources:compileReleaseJavaWithJavac
:unity-android-resources:processReleaseJavaRes NO-SOURCE
:unity-android-resources:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease
:javaPreCompileRelease
:compileReleaseJavaWithJavac
:compileReleaseNdk NO-SOURCE
:compileReleaseSources
:lintVitalRelease
:mergeReleaseShaders UP-TO-DATE
:compileReleaseShaders UP-TO-DATE
:generateReleaseAssets UP-TO-DATE
:GoogleMobileAdsPlugin:mergeReleaseShaders
:GoogleMobileAdsPlugin:compileReleaseShaders
:GoogleMobileAdsPlugin:generateReleaseAssets
:GoogleMobileAdsPlugin:packageReleaseAssets
:IronSource:mergeReleaseShaders
:IronSource:compileReleaseShaders
:IronSource:generateReleaseAssets
:IronSource:packageReleaseAssets
:unity-android-resources:mergeReleaseShaders
:unity-android-resources:compileReleaseShaders
:unity-android-resources:generateReleaseAssets
:unity-android-resources:packageReleaseAssets
:mergeReleaseAssets
:transformClassesWithDexBuilderForRelease
C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\recyclerview-v7.aar\abd41c74047d7be064a61e8696b02349\jars\classes.jar: D8: Type `android.support.v4.animation.AnimatorCompatHelper` was not found, it is required for default or static interface methods desugaring of `void android.support.v7.widget.DefaultItemAnimator.resetAnimation(android.support.v7.widget.RecyclerView$ViewHolder)`
C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\recyclerview-v7.aar\abd41c74047d7be064a61e8696b02349\jars\classes.jar: D8: Interface `android.support.v4.animation.AnimatorListenerCompat` not found. It's needed to make sure desugaring of `android.support.v7.widget.helper.ItemTouchHelper$RecoverAnimation` is correct. Desugaring will assume that this interface has no default method.
C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\recyclerview-v7.aar\abd41c74047d7be064a61e8696b02349\jars\classes.jar: D8: Interface `android.support.v4.animation.AnimatorUpdateListenerCompat` not found. It's needed to make sure desugaring of `android.support.v7.widget.helper.ItemTouchHelper$RecoverAnimation$1` is correct. Desugaring will assume that this interface has no default method.
:transformDexArchiveWithExternalLibsDexMergerForRelease FAILED
63 actionable tasks: 52 executed, 11 up-to-date
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1 progress)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
解決方法:出現這種問題是jar包重覆。
Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\3.jar(我的最後一個是3.jar,可能不一樣)中可以看到:Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
說明android.support.v4已經存在,就是說有兩個,一個新的一個舊的,找到刪掉就可以
我的是 support-v4-compat.jar和剛剛導入的 com.android.support.support-v4-26.1.0重覆,我刪掉了support-v4-compat.jar,就可以打包了
3:IL2CPP打包時中斷,停止運行
Failed running D:\Unity2018.4\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="net20" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --configuration="Release" --outputpath="F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp/StagingArea\assets\bin\Data\Native\armeabi-v7a\libil2cpp.so" --cachedirectory="F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Assets\..\Library\il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="D:\Unity2018.4\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\bdwgc/include" --additional-include-directories="D:\Unity2018.4\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\libil2cpp/include" --tool-chain-path="F:/Environment/NDK/android-ndk-r16b-windows-x86_64/android-ndk-r16b" --map-file-parser="D:\Unity2018.4\Editor\Data\Tools\MapFileParser\MapFileParser.exe" --directory="F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\StagingArea\assets\bin\Data\Managed" --generatedcppdir="F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\StagingArea\Il2Cpp\il2cppOutput"
stdout:
Building libil2cpp.so with AndroidToolChain
Output directory: F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a
Cache directory: F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Library\il2cpp_android_armeabi-v7a\il2cpp_cache
ObjectFiles: 644 of which compiled: 0
Total compilation time: 995 milliseconds.
il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: F:\Environment\NDK\android-ndk-r16b-windows-x86_64\android-ndk-r16b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ @"C:\Users\Administrator\AppData\Local\Temp\tmp4146.tmp" -o "F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Library\il2cpp_android_armeabi-v7a\il2cpp_cache\linkresult_37EBD535B6A775512618C151CBF4CE6A\libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id --sysroot "F:\Environment\NDK\android-ndk-r16b-windows-x86_64\android-ndk-r16b\platforms\android-16\arch-arm" -gcc-toolchain "F:\Environment\NDK\android-ndk-r16b-windows-x86_64\android-ndk-r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" -target armv7-none-linux-androideabi -Wl,--wrap,sigaction -L "F:\Environment\NDK\android-ndk-r16b-windows-x86_64\android-ndk-r16b\sources\cxx-stl\gnu-libstdc++\4.9\libs\armeabi-v7a" -lgnustl_static -llog -rdynamic -fuse-ld=gold.exe
F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp_9.cpp:34995: error: undefined reference to '_copyToPasteboardWithText'
F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp_9.cpp:35099: error: undefined reference to '_shareWithText'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
在 Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
在 Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
在 il2cpp.Program.DoRun(String[] args)
在 il2cpp.Program.Run(String[] args)
在 il2cpp.Program.Main(String[] args)
stderr:
未經處理的異常: Unity.IL2CPP.Building.BuilderFailedException: F:\Environment\NDK\android-ndk-r16b-windows-x86_64\android-ndk-r16b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ @"C:\Users\Administrator\AppData\Local\Temp\tmp4146.tmp" -o "F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Library\il2cpp_android_armeabi-v7a\il2cpp_cache\linkresult_37EBD535B6A775512618C151CBF4CE6A\libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id --sysroot "F:\Environment\NDK\android-ndk-r16b-windows-x86_64\android-ndk-r16b\platforms\android-16\arch-arm" -gcc-toolchain "F:\Environment\NDK\android-ndk-r16b-windows-x86_64\android-ndk-r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" -target armv7-none-linux-androideabi -Wl,--wrap,sigaction -L "F:\Environment\NDK\android-ndk-r16b-windows-x86_64\android-ndk-r16b\sources\cxx-stl\gnu-libstdc++\4.9\libs\armeabi-v7a" -lgnustl_static -llog -rdynamic -fuse-ld=gold.exe
F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp_9.cpp:34995: error: undefined reference to '_copyToPasteboardWithText'
F:\Unity\CrushMiner\CrushMiner9.11Optimize2018.4.1\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp_9.cpp:35099: error: undefined reference to '_shareWithText'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
在 Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
在 Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
在 il2cpp.Program.DoRun(String[] args)
在 il2cpp.Program.Run(String[] args)
在 il2cpp.Program.Main(String[] args)
UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73)
UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:368)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(String, String, String, Boolean) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:349)
UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:211)
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:35)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
解決方法:查看中斷信息:
在未經處理的異常:下麵一段找到error,error: undefined reference to '_copyToPasteboardWithText'
error:undefined reference to '_shareWithText',說未定義的引用。
這個可能是你ios的調用方法(我的是ios的方法),然後在代碼中找到用條件編譯命令#if改掉就ok了
我的方法
[DllImport("__Internal")]
private static extern void _copyToPasteboardWithText(string text);
改成
#if UNITY_IOS
[DllImport("__Internal")]
private static extern void _copyToPasteboardWithText(string text);
#endif
所有問題解決,完美打包運行!!!
有什麼問題或錯誤的地方歡迎討論指正,謝謝。