为动态模块获取SplitInstallErrorCode.MODULE_UNAVAILABLE

问题描述 投票:0回答:1

我在尝试安装动态模块时遇到以下错误SplitInstallErrorCode.MODULE_UNAVAILABLE。我已经在使用Google Play内部应用共享来测试aab文件,但仍然可以获取它。

这里是动态要素清单文件:

 <dist:module
        dist:title="@string/module_investment">
        <dist:delivery>
            <dist:on-demand />
        </dist:delivery>
        <dist:fusing dist:include="true" />
    </dist:module>

这是我开始下载的方式:

private val moduleInvestment by lazy { getString(R.string.module_investment) }

splitInstallRequest = SplitInstallRequest
                        .newBuilder()
                        .addModule(moduleInvestment)
                        .build()

     splitInstallManager.startInstall(splitInstallRequest)
                    .addOnSuccessListener { sessionId -> mySessionId = sessionId }
                    .addOnFailureListener { exception ->
                        when ((exception as SplitInstallException).errorCode) {
                            SplitInstallErrorCode.NETWORK_ERROR -> {

                            }
                            SplitInstallErrorCode.ACTIVE_SESSIONS_LIMIT_EXCEEDED ->
                                checkForActiveDownloads()
                            SplitInstallErrorCode.MODULE_UNAVAILABLE ->
                                Toast.makeText(
                                        requireActivity(),
                                        "You don't have access to $moduleInvestment module",
                                        Toast.LENGTH_LONG).show()
                        }
                    }

我该如何解决这个问题?

android android-app-bundle dynamic-feature dynamic-delivery
1个回答
0
投票

您在SplitInstallRequest中传递的值不应是动态功能模块的标题,而应是其名称。动态特征模块的名称也是Gradle模块的名称,您也可以在Gradle配置android.dynamicFeatures中设置该名称。

希望有所帮助,

© www.soinside.com 2019 - 2024. All rights reserved.