Unity上線google商店 用IL2Cpp打包64位版本和Android APP Bundle優化 及產生的bug

来源:https://www.cnblogs.com/INSIST-NLJY/archive/2019/06/18/11044558.html
-Advertisement-
Play Games

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

 

所有問題解決,完美打包運行!!!

 

有什麼問題或錯誤的地方歡迎討論指正,謝謝。

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 前言:時間緊,先寫關鍵代碼,以後優化: 在此感謝其他博友分享的文章,參考文章:C#反射委托創建器 1-定義含有委托的類: 2-初始化類: 創建委托方法1--創建靜態方法的委托,只需要2個參數:委托類型和方法信息: Delegate.CreateDelegate(typeof(Action<TimeC ...
  • 前言:為了節約時間,先只粘貼關鍵代碼: 1-添加section標簽,name為自定義標簽名稱,type為:命名空間+類型,程式集名稱 2-自定義標簽數據: watchModel為自定義標簽(ConfigurationSection),watchItems為自定義標簽的數據集(Configuratio ...
  • 一、創建項目 新建api項目: 建好之後,一個預設的控制器已經有了: 運行就可以直接訪問get介面獲取數據: 二、跨平臺部署 部署方面,微軟已經完善的很好了,基本上算是傻瓜式操作。項目右鍵選擇發佈: 部署模式可以採用框架依賴,或獨立,選擇框架依賴,則需要在目標平臺安裝netcore運行時後才能運行n ...
  • LnskyDB " " " " LnskyDB是基於Dapper的Lambda擴展,支持按時間分庫分表,也可以自定義分庫分表方法.而且可以T4生成實體類免去手寫實體類的煩惱. 文檔地址: https://liningit.github.io/LnskyDB/ 開源地址: https://github ...
  • (迄今為止網上那些說的用Encoding.Default解決中文文件名亂碼的都不能真正解決問題!) 1、在程式開始處 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); 2、設置編碼為GBK ...
  • 測試代碼: 不忘初心,方得始終;初心易得,始終難守。 ...
  • asp.net core系統自帶的異常頁面色彩給人感覺模糊、朦朧,暈眩! 原版: 美化版 實現思路:(在系統自帶異常中間件“DeveloperExceptionPageMiddleware”執行後,調用自定義的異常中間件“DeveloperExceptionPrettifyMiddleware”,繼 ...
  • 這兩天做項目的時候偶然發現項目中的保存功能的時候出現這樣的異常:異常詳細信息: System.Web.HttpRequestValidationException: 從客戶端(XXXX)中檢測到有潛在危險的 Request.Form 值。經過查詢調試發現,保存的文本中存在回車符,<br/>標簽作為參 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...