24

Problem occurs only on release build or on generate signed apk, when I build debug - no such problem.

Problem arrived right after upgrade AS to version 3.1

Program type already present: com.android.vending.billing.IInAppBillingService
Message{kind=ERROR, text=Program type already present: com.android.vending.billing.IInAppBillingService, sources=[Unknown source file], tool name=Optional.of(D8)}

enter image description here dependencies:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
    implementation('org.apache.httpcomponents:httpmime:4.3') {
        exclude module: "httpclient"
    }
    implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.0'
    implementation 'com.github.clans:fab:1.6.4'
    implementation 'com.android.billingclient:billing:1.0'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
    implementation 'com.github.eggheadgames:Siren:1.5.0'
    implementation 'me.leolin:ShortcutBadger:1.1.18@aar'
    implementation 'me.everything:overscroll-decor-android:1.0.4'
    implementation 'com.baoyz.pullrefreshlayout:library:1.2.0'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
    //implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.github.esafirm.android-image-picker:imagepicker:1.8.0'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.google.android.gms:play-services-places:12.0.0'
    implementation 'com.google.android.gms:play-services-gcm:12.0.0'
    implementation 'com.github.mukeshsolanki:country-picker-android:1.1.9'
    implementation 'com.github.rey5137:material:1.2.4'
    implementation 'com.mikepenz:iconics-core:2.8.9@aar'
    implementation 'com.mikepenz:fontawesome-typeface:4.7.0.1@aar'
    implementation 'com.mcxiaoke.volley:library:1.0.19'
    implementation 'com.android.support:design:27.0.2'
    implementation 'com.android.support:animated-vector-drawable:27.0.2'
    implementation 'com.android.support:customtabs:27.0.2'
    implementation 'com.android.support:support-annotations:27.0.2'
    implementation 'com.android.support:recyclerview-v7:27.0.2'
    implementation 'com.android.support:cardview-v7:27.0.2'
    implementation 'com.android.support:support-v4:27.0.2'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'org.greenrobot:eventbus:3.0.0'
    implementation 'com.google.code.gson:gson:2.8.0'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }
    implementation 'com.google.firebase:firebase-firestore:12.0.0'
    implementation 'com.google.firebase:firebase-storage:12.0.0'
    implementation 'com.google.firebase:firebase-database:12.0.0'
    implementation 'com.google.firebase:firebase-messaging:12.0.0'
    implementation 'com.google.firebase:firebase-auth:12.0.0'
    implementation 'com.google.firebase:firebase-core:12.0.0'
    implementation 'com.facebook.android:facebook-android-sdk:4.30.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'me.relex:circleindicator:1.1.8@aar'
    implementation 'com.yalantis:ucrop:2.2.0'
    implementation 'com.appsflyer:af-android-sdk:4.8.8@aar'
    implementation 'com.android.installreferrer:installreferrer:1.0'
}

M lost to find solution to fix this, any suggestions - welcome. Thanks!

Stepan Maksymov
  • 2,618
  • 19
  • 31
  • 4
    Finally was able to resolve problem by simple deleting of aidl import lib, now compilation success on both debug and release, don't know why like this, Documentation seems outdated for inAppPurchases in google, seems this class is added from somewhere automatically. – Stepan Maksymov Apr 01 '18 at 16:17
  • I am having the same issue, and it was fine in previous builds. Can you explain a bit more about what aidl files you deleted? Was it the IInAppBillingService class located at com.android.vending.billing inside src/main? – SamIAmHarris Apr 02 '18 at 16:14
  • 1
    Went ahead and deleted the IInAppBillingService.aidl file, and my signed releases are working now. I need to go check out the documentation for InAppPurchases to see if they have updated them or recommended any changes. – SamIAmHarris Apr 02 '18 at 16:28
  • Looks like they still recommend adding the .aidl file, but I agree that the docs are probably just outdated. I found the info here: https://developer.android.com/google/play/billing/billing_integrate.html – SamIAmHarris Apr 02 '18 at 16:30
  • This is actually the proper solution for it ? We can't try to exclude the module ? – Ionut J. Bejan Apr 20 '18 at 08:43
  • This worked for me with same issue, thank you for posting, you should post it as an accepted answer. – ZengoTim Apr 24 '18 at 19:16

5 Answers5

17

Solution was close: Finally was able to resolve problem by simple deleting of aidl import lib, now compilation success on both debug and release, don't know why like this, Documentation seems outdated for inAppPurchases in google, seems this class is added from somewhere automatically.

Stepan Maksymov
  • 2,618
  • 19
  • 31
  • 3
    How can i do this? – Igor Ronner May 22 '18 at 20:08
  • Thanks, it works. The reason is you are using a billing library which already added this !! – Quan Nguyen Jul 12 '18 at 04:44
  • Oh man, I have been on it all afternoon with different error messages. I have changed buildToolsVersion, compileSdkVersion, supportLibVersion, and everything else that has been suggested on the net. Finally, I deleted the aidl folder, rebuilt it, all good, added the aidl folder again and got this fault. What a joke. Their sample project has the aidl folder and shows no errors with the exact same setup. How does that work? Thanks anyway. – Immy Aug 27 '18 at 08:52
  • I have the same exact message and this solution didn't work for me – salouri Aug 28 '18 at 15:53
7

Delete the IinAppBillingService.aidl file from the android studio and just run the app again. Hope this will help.

6
  • Whenever you trying to adding google play billing library with

implementation 'com.android.billingclient:billing:version-code'

  • You must remove IInAppBillingService.aidl file from your project.

check this path of IInAppBillingService.aidl in Project level view

  • path :- app > src > main > aidi and so on...

You just delete this aidi folder or delete IInAppBillingService.aidl and rebuild your project. An error will disappear.

Bhaven Shah
  • 692
  • 1
  • 5
  • 18
1

Before I explain my fix, let me tell you how did I managed to create it.

I started with Ionic In App Purchase 2 , worked perfect in development, after I've deployed with

ionic cordova build android --prod --release

Fail! Doesn't work

Ok! I thought I need to take another approach / package, so I've go to In App Purchase (version 1 if we want to call it)

After 1 try without luck in development mode, I thought , ok lets go back to Version 2, so when I've tried to deploy, 0 success!

I tried the following things that worked for me

  1. Delete node_modulesfolder
  2. Run npm install
  3. Run ionic cordova platform remove android && ionic cordova platform add android

So we are clean... now the most important piece , you can't have multiple versions of in-app-purchase , so my solution was to remove the version 1.

  1. Run cordova plugin remove cordova-plugin-inapppurchase

Just to be sure if you are clean , you shouldn't be able to find any of these 2

enter image description here

Sorin Veștemean
  • 1,772
  • 19
  • 17
0

in my case same file added two time at different location with .aidl when I search, in windows explorer source code of project then I able to find it, then I delete it, After it APK generated successfully!

Abdur Rehman
  • 1,247
  • 10
  • 13