无法安装华为动态特性:缺少静默安装权限(代码8)

移动开发 2026-07-09

我已经使用Google SDK实现了Google Play动态特性,现在在华为端用 Dynamic Ability SDK(在不同的构建变体中)做着差不多的事情,看起来几乎与Google SDK一致。

我正在请求安装该模块:

fun startInstall(moduleName: String): Task<Int> {
    val request = FeatureInstallRequest.newBuilder()
        .addModule(moduleName)
        .build()

    return manager.installFeature(request)
}

manager
        .startInstall(sdkInfo.moduleName)
        .addOnSuccessListener { sessionId ->
                ...
        }
        .addOnFailureListener { exception ->
                listener?.onError(sdkInfo, exception, null) // fired
        }

然而我收到了以下错误:

com.huawei.hms.feature.model.FeatureInstallException: No install permission..

以下是我在日志中看到的内容:

12:12:05.729 13092-13092 DF_b                     I  Ready to installFeature from the market.
12:12:05.729 13092-13092 DF_LocalApk-d            I  fire
12:12:05.730 13092-13092 WindowOnBackDispatcher   W  sendCancelIfRunning: isInProgress=false callback=android.app.Dialog$$ExternalSyntheticLambda2@fd4d6e6
12:12:05.730 13092-13257 DF_LocalApk-d            I  Begin binding to the service.
12:12:05.731 13092-13131 HWUI                     D  endAllActiveAnimators on 0xb4000072a1fb5820 (RippleDrawable) with handle 0xb400007421eb44e0
12:12:05.749 13092-13257 DF_LocalApk-d            I  Binding to the service  success
12:12:05.753 13092-13092 DF_LocalApk-d            I  onServiceConnected
12:12:05.753 13092-13092 DF_LocalApk-d            I  onServiceConnected successed , check permission successed
12:12:05.753 13092-13257 DF_LocalApk-d            I  begin linking to death...
12:12:05.753 13092-13257 DF_LocalApk-b            I  start add new feature [esp32_sdk]
12:12:05.753 13092-13257 DF_LocalApk-b            I  installFeature....[esp32_sdk]
12:12:05.757 13092-13105 DF_LocalApk-b            E  Get error from hw marke , marketErrorCode is 8, errorMsg is No silent install permission.
12:12:05.757 13092-13257 DF_LocalApk-d            I  forget
12:12:05.757 13092-13092 OnboardingViewModel      E  SDK error: esp32_sdk, com.huawei.hms.feature.model.FeatureInstallException: No install permission., null

我已经查看了所提供的文档和 示例源代码,但我不能弄清楚到底哪里出错了。

我甚至把

<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

加到了AndroidManifest.xml中,但没有起作用。

有任何想法吗?

P.S.在已安装HMS服务的模拟器中进行测试。

P.P.S.在 FeatureInstallErrorCode 枚举中没有这样的代码。

解决方案

这是由于本地测试导致的。华为SDK演示应用 的表现也完全一样。如果上传到AppGallery进行公开测试——它按预期工作。不过仍然需要做一些小的调整。

P.S.状态监听器没有被触发,但在本地测试时,任务监听器会返回错误代码 FeatureInstallErrorCode.NO_INSTALL_PERMISSION(903)。

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章