gpt4 book ai didi

android - Gradle同步失败:找不到方法defaultConfig()

转载 作者:行者123 更新时间:2023-12-02 13:44:40 24 4
gpt4 key购买 nike

在第一个实例中,我的问题是原因1:org.gradle.workers.internal.DefaultWorkerExecutor $ WorkExecutionException:执行com.android.build.gradle.internal.tasks.Workers $ ActionFacade时发生故障

但是从那以后,这种情况不断升级,现在我的 Gradle 被打破了。
这是我得到的错误:

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\stackstorage\android projecten\Converter\build.gradle' line: 26

* What went wrong:
A problem occurred evaluating root project 'Converter'.
> Could not find method defaultConfig() for arguments [build_7komq7i2k7pl5720grjx3kada$_run_closure2@b894d83] on root project 'Converter' of type org.gradle.api.Project.

* 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

CONFIGURE FAILED in 0s
Could not find method defaultConfig() for arguments [build_7komq7i2k7pl5720grjx3kada$_run_closure2@b894d83] on root project 'Converter' of type org.gradle.api.Project.
Open File


事件日志:
12:13   Gradle sync started with IDEA sync

12:13 Gradle sync failed: Could not find method defaultConfig() for arguments [build_7komq7i2k7pl5720grjx3kada$_run_closure2@55d7744a] on root project 'Converter' of type org.gradle.api.Project.
Consult IDE log for more details (Help | Show Log) (287 ms)

12:13 NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN

12:13 Gradle sync started with IDEA sync

12:13 Gradle sync failed: Could not find method defaultConfig() for arguments [build_7komq7i2k7pl5720grjx3kada$_run_closure2@b894d83] on root project 'Converter' of type org.gradle.api.Project.
Consult IDE log for more details (Help | Show Log) (230 ms)

12:13 NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN

我不确定需要什么代码才能获得帮助,但是我看到有人发布了他们的build.gradle和gradle.properties,所以我将发布我的代码。
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()

}
}

defaultConfig {
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}

task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx4608m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

在此先感谢任何愿意提供帮助的人。我有点搞砸了。

最佳答案

检查您的应用程序> build.gradle 文件。会有像这样的 defaultConfig()标记

 defaultConfig {
applicationId "com.example.myApp"// your appId
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

关于android - Gradle同步失败:找不到方法defaultConfig(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59966157/

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