2019安卓打包只有gradle模式了,由於谷歌把adt刪了html
unity2019能夠自定義gradle模板,國內請把repo地址改爲阿里雲的源android
引擎版本:unity2019.3.7f1json
android sdk,我僅保留28,29三個平臺,system-images 僅保留23,29壓縮後是2.5G,Android SDK Tools Version>26.1.1maven
jdk提示須要JDK1.8 64位gradle
家裏電腦上安裝的是:openjdk/16,打包會彈出提示版本不匹配,因此仍是請安裝JDK而不是OpenJDKui
華爲JDK國內鏡像:https://mirrors.huaweicloud.com/openjdk/google
此環境配置打包出來的APK可在mumu模擬器安卓6.0上正常跑阿里雲
在斷網的狀況下,使用unity2018.4.15在打包apk時會報沒法鏈接到遠程的google.xxx,沒法打包出apk,嘗試過從其它電腦拷貝.gradle到打包機上,仍是出現同樣的提示,因此放棄離線的方法。url
以unity2019.3.7f1爲例,在Unity的安裝目錄下,找到:PlaybackEngines/AndroidPlayer/Tools/GradleTemplates/baseProjectTemplate.gradlespa
替換這個文件的內容爲以下,重啓Unity進行build,下載一次以後後面build就會很快了。
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN allprojects { buildscript { repositories {**ARTIFACTORYREPOSITORY** maven{ url 'https://maven.aliyun.com/repository/google'} //google() maven{ url 'https://maven.aliyun.com/repository/jcenter'} //jcenter() } dependencies { // If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity // See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html // See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle // To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version classpath 'com.android.tools.build:gradle:3.4.0' **BUILD_SCRIPT_DEPS** } } repositories {**ARTIFACTORYREPOSITORY** maven{ url 'https://maven.aliyun.com/repository/google'} //google() maven{ url 'https://maven.aliyun.com/repository/jcenter'} //jcenter() flatDir { dirs "${project(':unityLibrary').projectDir}/libs" } } } task clean(type: Delete) { delete rootProject.buildDir }