// GENERATED BY UNITY. REMOVE THIS LINE TO PREVENT OVERWRITING WHEN CHANGING PLAYER SETTINGS // 第一步:把用来修补 D8 编译器的 buildscript 独立提拔到最外层的最顶部 buildscript { repositories { **BUILD_SCRIPT_REPOSITORIES** // 1. 添加存放新版 D8 编译器的谷歌官方仓库 maven { url 'https://storage.googleapis.com/r8-releases/raw' } } dependencies { // 2. 强制指定更高级别的 R8/D8 编译器,解决 Meta SDK 引发的 NullPointerException classpath 'com.android.tools:r8:8.2.24' **BUILD_SCRIPT_DEPENDENCIES** } } // 第二步:紧随其后的是原配 plugins 块(绝对不能被allprojects压在下面) 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** } // 第三步:将通用的 allprojects 移到文件下方安全区 allprojects { repositories { **PROJECT_REPOSITORIES** } } task clean(type: Delete) { delete rootProject.buildDir }