6

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!

Genadinik
  • 18,153
  • 63
  • 185
  • 284
  • What are the Errors you facing? can you specify that? – Bhavesh Patadiya Jul 17 '12 at 07:18
  • @Ran and Bhavesh the COMPILE time error that happens is I leave override here is this: Multiple markers at this line - The method onServiceConnected(ComponentName, IBinder) of type BillingService must override a superclass method – Genadinik Jul 17 '12 at 10:48
  • Could you check if you're compiling under Java 1.5 or lower? If so please change to 1.6+… –  Jul 21 '12 at 16:03
  • 1
    I had the same problem and it worked for me to change to Java 1.6 from 1.5. – harrakiss May 30 '13 at 17:54
  • Have a look at this question's accepted answer: http://stackoverflow.com/questions/1678122/ as said by @harrakiss, changing to 1.6 do the trick. – TheVillageIdiot Jul 12 '14 at 13:48

6 Answers6

5

Make sure your class implements the ServiceConnection interface.

Ran
  • 4,117
  • 4
  • 44
  • 70
  • yes, it already implements that interface. But those error are still there. – Genadinik Jul 17 '12 at 12:35
  • "multiple markers" could mean there are several errors on that line, so check what they are. – Ran Jul 17 '12 at 12:38
  • these are the two errors: Multiple markers at this line - The method onServiceDisconnected(ComponentName) of type BillingService must override a superclass method ....and - implements android.content.ServiceConnection.onServiceDisconnected – Genadinik Jul 17 '12 at 13:02
  • did you try running Android lint on it? sometimes it helps. – Ran Jul 17 '12 at 13:30
  • I am actually not familiar with Android lint. I looked it up..sounds useful, but I had not set it up yet. – Genadinik Jul 17 '12 at 14:40
  • It comes with the ADT so you have it. Do right-click on the project, android -> run Lint – Ran Jul 17 '12 at 14:45
  • ah cool, just ran it. Found some interesting things in my app, but nothing with billing other than this: The resource R.layout.billing_not_supported appears to be unused Issue: Looks for unused resources Id: UnusedResources Unused resources make applications larger and slow down builds. – Genadinik Jul 17 '12 at 14:57
4

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

Community
  • 1
  • 1
Siddharth
  • 9,349
  • 16
  • 86
  • 148
  • I agree, but I happen to be almost there, and just have a few bugs to work out. – Genadinik Jul 17 '12 at 10:30
  • This in app billing thingy used up a lot of my energy. Especially since every little change has to be tested in more than 1 combination. You miss one step and a reinstall of your app, and your customer may loose all purchased information. Its crazy. Testing every scenario (no matter how simple it is) takes 1/2 hour. Thats why I like to start from a simple HelloWorld. – Siddharth Jul 18 '12 at 02:32
3

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.

John J Smith
  • 11,435
  • 9
  • 53
  • 72
  • thanks, could you just help me understand a bit more what is the difference between having the override or commenting it out? – Genadinik Jul 23 '12 at 12:01
  • Sure, when you are implementing an interface, you don't use the override key word. If, however, you are extending an abstract class or a class with some abstract methods, then you use the override key word. Overriding method behaviour is one of the ways of implementing polymorphism: you could have several classes which override methods in an abstract base class but each of these classes could do something different e.g. you might have a class which will sort integers and another which would sort decimals - they could both override the sort() method in an abstract base class. – John J Smith Jul 23 '12 at 13:51
2

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.

1

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.

j2emanue
  • 60,549
  • 65
  • 286
  • 456
1

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).

easycheese
  • 5,859
  • 10
  • 53
  • 87