[英]Cannot resolve symbol 'BillingResponse'
我已经从以下网址实现了计费库https://developer.android.com/google/play/billing/billing_library_overview#java
我在这条线上出错
if (billingResult.getResponseCode() == BillingResponse.OK) {
它说Cannot resolve symbol 'BillingResponse'
这是上面链接的完整代码
billingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingResponse.OK) {
// The BillingClient is ready. You can query purchases here.
}
}
@Override
public void onBillingServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
我在我的应用程序build.gradle
文件中添加了以下依赖build.gradle
dependencies {
...
implementation 'com.android.billingclient:billing:2.1.0'
}
但我收到错误
我什至无法手动导入
import com.android.billingclient.api.BillingClient.BillingResponse;
我知道它的简单解决方案是更换
BillingResponse.OK
和
BillingClient.BillingResponseCode.OK
但我的问题是为什么它没有在文档中给出呢?
我检查了源代码并找出了正确的代码。
虽然谷歌文档上的代码说billingResult.getResponseCode() == BillingResponse.OK
它应该是billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK
所以你需要做的就是用BillingResponse.OK
替换BillingClient.BillingResponseCode.OK
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.