软件包IInAppBillingService不存在

时间:2018-07-06 04:10:33

标签: android in-app-billing android-billing

我正在尝试使用应用内结算库。

自2天以来一切正常。现在,当我生成签名的APK时,它说

AGPBI: {"kind":"error","text":"Program type already present: com.android.vending.billing.IInAppBillingService","sources":[{}],"tool":"D8"}

最初是这样的。 enter image description here

从我所做的研究中,我发现我必须删除.aidl文件和库,执行了“清理项目”和“重建项目”,并且遇到以下错误。

error: package com.android.vending.billing does not exist

接下来,我在src / main中创建了一个AIDL文件夹,并在其中创建了一个名为com.android.vending.billing的包,并将.aidl文件放入其中。

这是我完成上述步骤后的样子。

enter image description here

然后做了一个干净的项目并重建了项目。

即使执行了上述步骤,我仍然收到以下错误。

error: package com.android.vending.billing does not exist
import com.android.vending.billing.IInAppBillingService;

我想念的是什么?我应该怎么做才能解决此问题。

这是我的build.gradle(app)的外观,如果有帮助的话。

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.krishna.myapp.myappp"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
    buildToolsVersion '27.0.3'
}

dependencies {
    compile project(':library')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //    classpath "io.realm:realm-gradle-plugin:4.3.1"
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    compile 'com.google.firebase:firebase-messaging:12.0.0'
    compile 'com.google.android.gms:play-services-places:12.0.0'
    compile 'com.jakewharton:butterknife:8.4.0'
    compile 'com.google.android.gms:play-services-location:12.0.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    compile 'me.relex:circleindicator:1.0.0@aar'
    compile 'com.anjlab.android.iab.v3:library:1.0.44'
    //compile 'com.viewpagerindicator:library:2.4.1@aar'
    compile 'com.nineoldandroids:library:2.4.+'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.9.3@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:answers:1.4.2@aar') {
        transitive = true;
    }
}

apply plugin: 'com.google.gms.google-services'

在添加android.enableD8 = false选项之后添加stacktrace。

Executing tasks: [clean, :library:assembleDebug, :app:assembleDebug]

Configuration on demand is an incubating feature. WARNING: The option 'android.enableD8' is deprecated and should not be used anymore. Use 'android.enableD8=true' to remove this warning. It will be removed in AGP version 3.3.. NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to C:\Users\Krishna\AppData\Local\Android\Sdk\ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of
2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) WARNING: The option 'android.enableD8' is deprecated and should not be used anymore. Use 'android.enableD8=true' to remove this warning. It will be removed in AGP version 3.3.. NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to C:\Users\Krishna\AppData\Local\Android\Sdk\ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

