Muh*_*fan 3 java android billing android-billing
我已经从以下 url https://developer.android.com/google/play/billing/billing_library_overview#java实现了计费库
我在这条线上出错
if (billingResult.getResponseCode() == BillingResponse.OK) {
Run Code Online (Sandbox Code Playgroud)
它说 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.
}
});
Run Code Online (Sandbox Code Playgroud)
我在我的应用程序build.gradle文件中添加了以下依赖项
dependencies {
...
implementation 'com.android.billingclient:billing:2.1.0'
}
Run Code Online (Sandbox Code Playgroud)
但我收到错误
我什至无法手动导入
import com.android.billingclient.api.BillingClient.BillingResponse;
Run Code Online (Sandbox Code Playgroud)
我知道它的简单解决方案是更换
BillingResponse.OK
Run Code Online (Sandbox Code Playgroud)
和
BillingClient.BillingResponseCode.OK
Run Code Online (Sandbox Code Playgroud)
但我的问题是为什么它没有在文档中给出呢?
我检查了源代码并找出了正确的代码。
虽然谷歌文档上的代码billingResult.getResponseCode() == BillingResponse.OK说它应该是billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK
所以你需要做的就是替换BillingResponse.OK为BillingClient.BillingResponseCode.OK
| 归档时间: |
|
| 查看次数: |
1004 次 |
| 最近记录: |