[Solved] Adding in-app unity service to a game already including admob causes error

I have a game already serving interstitial ads using Google mobile ads plugin. Then, I decided to include Unity in-app purchase service (available in Unity 5.3) but I get an error during the build phase (see below). If I delete the Google Mobile Ads everything start to work.

CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir=“/Applications/android-sdk/tools” -Dfile.encoding=UTF8 -jar “/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar” -

stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/android/vending/billing/IInAppBillingService$Stub$Proxy;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/android/vending/billing/IInAppBillingService$Stub;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/android/vending/billing/IInAppBillingService;
3 errors; aborting
]
stdout[
processing archive bin/classes.jar…
processing com/unity3d/player/a$1.class…
processing com/unity3d/player/a$2.class…
processing com/unity3d/player/a$a.class…
processing com/unity3d/player/a.class…
processing com/unity3d/player/b$1.class…
processing com/unity3d/player/b$2.class…
processing com/unity3d/player/b.class…
processing com/unity3d/player/c.class…
processing com/unity3d/player/d$1.class…
processing com/unity3d/player/d$2.class…
processing com/unity3d/player/d.class…
processing com/unity3d/player/e.class…
processing com/unity3d/player/f.class…
processing com/unity3d/player/g.class…
processing com/unity3d/player/h.class…
processing com/unity3d/player/i.class…
processing com/unity3d/player/j.class…
processing com/unity3d/player/k$1.class…
processing com/unity3d/player/k$2$1$1.class…
processing com/unity3d/player/k$2$1.class…
processing com/unity3d/player/k$2.class…
processing com/unity3d/player/k.class…
processing com/unity3d/player/l$1.class…
processing com/unity3d/player/l.class…
processing com/unity3d/player/m.class…
processing com/unity3d/player/n$1.class…
processing com/unity3d/player/n.class…
processing com/unity3d/player/o.class…
processing com/unity3d/player/p$1.class…
processing com/unity3d/player/p.class…
processing com/unity3d/player/NativeLoader.class…
processing com/unity3d/player/q.class…
processing com/unity3d/player/ReflectionHelper$1.class…
processing com/unity3d/player/ReflectionHelper$a.class…
processing com/unity3d/player/ReflectionHelper.class…
processing com/unity3d/player/r.class…
processing com/unity3d/player/s$1.class…
processing com/unity3d/player/s$2.class…
processing com/unity3d/player/s$3.class…
processing com/unity3d/player/s.class…
processing com/unity3d/player/t.class…
processing com/unity3d/player/u.class…
processing com/unity3d/player/UnityPlayer$1.class…
processing com/unity3d/player/UnityPlayer$2.class…
processing com/unity3d/player/UnityPlayer$4.class…
processing com/unity3d/player/UnityPlayer$5.class…
processing com/unity3d/player/UnityPlayer$6.class…
processing com/unity3d/player/UnityPlayer$7.class…
processing com/unity3d/player/UnityPlayer$8.class…
processing com/unity3d/player/UnityPlayer$9.class…
processing com/unity3d/player/UnityPlayer$10.class…
processing com/unity3d/player/UnityPlayer$11.class…
processing com/unity3d/player/UnityPlayer$12.class…
processing com/unity3d/player/UnityPlayer$13.class…
processing com/unity3d/player/UnityPlayer$14.class…
processing com/unity3d/player/UnityPlayer$3.class…
processing com/unity3d/player/UnityPlayer$15$1.class…
processing com/unity3d/player/UnityPlayer$15.class…
processing com/unity3d/player/UnityPlayer$16.class…
processing com/unity3d/player/UnityPlayer$17.class…
processing com/unity3d/player/UnityPlayer$18.class…
processing com/unity3d/player/UnityPlayer$19.class…
processing com/unity3d/player/UnityPlayer$20.class…
processing com/unity3d/player/UnityPlayer$a.class…
processing com/unity3d/player/UnityPlayer$b.class…
processing com/unity3d/player/UnityPlayer$c.class…
processing com/unity3d/player/UnityPlayer.class…
processing com/unity3d/player/UnityPlayerActivity.class…
processing com/unity3d/player/UnityPlayerNativeActivity.class…
processing com/unity3d/player/UnityPlayerProxyActivity.class…
processing com/unity3d/player/v.class…
processing com/unity3d/player/UnityWebRequest.class…
processing com/unity3d/player/w$1.class…
processing com/unity3d/player/w.class…
processing com/unity3d/player/WWW.class…
processing org/fmod/FMODAudioDevice.class…
processing org/fmod/a.class…
processing bitter/jnibridge/JNIBridge$a.class…
processing bitter/jnibridge/JNIBridge.class…
processing bin/classes/./com/argonnetech/timetables/R$attr.class…
processing bin/classes/./com/argonnetech/timetables/R$color.class…
processing bin/classes/./com/argonnetech/timetables/R$dimen.class…
processing bin/classes/./com/argonnetech/timetables/R$drawable.class…
processing bin/classes/./com/argonnetech/timetables/R$id.class…
processing bin/classes/./com/argonnetech/timetables/R$integer.class…
processing bin/classes/./com/argonnetech/timetables/R$layout.class…
processing bin/classes/./com/argonnetech/timetables/R$raw.class…
processing bin/classes/./com/argonnetech/timetables/R$string.class…
processing bin/classes/./com/argonnetech/timetables/R$style.class…
processing bin/classes/./com/argonnetech/timetables/R$styleable.class…
processing bin/classes/./com/argonnetech/timetables/R.class…
processing bin/classes/./com/facebook/android/R$attr.class…
processing bin/classes/./com/facebook/android/R$color.class…
processing bin/classes/./com/facebook/android/R$dimen.class…
processing bin/classes/./com/facebook/android/R$drawable.class…
processing bin/classes/./com/facebook/android/R$id.class…
processing bin/classes/./com/facebook/android/R$integer.class…
processing bin/classes/./com/facebook/android/R$layout.class…
processing bin/classes/./com/facebook/android/R$raw.class…
processing bin/classes/./com/facebook/android/R$string.class…
processing bin/classes/./com/facebook/android/R$style.class…
processing bin/classes/./com/facebook/android/R$styleable.class…
processing bin/classes/./com/facebook/android/R.class…
processing bin/classes/./com/facebook/R$attr.class…
processing bin/classes/./com/facebook/R$color.class…
processing bin/classes/./com/facebook/R$dimen.class…
processing bin/classes/./com/facebook/R$drawable.class…
processing bin/classes/./com/facebook/R$id.class…
processing bin/classes/./com/facebook/R$integer.class…
processing bin/classes/./com/facebook/R$layout.class…
processing bin/classes/./com/facebook/R$raw.class…
processing bin/classes/./com/facebook/R$string.class…
processing bin/classes/./com/facebook/R$style.class…
processing bin/classes/./com/facebook/R$styleable.class…
processing bin/classes/./com/facebook/R.class…
processing bin/classes/./com/google/android/gms/R$attr.class…
processing bin/classes/./com/google/android/gms/R$color.class…
processing bin/classes/./com/google/android/gms/R$dimen.class…
processing bin/classes/./com/google/android/gms/R$drawable.class…
processing bin/classes/./com/google/android/gms/R$id.class…
processing bin/classes/./com/google/android/gms/R$integer.class…
processing bin/classes/./com/google/android/gms/R$layout.class…
processing bin/classes/./com/google/android/gms/R$raw.class…
processing bin/classes/./com/google/android/gms/R$string.class…
processing bin/classes/./com/google/android/gms/R$style.class…
processing bin/classes/./com/google/android/gms/R$styleable.class…
processing bin/classes/./com/google/android/gms/R.class…
processing bin/classes/./com/google/unity/R$attr.class…
processing bin/classes/./com/google/unity/R$color.class…
processing bin/classes/./com/google/unity/R$dimen.class…
processing bin/classes/./com/google/unity/R$drawable.class…
processing bin/classes/./com/google/unity/R$id.class…
processing bin/classes/./com/google/unity/R$integer.class…
processing bin/classes/./com/google/unity/R$layout.class…
processing bin/classes/./com/google/unity/R$raw.class…
processing bin/classes/./com/google/unity/R$string.class…
processing bin/classes/./com/google/unity/R$style.class…
processing bin/classes/./com/google/unity/R$styleable.class…
processing bin/classes/./com/google/unity/R.class…
processing bin/classes/./com/unity/purchasing/googleplay/R$attr.class…
processing bin/classes/./com/unity/purchasing/googleplay/R$color.class…
processing bin/classes/./com/unity/purchasing/googleplay/R$dimen.class…
processing bin/classes/./com/unity/purchasing/googleplay/R$drawable.class…
processing bin/classes/./com/unity/purchasing/googleplay/R$id.class…
processing bin/classes/./com/unity/purchasing/googleplay/R$integer.class…
processing bin/classes/./com/unity/purchasing/googleplay/R$layout.class…
processing bin/classes/./com/unity/purchasing/googleplay/R$raw.class…
processing bin/classes/./com/unity/purchasing/googleplay/R$string.class…
processing bin/classes/./com/unity/purchasing/googleplay/R$style.class…
processing bin/classes/./com/unity/purchasing/googleplay/R$styleable.class…
processing bin/classes/./com/unity/purchasing/googleplay/R.class…
processing bin/classes/./com/unity/purchasing/R$attr.class…
processing bin/classes/./com/unity/purchasing/R$color.class…
processing bin/classes/./com/unity/purchasing/R$dimen.class…
processing bin/classes/./com/unity/purchasing/R$drawable.class…
processing bin/classes/./com/unity/purchasing/R$id.class…
processing bin/classes/./com/unity/purchasing/R$integer.class…
processing bin/classes/./com/unity/purchasing/R$layout.class…
processing bin/classes/./com/unity/purchasing/R$raw.class…
processing bin/classes/./com/unity/purchasing/R$string.class…
processing bin/classes/./com/unity/purchasing/R$style.class…
processing bin/classes/./com/unity/purchasing/R$styleable.class…
processing bin/classes/./com/unity/purchasing/R.class…
processing archive plugins/./android-support-v4.jar…
ignored resource META-INF/
ignored resource META-INF/MANIFEST.MF
ignored resource android/
ignored resource android/support/
ignored resource android/support/annotation/
processing android/support/annotation/ColorRes.class…
processing android/support/annotation/XmlRes.class…
processing android/support/annotation/BoolRes.class…
processing android/support/annotation/RequiresPermission$Read.class…
processing android/support/annotation/RequiresPermission.class…
processing android/support/annotation/RawRes.class…
processing android/support/annotation/RequiresPermission$Write.class…
processing android/support/annotation/StyleableRes.class…
processing android/support/annotation/UiThread.class…
processing android/support/annotation/TransitionRes.class…
processing android/support/annotation/AnimRes.class…
processing android/support/annotation/FloatRange.class…
processing android/support/annotation/CheckResult.class…
processing android/support/annotation/IntegerRes.class…
processing android/support/annotation/Keep.class…
processing android/support/annotation/AttrRes.class…
processing android/support/annotation/IntRange.class…
processing android/support/annotation/CallSuper.class…
processing android/support/annotation/MenuRes.class…
processing android/support/annotation/WorkerThread.class…
processing android/support/annotation/FractionRes.class…
processing android/support/annotation/Nullable.class…
processing android/support/annotation/InterpolatorRes.class…
processing android/support/annotation/ColorInt.class…
processing android/support/annotation/PluralsRes.class…
processing android/support/annotation/MainThread.class…
processing android/support/annotation/DrawableRes.class…
processing android/support/annotation/LayoutRes.class…
processing android/support/annotation/Size.class…
processing android/support/annotation/DimenRes.class…
processing android/support/annotation/ArrayRes.class…
processing android/support/annotation/IdRes.class…
processing android/support/annotation/AnyRes.class…
processing android/support/annotation/StringRes.class…
processing android/support/annotation/NonNull.class…
processing android/support/annotation/IntDef.class…
processing android/support/annotation/BinderThread.class…
processing android/support/annotation/StyleRes.class…
processing android/support/annotation/StringDef.class…
processing android/support/annotation/AnimatorRes.class…
processing android/support/annotation/VisibleForTesting.class…
ignored resource android/support/v4/
ignored resource android/support/v4/internal/
ignored resource android/support/v4/internal/view/
processing android/support/v4/internal/view/SupportSubMenu.class…
processing android/support/v4/internal/view/SupportMenu.class…
processing android/support/v4/internal/view/SupportMenuItem.class…
ignored resource android/support/v4/app/
processing android/support/v4/app/NavUtils$NavUtilsImplBase.class…
processing android/support/v4/app/NotificationManagerCompat.class…
processing android/support/v4/app/NotificationCompat$Style.class…
processing android/support/v4/app/ShareCompatICS.class…
processing android/support/v4/app/FragmentTabHost$SavedState$1.class…
processing android/support/v4/app/NotificationCompat$NotificationCompatImplJellybean.class…
processing android/support/v4/app/ShareCompat$ShareCompatImplJB.class…
processing android/support/v4/app/FragmentTransaction$Transit.class…
processing android/support/v4/app/FragmentState$1.class…
processing android/support/v4/app/FragmentManagerImpl$AnimateOnHWLayerIfNeededListener$1.class…
processing android/support/v4/app/NotificationCompat$Action$1.class…
processing android/support/v4/app/NotificationCompat$Builder.class…
processing android/support/v4/app/ActivityCompat$SharedElementCallback21Impl.class…
processing android/support/v4/app/RemoteInput$1.class…
processing android/support/v4/app/BackStackRecord$3.class…
processing android/support/v4/app/NotificationBuilderWithBuilderAccessor.class…
processing android/support/v4/app/NotificationCompat$NotificationCompatImplHoneycomb.class…
processing android/support/v4/app/FragmentStatePagerAdapter.class…
processing android/support/v4/app/ActionBarDrawerToggleJellybeanMR2.class…
processing android/support/v4/app/RemoteInput.class…
processing android/support/v4/app/FragmentManagerImpl$1.class…
processing android/support/v4/app/NotificationCompat$BigTextStyle.class…
processing android/support/v4/app/RemoteInput$ImplJellybean.class…
processing android/support/v4/app/BaseFragmentActivityHoneycomb.class…
processing android/support/v4/app/FragmentTabHost$1.class…
processing android/support/v4/app/ShareCompat$ShareCompatImplBase.class…
processing android/support/v4/app/FragmentManager$BackStackEntry.class…
processing android/support/v4/app/SharedElementCallback.class…
processing android/support/v4/app/ActivityOptionsCompat$ActivityOptionsImplJB.class…
processing android/support/v4/app/BackStackRecord$2.class…
processing android/support/v4/app/FragmentManagerImpl$3.class…
processing android/support/v4/app/TaskStackBuilder.class…
processing android/support/v4/app/NotificationCompatKitKat$Builder.class…
processing android/support/v4/app/FragmentManagerImpl$5.class…
processing android/support/v4/app/NotificationCompat$NotificationCompatImplBase.class…
processing android/support/v4/app/FragmentTabHost$DummyTabFactory.class…
processing android/support/v4/app/DialogFragment.class…
processing android/support/v4/app/FragmentActivity.class…
processing android/support/v4/app/NotificationCompat$1.class…
processing android/support/v4/app/ActivityCompat22.class…
processing android/support/v4/app/NotificationCompat$BigPictureStyle.class…
processing android/support/v4/app/NotificationCompat$Action$Extender.class…
processing android/support/v4/app/ActivityManagerCompatKitKat.class…
processing android/support/v4/app/FragmentTransaction.class…
processing android/support/v4/app/NotificationCompat$CarExtender$UnreadConversation$Builder.class…
processing android/support/v4/app/NotificationCompatIceCreamSandwich$Builder.class…
processing android/support/v4/app/ListFragment$2.class…
processing android/sup

@a-dibacco The plugin looks like it includes a problematic file, a purchasing (a.k.a. billing) JAR which itself contains Java classes from the package “com/android/vending/billing/IInAppBillingService”. These same Java classes are included by Unity IAP to support in-app purchasing. This duplication confuses the Android build, and so to successfully build the Java classes must be made unique.

I do not have the Google Mobile Ads package (is there a link? I found a repo that might be the source) but I can suggest an untested workaround experiment: (NOTE: Back up your code first!) Try finding the billing JAR in the Google Mobile Ads Plugin folder of your project, and moving the JAR completely out of Assets. I guess the JAR filename could be “in-app-billing-service-aidl.jar” or possibly “billingaidl.jar”. Then rebuild for Android.

2 Likes

I deleted in-app-billing-service-aidl.jar under Assets/Plugins/Android/GoogleMobileAdsPlugin/libs and now I’m able to build an APK without problems.

Thank you very much,
Antonio.

2 Likes

@a-dibacco Does this workaround break AdMob or does it still work?

AdMob still works fine

1 Like