当前我遇到此错误:
Microsoft Windows [Version 10.0.19043.1526]
(c) Microsoft Corporation. Alle Rechte vorbehalten.
C:UsersFlutterStudioProjectsnomadnet>flutter run
Using hardware rendering with device sdk gphone x86 arm. If you notice graphics artifacts, consider enabling software rendering with
"--enable-software-rendering".
Launching libmain.dart on sdk gphone x86 arm in debug mode...
FAILURE: Build failed with an exception.
* Where:
Script 'C:UsersFlutterflutter_windows_2.10.1-stableflutterpackagesflutter_toolsgradleflutter.gradle' line: 421
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.
* 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 37s
Running Gradle task 'assembleDebug'... 38,8s
Exception: Gradle task assembleDebug failed with exit code 1
我已经试过了:
- https://stackoverflow.com/a/71014094/16241837
- https://stackoverflow.com/a/71009865/16241837
- 我也尝试了更多的东西,但我已经不知道了
我的代码:
app/build.gradle:
buildscript {
repositories {
// ...
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
// ...
// OneSignal-Gradle-Plugin
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
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 new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
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))
}
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.apps.social_circle"
minSdkVersion 20
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
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.release
}
}
android {
defaultConfig {
manifestPlaceholders = [
onesignal_app_id: 'f0f22efa-186b-4b17-be29-f3f86e4d6184',
onesignal_google_project_number: 'REMOTE'
]
}
}
packagingOptions {
exclude 'AndroidManifest.xml' //This fixes a bug in FAN 5.0.1
}
}
flutter {
source '../..'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-analytics'
// das ist für alle sachen sehr wichtig
implementation 'com.google.firebase:firebase-firestore'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.onesignal:OneSignal:3.2.4'
}
android/build.gradle:
buildscript {
ext.kotlin_version = '1.5.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我有最新的flutter版本和最新的flutter插件版本。
PS:我用oneSignal。
请帮帮我!
这似乎是OneSignal Grandle插件的已知问题。
Github OneSignal问题
在讨论中,提出了一些解决方案,这些解决方案似乎破坏了OneSignal或引发了更多问题。
其中两个是:
- 将onesignal插件放在";android/app/build.gradle">来源:Direnalex评论
- 下坡Flutter和Kotlin来源:Dgilperez评论
我的建议是引起人们对Github问题的关注,以便OneSignal社区能够解决它
要解决上面的以下问题,我想看看你的颤振医生,以及运行应用程序后的详细信息。
但是请先试试这个
1. downgrade your pub library , then do a pub repair, and flutter clean.
Did this solved the issue? if not Then do the following below.
2. downgrade your flutter version, and choose the stable channel for the down graded version, do a flutter clean, then pub repair, and fix the codes of yours to match the down graded version.