uni-app google billing-ktx 7.1.1云打包失败
uni-app google billing-ktx 7.1.1云打包失败
| 开发环境 | 版本号 | 项目创建方式 |
|---|---|---|
| Mac | 版本15.5 (24F74) | HBuilderX |
示例代码:
{
"dependencies": [
"androidx.core:core-ktx:1.9.0",
"com.android.billingclient:billing-ktx:7.1.1"
],
"minSdkVersion": "24"
}
package uts.sdk.modules.nativeBilling
import android.app.Activity
import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import com.android.billingclient.api.*
import com.android.billingclient.api.ProductDetailsResult
import io.dcloud.uts.*
import io.dcloud.uts.UTSJSONObject
import kotlinx.coroutines.*
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import org.json.JSONArray
import org.json.JSONObject
操作步骤:
- 云打包一直不成功
预期结果:
- 能正常云打包成功
实际结果:
- 云打包一直不成功
bug描述:
- UTS api插件开发,云打包失败:
- https://app.liuyingyong.cn/build/errorLog/fe5f8a70-6c55-11f0-a0b0-0f9729c8dbeb
- 上周打包还是成功的,UTS插件没动过。现在打包就失败了。
e: file://uni_modules/native-google/utssdk/app-android/src/Billing.kt:395:41 Class 'com.android.billingclient.api.ProductDetailsResult' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.0.0, expected version is 1.8.0.
更多关于uni-app google billing-ktx 7.1.1云打包失败的实战教程也可以访问 https://www.itying.com/category-93-b0.html
2 回复
这是因为google billing-ktx:7.1.1使用的是kotlin 2.0.0 编译环境,目前云端打包使用的是 kotlin 1.8.0。
建议先试用 google billing-ktx 低版本,HBuilderX4.81版本将会升级云端打包的 kotlin 环境为2.2.0。
更多关于uni-app google billing-ktx 7.1.1云打包失败的实战教程也可以访问 https://www.itying.com/category-93-b0.html
这是Kotlin版本兼容性问题。com.android.billingclient:billing-ktx:7.1.1使用了Kotlin 2.0.0编译,而当前UTS环境使用的是Kotlin 1.8.0,导致版本不匹配。
解决方案:
- 降级billing库版本:将依赖改为兼容Kotlin 1.8.0的版本
{
"dependencies": [
"androidx.core:core-ktx:1.9.0",
"com.android.billingclient:billing-ktx:6.1.0"
],
"minSdkVersion": "24"
}
- 或者使用非Kotlin版本:
{
"dependencies": [
"androidx.core:core-ktx:1.9.0",
"com.android.billingclient:billing:7.1.1"
],
"minSdkVersion": "24"
}

