Unity上线google商店 用IL2Cpp打包64位版本和Android APP Bundle优化 及产生的bug

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

所有问题解决,完美打包运行!!!

有什么问题或错误的地方欢迎讨论指正,谢谢。

原文地址:https://www.cnblogs.com/INSIST-NLJY/p/11044558.html

时间: 2024-11-02 00:38:45

Unity上线google商店 用IL2Cpp打包64位版本和Android APP Bundle优化 及产生的bug的相关文章

Windows 8.1 64位版本安装.Net Framework3.5

最近刚把个人电脑切换成了Win 8.1 64位版本,但在使用某些Ms的某此产品时会提示没有安装.Net Framework3.5,但按照他的提示需要在线安装而且速度很慢,因为之前搞过WinServer2102的安装知道可以指定安装路径的,但在系统上没有找到,于是求助Google在一个网友的博客里找到并安装成功 注意下面的Cmd需要用管理员权限运行"E:\HTL\System\Windows\Win81\"是我本地的Win81系统镜像 可以使用"DAEMON Tools&quo

64位ubuntu下Android开发环境的配置

本文介绍如何在64位ubuntu上搭建android的开发环境. 系统:ubuntu12.04LTS 使用的是ADT Bundle for Linux和jdk1.7(open jdk也可) 一共分为3步走: 1.配置JDK 安装Open jdk $sudo apt-get install openjdk-7-jdk 或 从oracle官网下载 从官网下载JDK64位版 解压安装 将解压出的文件用最高权限复制到/usr/lib/jvm里 sudo cp -r ~/jdk1.7/ /usr/lib/

PLSQL Developer 没有64位版本 + 找不到 msvcr71.dll

由于 PLSQL Developer 没有64位版本,所以在64位系统上运行该程链接64位Oracle时就会报错,笔者为这个问题纠结了好几天,后来通过请教Google + 动手实践,终于搞定了这个问题.现在把笔者解决的过程记录下来,分享给遇到同样问题的网友们. 首先到Oracle官网上下载一个32位的客户端(instantclient),一定要下载 basic 版本的,不要下载 basiclite 版本的.笔者刚开始下载的是 basiclite 版本的,结果不好使,后来对比才发现, basicl

关于64位Linux配置android开发环境出现 No such file or directory

前几天在64位系统上部署android开发环境的时候出现了这种问题 /aapt: No such file or directory 通过谷老师,知道原理android SDK里面的程序全是32位的,没有64位的.不知道为啥要写个x64, 我们仅仅要安装一下32位的执行库即可了,sudo apt-get install ia32-libs,就这么简单,一键搞定. 关于64位Linux配置android开发环境出现 No such file or directory,布布扣,bubuko.com

MongoDB每64位版本下载

MongoDB每64位版本下载: http://dl.mongodb.org/dl/win32/x86_64 版权声明:本文博主原创文章,博客,未经同意不得转载.

MongoDB各个64位版本下载地址

MongoDB各个64位版本下载地址: http://dl.mongodb.org/dl/win32/x86_64

解决“无法安装64位版本的Office,因为在您的PC上找到了以下32位程序:”的问题

在安装office2013 64位版本的时候,出现"无法安装64位版本的Office,因为在您的PC上找到了以下32位程序:Office 15 Click-to-Run Extensibility Component ,请卸载所有32位Office程序,然后重试安装64位Office.如果要安装32位Office,请运行32位安装程序",出现这种情况的原因大多出现在预装系统并且自带有office的电脑上,比如带有预装系统的品牌机或笔记本等,本方案以便帮助更多的同学解决这个问题. 解决方

确定jdk是32位版本还是64位版本

到jdk目录,用文本编辑器打开release文件,里面为jdk的版本信息(以Windows的java7为例): 64位版本: JAVA_VERSION="1.7.0"OS_NAME="Windows"OS_VERSION="5.2"OS_ARCH="amd64" OS_ARCH="amd64"表示支持64位操作系统 32位版本: JAVA_VERSION="1.7.0"OS_NAME=&

如何在64位版本Linux上开发运行32位应用程序

最近换了Linux系统,由i686换成了x86-64,导致在进行开发的时候出用不了原来SDK中32位的开发工具.于是,博主找到如下文章,博主亲测实用: 如何在64位版本Linux上开发运行32位应用程序 内容如下: 很多程序员(特别是别的公司的)跟我抱怨说他们32位软件无法在我们的64位Linux系统上正常运行,而在他们32位机上正常,其实这个很好解决,一般 是64位系统安装后没有默认安装glibc的32位版本,通过简单的执行以下命令即可实现在64位Linux系统上开发运行32位应用程序,而不用