因为差不多2个月我正在寻找以下问题的解决方案。我在我的应用程序中实现了一个库,其中还包括IInAppBillingService.aidl文件和Google的In App Billing Library的其他部分。当我试图编译我的应用程序的发布版本时,它只会抛出以下错误:
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / android / vending / billing / IInAppBillingService $ Stub $ Proxy.class
暂时我只是使用这个库进行应用程序购买,而不是直接将它放在我的应用程序中。这在大多数情况下工作正常,但真正让我紧张的是,我无法改变IabHelper.class中的任何内容。由于我们都不认为Google In App Billing解决方案有时会出错,所以我想编辑IabHelper.class。所以现在问题2" IInAppBillingService.aidl"文件显然已经回来了。我已经尝试使用开头代码排除这部分库:
compile ('com.adobe.creativesdk:image:4.4.8') {
exclude module: 'com.android.vending.billing'
}
它不起作用..... :(我该怎么办?你还有其他解决办法吗?我讨厌浪费在所有图书馆问题上的时间.....
非常感谢!!
答案 0 :(得分:6)
答案 1 :(得分:4)
重复条目:com / android / vending / billing / IInAppBillingService $ Stub $ Proxy.class
这意味着您的项目中有两个文件IInAppBillingService.aidl
。删除您手动导入的那个。你应该不在项目中保留两个相似的类。
答案 2 :(得分:0)
搜索整个项目IInAppBillingService
,如果您找到此课程的多个副本,则必须删除所有只保留一个课程的副本。从billing library dependency
文件中删除所有gradle
,它将被构建。
答案 3 :(得分:0)
确定,因此您已经注意到文件重复。您需要做的就是仅一次包含该库。
在一个地方,您需要做:
implementation 'library name here'
在所有其他地方,使用:
api 'library name here'
如果模块的依赖库中有一个aidl文件,并且还想访问ANOTHER模块中的aidl文件,则此方法有效。您不能将其包含在第二个模块中,因为会得到一个重复的文件。
请注意,对于奖励积分,由于该库包含帮助,因此很可能包含android计费。但是您可能不希望实现该功能,所以可以这样做:
模块1:
implementation('library_with_aidl_and_old_version_of_other_libs') {
['other_lib1', 'other_lib2'].each { exclude group: it }
['com.android.vending.billing.*'].each { exclude module: it }
}
模块2:
api (library_with_aidl_and_old_version_of_other_libs) {
['other_lib1', 'other_lib2'].each { exclude group: it }
['com.android.vending.billing.*'].each { exclude module: it }
}
implementation 'other_lib1_later_version'
implementation 'other_lib2_later_version'
implementation 'billing_etc'
请注意,这些带有计费功能的库通常还包含旧版本的支持库,因此您还需要包括:
configurations.all {
resolutionStrategy {
force "com.android.support:support-v4:<some_version_code_here>"
}
}