settingsTemplate.gradle是新增的一个文件,用于统一管理所有的maven依赖加载路径。
mainTemplate.gradle有所变化,主要如下标红行
android {
namespace "com.unity3d.player"
ndkPath "**NDKPATH**"
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
... ....aaptOptions {
noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}**REPOSITORIES****SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
baseProjectTemplate.gradle文件的内容基本全变化,maven相关的迁移到了settingsTemplate.gradle,可以新建个空项目 然后看默认的baseProjectTemplate.gradle文件,我的如下:
plugins {
// 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
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
**BUILD_SCRIPT_DEPS**
}task clean(type: Delete) {
delete rootProject.buildDir
}
各种相关依赖加载失败问题,例如下
Could not find com.google.android.gms:play-services-auth:xx.xx.xx Could not find com.google.firebase:firebase-messaging:23.3.1.
调整settingsTemplate.gradle文件的maven,必须添加有
google()
mavenCentral()
并且位于最前方,如果你还有其他的maven{ url ... } 请放置在它们下方。
务必删除mainTemplate.gradle的所有maven{ url ... },所以查到是仍然支持的,但现在只需要settingsTemplate.gradle。