Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Can't Google's Market Billing Sample Build in a Signed Release Version?

I tried looking into similar problems, but the solutions offered there do not seem to fit my particular situation:

I initially followed the instructions for Configuring and building the sample application for In-app Billing, replacing the security key with the public key from Google's Developer account and changing the package name from com.example to com.billtheape.

I then built a non-release version and ran a "sanity check" on my Android phone. Everything went OK (except for accessing the Android Market server, of course, since by design it only works with a signed release version).

Then I tried to build a signed release version, but received the error:

[2012-01-03 20:52:45 - Dex Loader] Unable to execute dex: 
  Multiple dex files define Lcom/android/vending/billing/IMarketBillingService;

[2012-01-03 20:52:45 - Dungeons] Conversion to Dalvik format failed: 
  Unable to execute dex: Multiple dex files define Lcom/android/vending/billing/IMarketBillingService;

The problem now is that even the "debug version" building generated the same error, regardless of how many times I tried to clean the project.

This didn't look to me like a Build Path issue in the sense that the accepted answer described (I checked that, too, but couldn't find anything suspicious). So I tried something else:

  1. Exited Eclipse
  2. Spotted three subdirectories under %ANDROID_HOME%\extras\google\market_billing\gen\com: (1) android (2) example (3) billtheape
  3. Deleted the subdirectory example.
  4. Started Eclipse and cleaned the project.

Debug version builds now properly, but signed release still generates the same error. It turns out that deleting that extraneous subdirectory wasn't what did the magic, but rather restarting Eclipse and then cleaning the project.

OK, so at least I got the "debug version" working back, but the signed release Export keeps failing with the same error.

Any idea what this error means, why it happens and how to fix it?

like image 254
Bill The Ape Avatar asked Jan 04 '12 02:01

Bill The Ape


2 Answers

Short answer: Because Eclipse + ADT sucks. That's why.

Longer answer: I just imported the same exact project to a different machine with a slightly different configuration: Eclipse 3.6.2 (instead of 3.6.1 in the problematic system described above) and SDK R13 (instead of R9 in the problematic system).

Then I tried to export it, using the same exact steps described above. Works like a charm!

What is this? Voodoo?

What happened to the days in which the IDE behaved more predictably than the software I was trying to develop?

Next step: Upgrade Eclipse (to 3.6.2) only, on the problematic system and see whether this solves the problem in that system, too.

Update: I just finished updating Eclipse 3.6.1 to 3.6.2 on the offending system. It turns out that it is impossible to install Eclipse and keep the existing ADT. https://dl-ssl.google.com/android/eclipse/ forces you to install "the latest & greatest" even if you want otherwise (for configuration management & tracking reasons for example). So with the new Eclipse 3.6.2 I got ADT 16.0.0.v201112150204-238534 as well. Works like a charm!

The root cause and explanation for the odd behavior of the combination Eclipse 3.6.1 + ADT 9.0.1.v201101191456-93220 will never be known... and this is a combo with which developers were supposed to (and did) release commercial grade apps to the Android Market at some point in time. Amazing.

like image 162
Bill The Ape Avatar answered Nov 20 '22 19:11

Bill The Ape


I too had the same issue and i solved it by :

  1. Delete bin & gen folder
  2. Remove the dependency libraries(if any) and add them back
  3. Finally clean up the project and build it again.

Done!

like image 32
Raneez Ahmed Avatar answered Nov 20 '22 21:11

Raneez Ahmed