简体   繁体   English

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

[英]I'm trying to add firebase to my flutter project but i keep on getting this Error Could not find method implementation()

**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] on object of type [com.android.support:support-annotations:28.0.0] 类型为 object

org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. 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

This is code for the Build.gradle file that is giving the error: New Properties methods is highlighted red 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'
}

Goto event_notifier\android\build.gradle ...转到event_notifier\android\build.gradle ...

These dependencies should make it build:这些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"
}

The actual problem seems to be a quite outdated version of the Android Gradle Plugin.实际问题似乎是 Android Gradle 插件的一个相当过时的版本。

You'd have to upgrade to something more current to use implementation :您必须升级到更新的版本才能使用implementation

classpath "com.android.tools.build:gradle:4.0.1"

And maybe already start with current androidx packages...because else you'll be stuck at the latest version of Firebase libraries, which use these obsolete support libraries.并且可能已经从当前的androidx包开始......因为否则您将被困在使用这些过时的支持库的 Firebase 库的最新版本中。 That Flutter project may generally be outdated and might require some refactoring (unless using the above compile ): 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"
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在尝试在我的项目中使用MaterialDesign,但一直都遇到此错误 - I'm trying to use MaterialDesign in my project but I'm getting this error all the time 我在运行 flutter 应用程序时不断收到此错误,我的控制台充满了它 - I'm keep getting this error while running my flutter app and my console is full of it 我正在尝试在我的依赖项中添加 firebase,我得到了这个 - I'm trying to add firebase in my dependencies and I get this 我的Android项目中不断出现错误 - I keep getting an error in my android project 实施Firebase(Flutter)通知时,出现错误 - When implementing Firebase (Flutter) notifications, I'm getting an error 尝试构建我的项目时,出现错误。 有人知道如何解决吗? - When trying to build my project I'm getting an error. Do anyone know how to fix it? 我正在尝试将新活动添加到我的项目中,但它给了我错误 - I'm trying to add new activity into my project but it gives me error 我正在尝试向应用程序添加图形。 尝试添加 MPAndroidChart 时出现错误 - I'm trying to add graphics to the application. I'm getting an error when trying to add the MPAndroidChart NameError:未初始化的常量 Rpush::Gcm 我正在尝试将 rpush 用于我的移动应用程序。 但我不断收到此错误 - NameError: uninitialized constant Rpush::Gcm I'm trying to use rpush for my mobile app. But I keep getting this error 我正在尝试在Windows上的android studio中运行一个基本的Android-NDK项目,但不断收到未知文件错误 - I'm trying to run a basic Android-NDK project in android studio on windows but keep getting unknown file error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM