Android inapp billing - BillingService在onServiceConnected和onServiceDisconnected上有编译错误

时间:2012-07-12 17:46:04

标签: android android-billing

我正在使用Dungeons应用程序示例,我正在使用该示例中提供的BillingService类。

我正在使用Java 6和@override为我工作,但我在BillingService.java中的这两个方法上遇到编译错误:

/**
 * This is called when we are connected to the MarketBillingService.
 * This runs in the main UI thread.
 */
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
    if (Consts.DEBUG) {
        Log.d(TAG, "Billing service connected");
    }
    mService = IMarketBillingService.Stub.asInterface(service);
    runPendingRequests();
}

/**
 * This is called when we are disconnected from the MarketBillingService.
 */
@Override
public void onServiceDisconnected(ComponentName name) {
    Log.w(TAG, "Billing service disconnected");
    mService = null;
}

有人会帮我理解为什么会这样吗?

谢谢!

6 个答案:

答案 0 :(得分:5)

确保您的类实现ServiceConnection接口。

答案 1 :(得分:4)

在App结算中,入门是一项挑战。诀窍是让它在一个独立项目中启动,然后完成所有特定功能。相信我,并且做得很勇敢并且一起完成,它不值得开始所需的时间。我希望谷歌在整体应用计费方面有所改进,以便于实施,理解和调试。我曾经写过一篇关于它的博客,并创建了一个helloworld有点项目供人们下载和开始工作。我希望它对你也有所帮助。

Debug Android inapp billing using Eclipse

答案 2 :(得分:3)

我认为你应该简单地从这两种方法中删除@Override装饰器。我正在使用Google BillingService类,这是我的方法:

public void onServiceConnected(ComponentName name, IBinder service)
{        
    mService = IMarketBillingService.Stub.asInterface(service);
    runPendingRequests();
}

您正在实现一个接口,而不是使用抽象方法扩展类。

答案 3 :(得分:2)

您可以尝试使用默认编译选项。

右键单击(或按住Control键并单击)项目,然后选择“属性”

选择“Java编译器”

取消选中“启用项目特定设置”

Eclipse将提示重新编译,它应该都很好。

答案 4 :(得分:1)

安装你的应用程序签名...所以去android工具导出签名的应用程序....现在,它签署了你可以回来查询。至少在物理设备上这是我的问题。

答案 5 :(得分:1)

右键单击项目 选择 - > Android工具 选择 - >修复项目属性

这为我修复了它(我相信它是一个Java编译器设置将其抛弃)。