小编Tai*_*uuu的帖子

使用 Gradle 在 Android Studio 中导入 BuildConfig

我是 Android Studio 的新手,我正在尝试versionCode进入build.gradle.

我已阅读这篇文章这篇文章,并尝试了他们的解决方案:

import com.example.BuildConfig;
...
...
...
// Get current version code
int currentVersionCode = BuildConfig.VERSION_CODE;
Run Code Online (Sandbox Code Playgroud)

但IDE一直说Cannot resolve symbol 'BuildConfig'。实际上,我在整个项目文件夹中没有找到任何名为“BuildConfig”的字符串(在 Windows 资源管理器中搜索)。我的项目配置/创建有问题吗?


defaultConfig就像build.gradle (module: app)

    defaultConfig {
        applicationId "com.foo.bar"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio

9
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

android-studio ×1

gradle ×1