gpt4 book ai didi

android - 我正在尝试将Firebase添加到我的flutter项目中,但我不断收到此错误找不到方法实现()

转载 作者:行者123 更新时间:2023-12-03 05:21:14 25 4
gpt4 key购买 nike

**This is the error message :** 

Launching lib\main.dart on sdk gphone x86 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\HP-LinkR\Videos\event_notifier\android\build.gradle'
line: 35

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find method implementation() for arguments
[com.android.support:support-annotations:28.0.0]类型的对象
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler。
* 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
Exception: Gradle task assembly debug failed with exit code 1



***This is code for the Build.gradle file that is giving the error:***
New Properties methods is highlighted red
这是Build.gradle文件的代码,出现错误:
新属性方法以红色突出显示
这是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 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"
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 28

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID
(https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.event_notifier"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName

multiDexEnabled true
}

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
}
}
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-
jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.2.2'
compile 'com.android.support:multidex:1.0.1'
}

最佳答案

转到event_notifier\android\build.gradle ...
这些dependencies应该使其构建:

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-
jdk7:$kotlin_version"
compile "com.google.firebase:firebase-analytics:17.2.2"
compile "com.android.support:multidex:1.0.1"
}
实际的问题似乎是Android Gradle插件的版本已经过时。
您必须升级到最新版本才能使用 implementation:
classpath "com.android.tools.build:gradle:4.0.1"
也许已经从当前的 androidx包开始了...因为否则您将被困在最新版本的Firebase库中,后者使用了这些 过时的支持库。该Flutter项目通常可能已过时,可能需要进行一些重构(除非使用上述 compile):
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.72"
implementation "com.google.firebase:firebase-analytics:17.4.4"

// https://mvnrepository.com/artifact/androidx.multidex/multidex
implementation "androidx.multidex:multidex:2.0.1"
}

关于android - 我正在尝试将Firebase添加到我的flutter项目中,但我不断收到此错误找不到方法实现(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63395972/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com