Android Studio未显示构建版本

时间:2019-08-15 13:06:40

标签: android gradle groovy build.gradle build-variant

我最近遇到了一个问题,我的构建变体无法正常工作。我无法选择变体,选择行上只有-----

enter image description here

我试图:

  • 删除我的.idea文件夹,使缓存和所有内容无效
  • 使用Gradle文件同步项目

我的buildConfig Gradle看起来像:

  buildTypes {
    debug {
        minifyEnabled false
        resValue "string", "ADMOB_APP_ID", "\"${keystoreProperties["debugAdmobApiKey"]}\""
        resValue "string", "INSTERSTIAL_AD_ID", "\"${keystoreProperties["debugInterstialAdKey"]}\""
    }

    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        resValue "string", "ADMOB_APP_ID", "\"${keystoreProperties["releaseAdmobApiKey"]}\""
        resValue "string", "INSTERSTIAL_AD_ID", "\"${keystoreProperties["releaseInterstialAdKey"]}\""
    }
}

可能是什么问题?

2 个答案:

答案 0 :(得分:0)

您可以在build.gradle文件中指定将signingConfigbuildType.一起使用

要使用与默认调试signingConfig相同的buildType进行签名,请使用以下命令:

buildTypes {
    local {
        signingConfig signingConfigs.debug
    }

    /* NOTE: the debug block is not required because it is a default
     * buildType configuration; all of its settings are defined implicitly
     * by Android Studio behind the scenes.
     */
}

如果您希望使用本地系统上的自定义密钥库,请改用以下内容:

signingConfigs {
    local {
        storeFile file("/path/to/custom.keystore")
        storePassword "password"
        keyAlias "MyLocalKey"
        keyPassword "password"
    }
}

buildTypes {
    local {
        signingConfig signingConfigs.local
    }
}

答案 1 :(得分:-1)

尝试通过以下方式将您的项目与Gradle文件同步

文件->使用Gradle文件同步项目