首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android给了我BuildConfig错误

Android给了我BuildConfig错误
EN

Stack Overflow用户
提问于 2020-05-06 13:41:09
回答 1查看 1.3K关注 0票数 4

如果我点击Debug,Android有时会自动创建新的BuildConfig文件,然后抱怨它应该只是一个名为Buildconfig.java的文件.

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

提前感谢

编辑:

我的build.gradle文件:

代码语言:javascript
复制
// 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)

代码语言:javascript
复制
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'
}

编辑:当我构建和调试时,我在我的控制台中得到了这个错误警告:

在此构建中使用了

不推荐的Gradle特性,使其与Gradle 7.0不兼容。使用见https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings

EN

回答 1

Stack Overflow用户

发布于 2020-05-11 15:02:34

按照列表顺序尝试以下方法:

  • 从生成菜单中选择Make Project
  • 转到File菜单并选择Invalidate Cache/restart
  • 将gradle-wrapper.properties中的distributionUrl更改为其他版本(更高的版本优先)。

distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

  • 更新安卓工作室.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61636699

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档