从即时应用程序迁移到应用程序捆绑包后,出现以下错误。

Could not set unknown property 'dynamicFeatures' for object of type com.android.build.gradle.AppExtension.

我已经按照https://developer.android.com/topic/google-play-instant/feature-module-migration中的说明进行了操作。
我尝试过更新应用程序的生成工具和目标sdk版本,但没有帮助。
这是我的动态功能模块的build.gradle文件。
apply plugin: 'com.android.dynamic-feature'

android {
    dynamicFeatures = [":features:base"]  // This is where error points to!
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation project(':features:base')

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

应用程序中使用的版本:
    buildTools = "28.0.3"
    compileSdk = 28
    targetSdk = 28
    minSdkInstant = 21
    minSdk = 21
    archLifecycleVersion = "1.1.1" //"2.0.0"
    ktxVersion = "1.0.1"

    supportLibVersion = "28.0.0"
    playServicesAuthVersion = "11.8.0"
    espressoVersion = "3.0.1"
    androidTestVersion = "0.5"
    hamcrestVersion = "1.3"
    junitVersion = "4.12"

Gradle包装版本:5.1.1

最佳答案

我在动态功能模块中设置dynamicfeatures变量,这是不正确的。必须仅在基本模块中设置dynamicfeatures变量。
功能1/构建.gradle

apply plugin: 'com.android.dynamic-feature'

android {
    ...
    // do not set dynamicFeatures here!
}

app/build.gradle版本
apply plugin: 'com.android.application'

android {
    ...
    dynamicFeatures = [":feature1", ":feature2"]
}

您可以在这里看到一个示例项目:https://github.com/CapTechMobile/Android-App-Bundle-Sample

关于android - AppExtension类型的对象的未知属性dynamicFeatures,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55989448/

10-09 13:49