WARNING: Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation' and 'androidTestApi'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html WARNING: Configuration 'androidTestApi' is obsolete and has been replaced with 'androidTestImplementation'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html :clean UP-TO-DATE :app:clean :library:clean :library:preBuild UP-TO-DATE :library:preDebugBuild UP-TO-DATE :library:compileDebugAidl :library:compileDebugRenderscript :library:checkDebugManifest :library:generateDebugBuildConfig :library:generateDebugResValues :library:generateDebugResources :library:packageDebugResources :library:platformAttrExtractor :library:processDebugManifest :library:prepareLintJar UP-TO-DATE :library:javaPreCompileDebug :library:mergeDebugConsumerProguardFiles :library:mergeDebugShaders :library:compileDebugShaders :library:generateDebugAssets :library:packageDebugAssets :library:packageDebugRenderscript NO-SOURCE :library:processDebugJavaRes NO-SOURCE :library:compileDebugNdk NO-SOURCE :library:mergeDebugJniLibFolders :library:transformNativeLibsWithMergeJniLibsForDebug :library:transformNativeLibsWithSyncJniLibsForDebug :app:preBuild UP-TO-DATE :app:preDebugBuild :app:compileDebugAidl NO-SOURCE :app:compileDebugRenderscript :app:checkDebugManifest :app:generateDebugBuildConfig :app:prepareLintJar UP-TO-DATE :app:mainApkListPersistenceDebug :app:mergeDebugShaders :app:compileDebugShaders :app:generateDebugAssets :app:mergeDebugAssets :app:processDebugGoogleServices Parsing json file: E:\newp\july2\MyApp2 2\MyApp2 2\app\google-services.json :app:createDebugCompatibleScreenManifests :app:processDebugManifest :app:fabricGenerateResourcesDebug :app:generateDebugResValues :app:generateDebugResources :app:mergeDebugResources :library:generateDebugRFile :library:generateDebugSources Note: E:\newp\july2\MyApp2 2\MyApp2 2\library\src\main\java\com\anjlab\android\iab\v3\BillingProcessor.java uses or overrides a deprecated API. Note: Recompile with
-Xlint:deprecation for details. :library:compileDebugJavaWithJavac :library:extractDebugAnnotations :library:transformResourcesWithMergeJavaResForDebug :library:transformClassesAndResourcesWithSyncLibJarsForDebug :library:bundleDebug :library:compileDebugSources :library:assembleDebug :app:splitsDiscoveryTaskDebug :app:processDebugResources :app:generateDebugSources :library:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug :app:javaPreCompileDebug Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: E:\newp\july2\MyApp2 2\MyApp2 2\app\src\main\java\com\myapp\myapp2\krishna\MyApp2\Adapter\PlaceAutocompleteAdapter.java uses unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details. :app:compileDebugJavaWithJavac :app:compileDebugNdk NO-SOURCE :app:compileDebugSources :app:transformClassesWithDexBuilderForDebug :app:transformDexArchiveWithExternalLibsDexMergerForDebug java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)   at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)     at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:720)    at java.util.ArrayList.forEach(ArrayList.java:1249)     at com.android.builder.dexing.DxDexArchiveMerger.mergeMonoDex(DxDexArchiveMerger.java:177)  at com.android.builder.dexing.DxDexArchiveMerger.mergeDexArchives(DxDexArchiveMerger.java:118)  at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:101)    at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:36)     at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)   at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)  at java.util.concurrent.ForkJoinTask.externalAwaitDone(ForkJoinTask.java:326)   at java.util.concurrent.ForkJoinTask.doJoin(ForkJoinTask.java:391)  at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:719)    at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:406)  at com.android.build.gradle.internal.transforms.DexMergerTransform.transform(DexMergerTransform.java:228)   at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221)  at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217)  at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)   at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)   at sun.reflect.GeneratedMethodAccessor536.invoke(Unknown Source)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)     at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)   at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)   at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)  at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)  at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)   at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)     at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)   at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)     at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)   at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)  at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)     at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)     at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)   at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)     at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)   at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)     at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:256)   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)  at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)  at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)     at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)     at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)  at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)     at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)   at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)   at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)    at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)   at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)     at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:720)    at com.android.builder.dexing.DxDexArchiveMerger.lambda$mergeMonoDex$0(DxDexArchiveMerger.java:171)     at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)   at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)  at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)  at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)  at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex    at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431)   ... 4 more Caused by: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex     at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:72)   at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)   at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)   ... 4 more Caused by: com.android.dex.DexException: Multiple dex files define Lcom/android/vending/billing/IInAppBillingService;    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:660)     at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:615)    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:597)    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)    at com.android.dx.merge.DexMerger.merge(DexMerger.java:197)     at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)   ... 6 more

AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: com.android.dex.DexException: Multiple dex files define Lcom/android/vending/billing/IInAppBillingService;","sources":[{}],"original":"UNEXPECTED TOP-LEVEL EXCEPTION:\ncom.android.dex.DexException: Multiple dex files define Lcom/android/vending/billing/IInAppBillingService;\n","tool":"Dex"} AGPBI: {"kind":"error","text":"com.android.dex.DexException: Multiple dex files define Lcom/android/vending/billing/IInAppBillingService;","sources":[{}]} AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:660)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:615)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:597)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:197)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)","sources":[{}]} AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)","sources":[{}]} :app:transformDexArchiveWithDexMergerForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong: Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0. See https://docs.gradle.org/4.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 51s 49 actionable tasks: 46 executed, 3 up-to-date

3 个答案:

答案 0 :(得分:1)

请将此内容插入build.gradle依赖项

implementation 'com.android.billingclient:billing:2.1.0'

答案 1 :(得分:0)

我亲自在“我的项目”中对其进行了测试。

请从库下面删除

compile 'com.anjlab.android.iab.v3:library:1.0.44'

如果不需要它。因为它也有IInAppBillingService类,并且与您的com.android.vending.billing.IInAppBillingService类冲突。

答案 2 :(得分:0)

如果有人将应用程式中的帐单更新为以下方式后得到此信息:

com.android.billingclient:billing:2.1.0//triggers error

尝试更改回:

com.android.billingclient:billing:2.0.1//will get new version available warning, a trap at this point