java - 找不到参数的方法实现()[org.jetbrains.kotlin :kotlin-stdlib-jdk7:1. 3.50]

标签 java android flutter kotlin gradle

我也是 Android 开发和 Flutter 的新手。导出我的应用程序时,我遇到很多错误,目前卡在这个错误上。不知道如何解决这个问题。如果你们能帮助我,那将是很大的帮助!

收到此错误:

FAILURE: Build failed with an exception.

* Where:
Build file 'F:\GAMES\quiz\android\app\build.gradle' line: 88

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method implementation() for arguments [org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDepen
dencyHandler.

* 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 3s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                       4.3s
Gradle task assembleRelease failed with exit code 1

我认为 gradle 文件中一定存在一些错误,因此包括下面的 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 FileNotFoundException("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 keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    compileSdkVersion 29

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

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.karat18.quiz"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            profile {
                matchingFallbacks = ['debug', 'release']
            }
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

apply plugin: 'kotlin-android'
buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.android.tools.build:gradle:3.6.3'
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        //testImplementation 'junit:junit:4.12'
        //androidTestImplementation 'androidx.test:runner:1.2.0'
        //androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
        //implementation 'com.google.firebase:firebase-analytics:17.4.1'

    }
    allprojects {
        // ...

        repositories {
            // Check that you have the following line (if not, add it):
            google()  // Google's Maven repository
            // ...
        }
    }
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

最佳答案

您在其中添加实现“org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version”的依赖项 block 位于buildscript block 。 这意味着您正在尝试修改构建使用的依赖项,而不是项目使用的依赖项。

  • 构建依赖项仅使用 classpath 配置,因此如果这是您的目标,请将实现替换为classpath
  • 项目依赖项必须在与 android block 处于同一级别的 dependencies block 中声明。请参阅Android documentation了解详情。因此,如果这是您的目标,请将该行移动到新的依赖项 block

关于java - 找不到参数的方法实现()[org.jetbrains.kotlin :kotlin-stdlib-jdk7:1. 3.50],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61779117/

相关文章:

java - Gson序列化字段仅当不为空或不为空时

java - Java获取带#的参数

android - 使所有 View 透明以仅看到主题背景图像

java - 无法检测 Android 中的 SIM 卡更改

android - 钛合金中的 SQLite 更新查询

java - 如何更改过滤器中 http 响应的正文

java - 为什么将 gradle java 应用程序部署到 heroku 失败?

firebase - Flutter Cloud Firestore orderBy 和 limit 问题

android - DioError [DioErrorType.RESPONSE] : Http status error [400] Exception

flutter - 我想每次添加不同的图像,我重复使用这张卡。如何在不复制粘贴整个代码的情况下做到这一点