如何在功能模块上设置Target Sdk (Gradle 7.0.2)

发布于 2025-01-12 18:33:52 字数 927 浏览 1 评论 0原文

我想将以前的 (com.android.library)更改为功能模块 (com.android.dynamic -特征)。但是,当我这样做时,我无法设置 targetSdktargetSdkVersion

plugins {
    id("com.android.dynamic-feature")
    kotlin("kapt")
    kotlin("android")
}

android { // this = DynamicFeatureExtension
    compileSdk = BuildConfig.SdkVersion.COMPILE

    defaultConfig {
        minSdk = BuildConfig.SdkVersion.MIN
        targetSdk = BuildConfig.SdkVersion.TARGET // targetSdk is not found
        targetSdkVersion(BuildConfig.SdkVersion.TARGET) // targetSdkVersion is not found
    ...
}

gradle 版本是 7.0.2: distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip

我注意到当我将它与 格子应用程序,它不会遇到同样的问题,他们的 gradle 版本是5.6.4.

I want to change what was previously a library (com.android.library) to a feature module (com.android.dynamic-feature). However, when I do so, I am unable to set the targetSdk or targetSdkVersion:

plugins {
    id("com.android.dynamic-feature")
    kotlin("kapt")
    kotlin("android")
}

android { // this = DynamicFeatureExtension
    compileSdk = BuildConfig.SdkVersion.COMPILE

    defaultConfig {
        minSdk = BuildConfig.SdkVersion.MIN
        targetSdk = BuildConfig.SdkVersion.TARGET // targetSdk is not found
        targetSdkVersion(BuildConfig.SdkVersion.TARGET) // targetSdkVersion is not found
    ...
}

The gradle version is 7.0.2:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip

I notice that when I compare it with the Plaid App, which doesn't suffer the same problems, that their gradle version is 5.6.4.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖凝香 2025-01-19 18:33:52

你能试试这个吗?

defaultConfig.apply {
        minSdk = BuildConfig.SdkVersion.MIN
        targetSdk = BuildConfig.SdkVersion.TARGET
        targetSdkVersion(BuildConfig.SdkVersion.TARGET)
} 

Can you try this?

defaultConfig.apply {
        minSdk = BuildConfig.SdkVersion.MIN
        targetSdk = BuildConfig.SdkVersion.TARGET
        targetSdkVersion(BuildConfig.SdkVersion.TARGET)
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文