【问题标题】:Android Studio isn't showing Build VariantsAndroid Studio 未显示构建变体
【发布时间】:2019-08-15 13:06:40
【问题描述】:

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

我已经尝试过:

  • 删除我的 .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"]}\""
    }
}

可能是什么问题?

【问题讨论】:

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


    【解决方案1】:

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

    文件 -> 将项目与 Gradle 文件同步

    【讨论】:

      【解决方案2】:

      您可以在build.gradle 文件中指定signingConfig 应与buildType. 一起使用

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

      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
          }
      }
      

      【讨论】:

        猜你喜欢
        • 2018-08-05
        • 1970-01-01
        • 2019-10-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-09-13
        • 1970-01-01
        相关资源
        最近更新 更多