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
所有问题解决,完美打包运行!!!
有什么问题或错误的地方欢迎讨论指正,谢谢。