gpt4 book ai didi

android - 使用内部应用程序共享来测试按需动态功能模块不起作用

转载 作者:行者123 更新时间:2023-12-02 13:45:02 24 4
gpt4 key购买 nike

我正在尝试使用内部应用共享来测试我是否可以正确请求和下载按需动态功能模块。

当我尝试此操作时,我可以看到它首先开始正确下载新功能,但它从未安装。我看到这些 com.example 已安装,但证书不匹配 日志。这会导致问题吗?我知道内部应用程序共享上传是“使用内部应用程序共享 key 自动重新签名的,该 key 是由 Google 自动为您的应用程序创建的”。 source 。是否有可能内部应用共享未正确签署点播 apk?

下载有问题的代码:

private const val ONDEMAND_FEATURE_MODULE_NAME: String = "ondemandfeature" // must match gradle module name

fun downloadOnDemandFeature(context: Context) {
val request = SplitInstallRequest
.newBuilder()
.addModule(ONDEMAND_FEATURE_MODULE_NAME)
.build()

val splitInstallManager = create(context)

// Initializes a variable to later track the session ID for a given request.
var mySessionId = 0
val listener = SplitInstallStateUpdatedListener { state ->
if (state.sessionId() == mySessionId) {
when (state.status()) {
SplitInstallSessionStatus.DOWNLOADING -> {
val totalBytes = state.totalBytesToDownload()
val progress = state.bytesDownloaded()
Timber.d("Downloading on demand module: state DOWNLOADING")
Timber.d("Downloading on demand module: %d of %d bytes", progress, totalBytes)
}
SplitInstallSessionStatus.INSTALLED -> {
Timber.d("Downloading on demand module: state INSTALLED")
// TODO installed, now do stuff
}
SplitInstallSessionStatus.CANCELED -> {
Timber.d("Downloading on demand module: state CANCELED")
}
SplitInstallSessionStatus.CANCELING -> {
Timber.d("Downloading on demand module: state CANCELING")
}
SplitInstallSessionStatus.DOWNLOADED -> {
Timber.d("Downloading on demand module: state DOWNLOADED")
}
SplitInstallSessionStatus.FAILED -> {
Timber.d("Downloading on demand module: state FAILED")
}
SplitInstallSessionStatus.INSTALLING -> {
Timber.d("Downloading on demand module: state INSTALLING")
}
SplitInstallSessionStatus.PENDING -> {
Timber.d("Downloading on demand module: state PENDING")
}
SplitInstallSessionStatus.REQUIRES_USER_CONFIRMATION -> {
Timber.d("Downloading on demand module: state REQUIRES USER CONFIRMATION")
}
SplitInstallSessionStatus.UNKNOWN -> {
Timber.d("Downloading on demand module: state UNKNOWN")
}
}
}
}

splitInstallManager.registerListener(listener)

splitInstallManager
.startInstall(request)
.addOnSuccessListener { sessionId -> mySessionId = sessionId }
.addOnFailureListener { exception ->
Timber.e(exception, "Error installing ondemandfeature")
}
}

你可以看到我的完整日志here .

最佳答案

我在我的应用程序中实现了一个动态模块,该模块大于 10 MB,并且也需要用户确认。你的代码看起来不错。请确保您正确执行以下操作。

  1. 在(case:SplitInstallSessionStatus.INSTALLED:)确保您创建了一个转到动态 Activity 的 Intent 。

    Intent Intent = new Intent();
    Intent.setClassName("你的包名称", "你的包名称.module.yourdynamicactivity");
    启动 Activity ( Intent );

  2. 确保应用和模块的 buidle.gradle 文件中的 (versionCode *) 和 (versionName "* ") 相同。

  3. 在您的动态模块中,在您的 Activity 中调用此方法。

    @Override
    protected 无效attachBaseContext(Context newBase){
    super.attachBaseContext(newBase);
    SplitCompat.install(this);
    }

关于android - 使用内部应用程序共享来测试按需动态功能模块不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59076963/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com