gpt4 book ai didi

java - Android Studio 给了我 BuildConfig 错误

转载 作者:行者123 更新时间:2023-12-01 14:32:20 29 4
gpt4 key购买 nike

如果我点击调试图标,Android Studio 有时会自动创建新的 BuildConfig文件,然后提示它应该只有一个名为 Buildconfig.java 的文件。 ...

enter image description here

一个 Clean Project修复它,但它太烦人了,必须有一个可靠的解决方案。

提前致谢

编辑:

我的 build.gradle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.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()
maven { url 'https://jitpack.io' }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

我的 build.gradle(Module: app) :

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
applicationId "de.my.app.id"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

// To inline the bytecode built with JVM target 1.8 into
// bytecode that is being built with JVM target 1.6. (e.g. navArgs)


compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.2.2'
implementation 'androidx.navigation:navigation-ui:2.2.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation 'com.github.siyamed:android-shape-imageview:0.9.3@aar'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.github.RobertApikyan:SegmentedControl:1.2.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation 'com.h6ah4i.android.materialshadowninepatch:materialshadowninepatch:1.0.0'
}

编辑:
构建和调试时,我在控制台中收到此错误警告:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings

最佳答案

按列出顺序尝试以下方法:

  • 选择 Make Project从构建菜单。
  • 转至 File菜单并选择 Invalidate Cache/restart .
  • 更改distributionUrl在 gradle-wrapper.properties 到其他一些版本(更高的首选)。distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
  • 更新安卓工作室。
  • 关于java - Android Studio 给了我 BuildConfig 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61636699/

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