Unity中65535解决方案
由于接入过多sdk导致方法数超过65535
原生开发解决方案
在build.gradle中
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 24
...
// 设置支持multidex
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.3'
}
在app子类中
package com.example;
import android.app.Application;
import android.content.Context;
public class MyApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
unity解决方案



勾选之后打开mainTemplate.gradle
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 24
...
// 设置支持multidex
multiDexEnabled true
}
...
}
由于我所用的是unity2018.3.6f1,貌似内置android-support-multidex,如果有不包含该jar包的情况需要在plugin文件夹加入该jar
然后找到Assets/Plugins/Android目录下的AndroidManifest.xml,在application节点下添加如下所示
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" package="" android:installLocation="preferExternal">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<application
android:name="android.support.multidex.MultiDexApplication"
……>
……
</application>
……
</manifest>
如果没有AndroidManifest.xml,可参考
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" package="" android:installLocation="preferExternal">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:icon="@drawable/app_icon" android:label="@string/app_name">
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</manifest>
在加入Firebase与ADMob后发生的特殊情况
不知道是否因为这三者同时出现还是仅仅其中某两者,会发生导出后闪退的情况,此时需要在AndroidManifest.xml中application内加入meta-data内容
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" package="" android:installLocation="preferExternal">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<application
android:name="android.support.multidex.MultiDexApplication"
……>
……
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value=[APPID]/>
</application>
……
</manifest>
6969




被折叠的 条评论
为什么被折叠?



