Android inapp billing - BillingService has compile

2019-02-17 21:03发布

I am using the Dungeons application example and I am using the BillingService class provided in that example.

I am using Java 6 and @override works for me, but I get a compile error on these two methods inside 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;
}

Would someone help me understand why this is happening?

Thanks!

6条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-02-17 21:51

I think you should simply remove the @Override decorator from both methods. I'm using the Google BillingService class and this is my method:

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

You are implementing an interface, not extending a class with abstract methods.

查看更多
劫难
3楼-- · 2019-02-17 21:51

Right click on the Project Select --> Android Tools Select --> Fix Project Properties

This fixed it for me (I believe it was a Java compiler setting throwing it off).

查看更多
不美不萌又怎样
4楼-- · 2019-02-17 21:55

In App billing is a challenge to get started with. The trick is to get it started in a independent project and then do all your specific feature. Trust me on this, and done be brave and do it all together, its not worth the time it takes to get started. I hope google improves on in app billing overall, to make it easy to implement, understand and debug. I had blogged about it a while back and created a helloworld kinda project for people to download and get working. I hope it helps you too.

Debug Android inapp billing using Eclipse

查看更多
时光不老,我们不散
5楼-- · 2019-02-17 22:06

Make sure your class implements the ServiceConnection interface.

查看更多
\"骚年 ilove
6楼-- · 2019-02-17 22:06

You might try to use default compile options.

Right-click (or Control-Click) the project and select "Properties"

Select "Java Compiler"

Uncheck "Enable Project Specific Settings"

Eclipse will prompt to re-compile and it should be all good.

查看更多
我想做一个坏孩纸
7楼-- · 2019-02-17 22:10

Install your app Signed ...so go to android tools export signed application .... now that its signed you can get back queries. This was my issue at least on a physical device.

查看更多
登录 后发表回答