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

ios刚上线,这边着手改成android版本,我开始使用的是unity2017.4.1版本

上传谷歌商店是出现这两个警告:

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

要支持64位,但是在2017版本上没有找到64位的打包选项,猜测应该是版本的问题,上网查询果然是

以下是我查询的:

https://www.cnblogs.com/cnxkey/articles/9760391.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错误

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zgwxyp.html