Reputation: 765
I have the following error:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK plugin.xml File1: /home/aaa/.gradle/caches/modules-2/files-2.1/org.eclipse.sisu/org.eclipse.sisu.inject/0.0.0.M5/4f6bda3f528c60a12e70db2e7a3feee539dcc8cd/org.eclipse.sisu.inject-0.0.0.M5.jar File2: /home/aaa/.gradle/caches/modules-2/files-2.1/kr.motd.maven/os-maven-plugin/1.2.3.Final/5467b32e1fe84f9ee2ea00a7e64128a269fb44a6/os-maven-plugin-1.2.3.Final.jar
and I get this error when I add this lite:
compile 'com.google.protobuf:protobuf-gradle-plugin:0.7.6
To the build.grandle (app) dependencies:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
defaultConfig.with {
applicationId = "com.google.sample.helloandroid"
minSdkVersion.apiLevel = 17
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-android.txt'))
}
}
android.ndk {
moduleName = "hello-android-jni"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.google.protobuf:protobuf-gradle-plugin:0.7.6'
}
How can I solve the problem? I need to add the protobuf to use in the project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.4.0'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.6'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Upvotes: 1
Views: 671
Reputation: 4774
Protobuf should be added at buildscript
level, it should be in the build.gradle that its in your root folder not inside /app
, also please ensure youre using gradle 2.12+ and Java7:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.6'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
then under your app/build.gradle do this:
android {
packagingOptions {
pickFirst 'plugin.xml'
}
}
Upvotes: 1