我正在使用implementation 'com.android.billingclient:billing:1.1'
依赖在app app purchase中实现。但我得到Unable to merge dex
引起:com.android.dex.DexException:多个dex文件定义Lcom / android / vending / billing / IInAppBillingService
Error:Execution failed for task Execution failed for task app:transformDexArchiveWithExternalLibsDexMergerForDebug
java.lang.RuntimeException com.android.builder.dexing.DexArchiveMergerException
Unable to merge dex
下面是我的build.gradle
应用程序级文件代码
apply plugin: 'com.android.application'
//def BUTTER_KNIFE_VERSION = "8.5.1" //current version of butterknife
repositories {
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.app.syncyes"
multiDexEnabled true
minSdkVersion 19
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:$project.versionName"
implementation "com.android.support:exifinterface:$project.versionName"
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation "com.android.support:design:$project.versionName"
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:support-v4:27.1.1'
// sinch audio calling
implementation(name: 'sinch-android-rtc', version: '+', ext: 'aar')
// compile 'com.google.android.gms:play-services:12.0.1'
// implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
// Multidex
implementation 'com.android.support:multidex:1.0.3'
// RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.0.2'
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
implementation "com.google.firebase:firebase-core:16.0.3"
// firebase database
implementation 'com.google.firebase:firebase-database:16.0.2'
// videocache
implementation 'com.danikula:videocache:2.7.0'
// InApp Billing
implementation 'com.android.billingclient:billing:1.1'
// // firebase notification
implementation 'com.google.firebase:firebase-messaging:17.3.1'
// compile 'com.google.firebase:firebase-core:16.0.0'
// video compressor
implementation 'com.github.WindSekirun:MediaResizer:1.0.0'
// Dexter runtime permissions
implementation 'com.karumi:dexter:4.2.0'
implementation 'com.github.darsh2:MultipleImageSelect:3474549'
// twitter sharing
implementation('com.twitter.sdk.android:tweet-composer:1.0.5@aar') {
transitive = true;
}
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation('com.facebook.android:account-kit-sdk:4.23.0') {
exclude group: 'com.google.android.gms', module: 'play-services-auth-api-phone'
exclude group: 'com.google.android.gms', module: 'play-services-auth'
}
}
// annotationProcessor "com.jakewharton:butterknife-compiler:$BUTTER_KNIFE_VERSION"
apply plugin: 'com.google.gms.google-services'
下面是我的项目级别build.gradle
文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url 'https://maven.fabric.io/public'
}
}
project.ext{
myBuildToolsVersion="20.0.0" //String
myMinSdkVersion=10 //Integer
myTargetSdkVersion=22
myCompileSdkVersion=27
// ext.versionName = '27.1.1'
versionName = '27.1.1'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
尝试清理项目,然后它应该工作。