You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity升级至2022.3.20f1后Android Gradle构建失败求助

Unity 2022.3.20f1 Android Gradle构建失败:android.enableR8无法解析为布尔值

项目升级到Unity 2022.3.20f1后,未修改其他配置,但Android平台Gradle构建失败。报错核心信息为:Cannot parse project property android.enableR8='' of type 'class java.lang.String' as boolean. Expected 'true' or 'false'。已尝试移除自定义gradleTemplate.properties中的android.enableR8=**MINIFY_WITH_R_EIGHT**行,但问题仍未解决。


完整错误日志

CommandInvokationFailure: Gradle build failed. 
C:\Unity\Hub\Editor\2022.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Unity\Hub\Editor\2022.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.2.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

Environment Variables:
PROCESSOR_ARCHITECTURE = AMD64
TEMP = C:\Users\eduar\AppData\Local\Temp
BURST_ANDROID_MIN_API_LEVEL = 22
DriverData = C:\Windows\System32\Drivers\DriverData
USERDOMAIN = EDUARDO-WINDOWS
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
COMPUTERNAME = EDUARDO-WINDOWS
DEBUG_ENV_VAR = UnityHub
LOGONSERVER = \\EDUARDO-WINDOWS
AMPLITUDE_TOKEN_GREENBUCKET_PROD = yyzPzalJDwrQcYNuOZam0bhKb26WyyhK
AMPLITUDE_API_KEY_YELLOWBUCKET_DEV = 48835b4d1f5e342aefe5f016324d296a
ProgramData = C:\ProgramData
AMPLITUDE_TOKEN_YELLOWBUCKET_PROD = Ph-837Q6GNodAkyc2MRkxVPUcjlIET4d
RlsSvcPort = 22112
KINECTSDK10_DIR = C:\Program Files\Microsoft SDKs\Kinect\v1.8\
SystemRoot = C:\Windows
windir = C:\Windows
AMPLITUDE_API_KEY_REDBUCKET_DEV = 46b8b46515e7632fc42a504b72e05fd0
ProgramFiles(x86) = C:\Program Files (x86)
KINECT_TOOLKIT_DIR = C:\Program Files\Microsoft SDKs\Kinect\Developer Toolkit v1.8.0\
ProgramW6432 = C:\Program Files
ChocolateyLastPathUpdate = 133239957005853949
OS = Windows_NT
ANDROID_NDK_ROOT = C:\Unity\Hub\Editor\2022.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK
PROCESSOR_IDENTIFIER = AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD
HEAP_CLIENT_TOKEN_STAGING = 3786794399
HOMEPATH = \Users\eduar
AMPLITUDE_TOKEN_REDBUCKET_DEV = U4PSN7S7PuYVRODivvdcFwbu8R6IHGqa
JetBrains Rider = C:\Program Files\JetBrains\JetBrains Rider 2023.3.3\bin;
ACSetupSvcPort = 23210
CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_3436_WKYURVMWGMWQFJEM
PROCESSOR_LEVEL = 25
APPDATA = C:\Users\eduar\AppData\Roaming
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
CommonProgramFiles = C:\Program Files\Common Files
PUBLIC = C:\Users\Public
USERDOMAIN_ROAMINGPROFILE = EDUARDO-WINDOWS
JAVA_HOME = C:\Unity\Hub\Editor\2022.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramW6432 = C:\Program Files\Common Files
AMPLITUDE_TOKEN_YELLOWBUCKET_DEV = wKi8foVigDditGFvmZewRFWsEbX9Y0YO
AMPLITUDE_API_KEY_GREENBUCKET_DEV = 3ded2a762163603391a425f688f990c8
AMPLITUDE_API_KEY_REDBUCKET_PROD = ca12bb461ea96f9bdf5df4ded7d52994
ChocolateyInstall = C:\ProgramData\chocolatey
HOMEDRIVE = C:
AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21
USERNAME = eduar
OneDrive = C:\Users\eduar\OneDrive
AMPLITUDE_API_KEY_YELLOWBUCKET_PROD = e03a9bbe92dc38a88cdb068d24c65b46
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
AMPLITUDE_TOKEN_REDBUCKET_PROD = QqyoFpcWPi7V17p80_46CF6-sNGRGbHo
FTSDK_DIR = C:\Program Files\Microsoft SDKs\Kinect\Developer Toolkit v1.8.0\
NUMBER_OF_PROCESSORS = 12
VBOX_MSI_INSTALL_PATH = C:\Program Files\Oracle\VirtualBox\
AMPLITUDE_TOKEN_GREENBUCKET_DEV = 84H2gMm_FJzhr3mBaX1lM1JVukmCM7d9
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_DEV = client-wbjHYrmeSR87GmWOE7LDpf7sUySOIKHm
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
AMPLITUDE_API_KEY_GREENBUCKET_PROD = c86fea37a9e1d3f0878b96e15b111c7c
ComSpec = C:\Windows\system32\cmd.exe
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
PROCESSOR_REVISION = 5000
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_PROD = client-zH8Y7OK1i331EKuG77C6UxN8ygcM6LzS
TMP = C:\Users\eduar\AppData\Local\Temp
SystemDrive = C:
AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa
ACSvcPort = 17532
SENTRY_ACCESS_TOKEN = 3df78d9e53f8456aa90fbae044ce1a6261421ab1d0014674bc2e933477289017
HEAP_CLIENT_TOKEN = 1717415662
ALLUSERSPROFILE = C:\ProgramData
Path = C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Inkscape\bin;C:\ProgramData\chocolatey\bin;C:\Android\platform-tools;C:\php;C:\Program Files\Git\cmd;C:\Users\eduar\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\eduar\AppData\Local\Programs\Python\Python311\;C:\Users\eduar\AppData\Local\Microsoft\WindowsApps;C:\Users\eduar\AppData\Local\GitHubDesktop\bin;C:\Users\eduar\AppData\Local\GitHubDesktop\app-3.2.1\resources\app\git\cmd;C:\Users\eduar\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\JetBrains\JetBrains Rider 2023.3.3\bin;
MOZ_PLUGIN_PATH = C:\Program Files (x86)\Foxit Software\Foxit PDF Reader\plugins\
ProgramFiles = C:\Program Files
LOCALAPPDATA = C:\Users\eduar\AppData\Local
USERPROFILE = C:\Users\eduar
WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3


stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\Unity\Projects\Rush-It\Rush-It\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':launcher'.
> Failed to apply plugin 'com.android.internal.application'.
   > Cannot parse project property android.enableR8='' of type 'class java.lang.String' as boolean. Expected 'true' or 'false'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
]
stdout[
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <350bddde343340be9c3b2ea115fe87e9>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <350bddde343340be9c3b2ea115fe87e9>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <350bddde343340be9c3b2ea115fe87e9>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <350bddde343340be9c3b2ea115fe87e9>:0)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <350bddde343340be9c3b2ea115fe87e9>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <350bddde343340be9c3b2ea115fe87e9>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <350bddde343340be9c3b2ea115fe87e9>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <350bddde343340be9c3b2ea115fe87e9>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

自定义AndroidManifest.xml

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:amazon="http://schemas.amazon.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.DevPenguin.RushIt" platformBuildVersionCode="23" >
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true"/>
    <application android:debuggable="false" android:icon="@drawable/app_icon" android:isGame="true" android:label="@string/app_name" android:theme="@style/UnityThemeSelector">
        <activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:label="@string/app_name" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity" android:screenOrientation="fullSensor">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true"/>
        </activity>
        
        <amazon:enable-feature android:name="com.amazon.device.messaging" android:required="false"/>
        <service android:name="com.onesignal.ADMMessageHandler" android:exported="false" />
        <receiver android:name="com.onesignal.ADMMessageHandler$Receiver"
                  android:permission="com.amazon.device.messaging.permission.SEND" >
          <intent-filter>
            <action android:name="com.amazon.device.messaging.intent.REGISTRATION" />
            <action android:name="com.amazon.device.messaging.intent.RECEIVE" />
            <category android:name="com.DevPenguin.RushIt" />
          </intent-filter>
        </receiver>
    </application>
    <uses-feature android:glEsVersion="0x20000"/>
    <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
    <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false"/>
    <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false"/>
    
    <uses-permission android:name="com.amazon.device.messaging.permission.RECEIVE" />
    <permission android:name="com.DevPenguin.RushIt.permission.RECEIVE_ADM_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.DevPenguin.RushIt.permission.RECEIVE_ADM_MESSAGE" />
</manifest>

自定义gradleTemplate.properties

org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
unityStreamingAssets=.unity3d**STREAMING_ASSETS**
# Android Resolver Properties Start
android.useAndroidX=true
android.enableJetifier=true
# Android Resolver Properties End
**ADDITIONAL_PROPERTIES**

解决方法

1. 明确设置R8开关值

在自定义gradleTemplate.properties中直接添加android.enableR8的布尔值,替换原本的变量占位逻辑:

org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
unityStreamingAssets=.unity3d**STREAMING_ASSETS**
# Android Resolver Properties Start
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true # 或根据需求设置为false
# Android Resolver Properties End
**ADDITIONAL_PROPERTIES**

2. 检查Unity发布设置的Minify选项

打开Edit > Project Settings > Player > Android > Publishing Settings:

  • 确保Release和Debug模式下的Minify选项选择R8或None,不要留空
  • 如果启用R8,确认`
相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 00:19:46