我已经尝试构建我的 Android 应用程序有一段时间了,但似乎找不到解决此问题的任何解决方案:
前言 该项目是在2021.3.22f1版本上构建的,需要将Android API版本提升到34。这次升级后,该项目已组装完毕,我们将其发布到商店。但在那里发现了一个问题,即设备崩溃。该问题已被定位,并联系了用于收集分析的第三方服务的开发人员。他建议升级到Unity版本2022.3.50f1。
转换后,构建因错误而停止构建
CommandInvokationFailure: Gradle build failed.
/Applications/Unity/Hub/Editor/2022.3.50f1/PlaybackEngines/AndroidPlayer/OpenJDK/bin/java -classpath "/Applications/Unity/Hub/Editor/2022.3.50f1/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-7.5.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "bundleRelease"
Environment Variables:
AMPLITUDE_API_KEY_REDBUCKET_DEV = 46b8b46515e7632fc42a504b72e05fd0
DEBUG_ENV_VAR = UnityHub
XPC_FLAGS = 0x0
__CFBundleIdentifier = com.unity3d.unityhub
AMPLITUDE_API_KEY_GREENBUCKET_DEV = 3ded2a762163603391a425f688f990c8
AMPLITUDE_TOKEN_REDBUCKET_DEV = U4PSN7S7PuYVRODivvdcFwbu8R6IHGqa
COMMAND_MODE = unix2003
AMPLITUDE_API_KEY_GREENBUCKET_PROD = c86fea37a9e1d3f0878b96e15b111c7c
SENTRY_ACCESS_TOKEN = 3df78d9e53f8456aa90fbae044ce1a6261421ab1d0014674bc2e933477289017
JAVA_HOME = /Applications/Unity/Hub/Editor/2022.3.50f1/PlaybackEngines/AndroidPlayer/OpenJDK
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_DEV = client-wbjHYrmeSR87GmWOE7LDpf7sUySOIKHm
AMPLITUDE_TOKEN_GREENBUCKET_PROD = ZpUcbAdZXJYzNSoHsAWtL_s_JppwWid9
AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa
XPC_SERVICE_NAME = application.com.unity3d.unityhub.11447275.11447284
ANDROID_NDK_ROOT = /Applications/Unity/Hub/Editor/2022.3.50f1/PlaybackEngines/AndroidPlayer/NDK
AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21
WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3
USER = honkhonk
MallocNanoZone = 0
LOGNAME = honkhonk
__CF_USER_TEXT_ENCODING = 0x1F5:0x7:0x31
AMPLITUDE_API_KEY_YELLOWBUCKET_DEV = 48835b4d1f5e342aefe5f016324d296a
PATH = /usr/bin:/bin:/usr/sbin:/sbin
SSH_AUTH_SOCK = /private/tmp/com.apple.launchd.e1gIWyZsRS/Listeners
AMPLITUDE_API_KEY_YELLOWBUCKET_PROD = e03a9bbe92dc38a88cdb068d24c65b46
AMPLITUDE_TOKEN_REDBUCKET_PROD = jTIgKs5KTZOjiqEEVdZFbgo_VRhABduL
AMPLITUDE_TOKEN_YELLOWBUCKET_PROD = UYDQtPOw83dIfVy3SrW5oMyo7ru4PRkV
HOME = /Users/honkhonk
TMPDIR = /var/folders/30/z0ysz4t50yxdm_6hfm03v1bh0000gn/T/
AMPLITUDE_TOKEN_GREENBUCKET_DEV = 84H2gMm_FJzhr3mBaX1lM1JVukmCM7d9
AMPLITUDE_TOKEN_YELLOWBUCKET_DEV = wKi8foVigDditGFvmZewRFWsEbX9Y0YO
SHELL = /bin/zsh
AMPLITUDE_API_KEY_REDBUCKET_PROD = ca12bb461ea96f9bdf5df4ded7d52994
AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_PROD = client-zH8Y7OK1i331EKuG77C6UxN8ygcM6LzS
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
stderr[
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/Users/honkhonk/MyWellnessStory/Library/Bee/Android/Prj/IL2CPP/Gradle/launcher/build.gradle' line: 8
* What went wrong:
A problem occurred evaluating project ':launcher'.
> Could not find method namespace() for arguments [com.SiberianWellness.WayToWellness] on extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':launcher'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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 2s
这是 gradle
apply plugin: 'com.android.application'
dependencies {
implementation project(':unityLibrary')
}
android {
namespace "com.SiberianWellness.WayToWellness"
ndkPath "/Applications/Unity/Hub/Editor/2022.3.50f1/PlaybackEngines/AndroidPlayer/NDK"
compileSdkVersion 35
buildToolsVersion '34.0.0'
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
defaultConfig {
minSdkVersion 23
targetSdkVersion 35
applicationId 'com.SiberianWellness.WayToWellness'
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
versionCode 181
versionName '3.20.5'
}
aaptOptions {
noCompress = ['.unity3d', '.ress', '.resource', '.obb', '.bundle', '.unityexp'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
}
signingConfigs {
release {
storeFile file('/Users/honkhonk/MyWellnessStory/OtherFiles/ForAutoBuild/user.keystore')
storePassword 'StoryWellnessMy2020'
keyAlias 'publish'
keyPassword 'StoryWellnessMy2020'
}
}
lintOptions {
abortOnError false
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.release
jniDebuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.release
}
}
packagingOptions {
doNotStrip '*/armeabi-v7a/*.so'
doNotStrip '*/arm64-v8a/*.so'
jniLibs {
useLegacyPackaging true
}
}
bundle {
language {
enableSplit = false
}
density {
enableSplit = false
}
abi {
enableSplit = true
}
}
}
我一直在尝试在谷歌中搜索答案。
构建 API 级别 34 的最低 AGP 版本是 8.1.1。构建 API 级别 35 的最低 AGP 版本是 8.6.0
classpath "com.android.tools.build:gradle:8.6.0"
并且你还需要相应升级Gradle版本