Flutter运行报错:无法确定:app:processDebugManifest任务依赖
Flutter构建错误:无法创建任务 ':app:processDebugMainManifest'
错误日志
FAILURE: Build failed with an exception. * 出错原因: 无法确定任务 ':app:processDebugManifest' 的依赖项。 > 无法创建任务 ':app:processDebugMainManifest'。 > 无法调用"Object.toString()",因为"value"为null * 建议操作: > 使用 --stacktrace 选项获取堆栈跟踪。 > 使用 --info 或 --debug 选项获取更多日志输出。 > 使用 --scan 获取完整分析信息。
已尝试的解决步骤
- 执行
flutter clean和flutter pub cache clean,无效 - 将compileSdkVersion更新至34
- 使用Gradle版本7.6.2-all
- 尝试过网上多种解决方案,问题仍存在
flutter doctor 输出
[√] Flutter (Channel stable, 3.22.2, on Microsoft Windows [Version 10.0.22631.3880], locale en-GH) • Flutter version 3.22.2 on channel stable at C:\Users\d.partey\Documents\Development\flutter sdks\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 761747bfc5 (7 weeks ago), 2024-06-05 22:15:13 +0200 • Engine revision edd8546116 • Dart version 3.4.3 • DevTools version 2.34.3 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at C:\Users\d.partey\AppData\Local\Android\sdk • Platform android-VanillaIceCream, build-tools 34.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [X] Visual Studio - develop Windows apps X Visual Studio not installed; this is necessary to develop Windows apps. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [√] Android Studio (version 2024.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314) [√] VS Code (version 1.91.1) • VS Code at C:\Users\d.partey\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.92.0 [√] Connected device (4 available) • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 14 (API 34) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.3880] • Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.182 • Edge (web) • edge • web-javascript • Microsoft Edge 126.0.2592.113 [√] Network resources • All expected network resources are available.
配置文件
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="world.opine.app"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.LOCATION" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="34" /> <queries> <intent> <action android:name="android.intent.action.VIEW" /> <data android:scheme="https" /> </intent> <intent> <action android:name="android.intent.action.DIAL" /> <data android:scheme="tel" /> </intent> <intent> <action android:name="android.intent.action.SEND" /> <data android:mimeType="*/*" /> </intent> </queries> <application android:icon="@mipmap/ic_launcher" android:label="Opine World" tools:replace="android:label"> <activity android:name="io.flutter.embedding.android.FlutterActivity" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density" android:exported="true" android:hardwareAccelerated="true" android:launchMode="singleTop" android:showWhenLocked="true" android:theme="@style/LaunchTheme" android:turnScreenOn="true" android:windowSoftInputMode="adjustResize"> <meta-data android:name="io.flutter.app.android.SplashScreenUntilFirstFrame" android:value="true" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <meta-data android:name="flutter_deeplinking_enabled" android:value="true" /> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="opine.world" android:scheme="http" /> <data android:scheme="https" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="opine.world" android:scheme="opine" /> </intent-filter> </activity> <activity android:name=".EmbeddingV1Activity" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale" android:hardwareAccelerated="true" android:theme="@style/LaunchTheme" android:windowSoftInputMode="adjustResize"></activity> <meta-data android:name="com.google.android.geo.API_KEY" android:value="${geoApiKEY}" /> <meta-data android:name="flutterEmbedding" android:value="2" /> <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="high_importance_channel" /> </application> </manifest>
android/build.gradle
buildscript { ext.kotlin_version = '2.0.0' ext.ndkVersion = "20.1.5948944" ext { compileSdkVersion = 34 // or latest targetSdkVersion = 34 // or latest appCompatVersion = "1.7.0" // or latest } repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.4.2' // START: FlutterFire Configuration classpath 'com.google.gms:google-services:4.4.2' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2' // END: FlutterFire Configuration classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { google() mavenCentral() maven { // [required] background_fetch url "${project(':background_fetch').projectDir}/libs" } } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } tasks.register("clean", Delete) { delete rootProject.buildDir } // subprojects { // project.configurations.all { // resolutionStrategy.eachDependency { details -> // if (details.requested.group == 'androidx.core' && // !details.requested.name.contains('androidx')) { // details.useVersion "1.0.1" // } // } // } // } // subprojects { // afterEvaluate { subproject -> // if (subproject.hasProperty("android")) { // android { // compileSdkVersion 27 // buildToolsVersion '27.0.3' // } // } // } // }
app/build.gradle
def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { throw GradleException("versionCode not found. Define flutter.versionCode in the local.properties file.") } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { throw GradleException("versionName not found. Define flutter.versionName in the local.properties file.") } apply plugin: 'com.android.application' // START: FlutterFire Configuration apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' // END: FlutterFire Configuration apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } def geoApiKEY = localProperties.getProperty('geo.apiKEY') apply plugin: 'kotlin-android' android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion "34.0.0" defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "world.opine.app" minSdkVersion 23 targetSdkVersion rootProject.ext.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true manifestPlaceholders = [geoApiKEY: geoApiKEY] } signingConfigs { release { // if (System.getenv()["CI"]) { // CI=true is exported by Codemagic // storeFile file(System.getenv()["CM_KEYSTORE_PATH"]) // storePassword System.getenv()["CM_KEYSTORE_PASSWORD"] // keyAlias System.getenv()["CM_KEY_ALIAS"] // keyPassword System.getenv()["CM_KEY_PASSWORD"] // } else { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] // storeFile file(keystoreProperties['storeFile']) storeFile file("Users/Kwabena/key.jks") storePassword keystoreProperties['storePassword'] // } } } buildTypes { release { signingConfig signingConfigs.release // minifyEnabled true // useProguard true // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // android.applicationVariants.all { variant -> // variant.outputs.all { // outputFileName = "opine-${variant.name}-${variant.versionName}-${variant.versionCode}.apk" // } // } } } android { namespace 'world.opine.app' compileOptions { sourceCompatibility 1.8 targetCompatibility 1.8 } } lint { disable 'InvalidPackage' } // buildTypes { // release { // // TODO: Add your own signing config for the release build. // // Signing with the debug keys for now, so `flutter run --release` works. // signingConfig signingConfigs.debug // minifyEnabled true // useProguard true // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // } // } // splits { // // Configures multiple APKs based on ABI. // abi { // // Enables building multiple APKs per ABI. // enable true // // By default all ABIs are included, so use reset() and include to specify that we only // // want APKs for armeabi-v7a and arm64-v8a. // // Resets the list of ABIs that Gradle should create APKs for to none. // reset() // // Specifies a list of ABIs that Gradle should create APKs for. // // include "armeabi-v7a", "arm64-v8a" // include "armeabi-v7a", "arm64-v8a", "x86" // // Specifies that we do not want to also generate a universal APK that includes all ABIs. // universalApk false // } // } } flutter { source '../..' } dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test:runner:1.6.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation platform('com.google.firebase:firebase-bom:31.0.2') implementation 'com.google.firebase:firebase-analytics-ktx' // api "androidx.core:core:1.1.0-alpha04" }
解决方案建议
根据错误日志和配置文件分析,问题大概率出在manifest占位符null值或Gradle配置冲突上,按以下步骤排查:
检查local.properties中的geo.apiKEY
确认local.properties文件中存在geo.apiKEY=你的密钥这一行,且值不为空。如果没有,添加该行并填入有效的Google Maps API密钥;如果已有,确保无拼写错误或空格。修复signingConfigs中的路径问题
release签名配置中,storeFile file("Users/Kwabena/key.jks")是相对路径,Windows系统下需使用完整路径(如C:/Users/Kwabena/key.jks),或改回读取keystoreProperties['storeFile']的值,避免路径错误导致null值问题。统一Gradle插件版本
当前Android Gradle插件为7.4.2,Gradle版本为7.6.2-all,两者兼容,但可尝试将插件升级到7.6.2(与Gradle版本匹配),修改android/build.gradle中的:classpath 'com.android.tools.build:gradle:7.6.2'合并重复的android块
app/build.gradle
相关产品推荐
相关产品推荐

