0

I got this error when add project library gpuimage-library . to my app's gradle.build would fix the issue, however, it doesn't. Here is what my app's gradle.build currently looks like.

This is top-level build.gradle config:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'

        // 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
}

This is my app/build.gradle config:

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 2
        versionName "2.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        ndk {
            abiFilters 'armeabi-v7a'
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'lib/armeabi-v7a/librsjni.so'
    }
    sourceSets.main.jni.srcDirs = []
    sourceSets.main.jniLibs.srcDirs = ['src/main/libs', 'src/main/jniLibs']

    task ndkBuild(type: Exec, description: 'Compile JNI source with NDK') {
        Properties properties = new Properties()
        properties.load(project.rootProject.file('local.properties').newDataInputStream())
        def ndkDir = properties.getProperty('ndk.dir')

        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            commandLine "$ndkDir/ndk-build.cmd", '-C', file('src/main/jni').absolutePath
        } else {
            commandLine "$ndkDir/ndk-build", '-C', file('src/main/jni').absolutePath
        }
    }

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn ndkBuild
    }

    task ndkClean(type: Exec, description: 'Clean NDK Binaries') {
        Properties properties = new Properties()
        properties.load(project.rootProject.file('local.properties').newDataInputStream())
        def ndkDir = properties.getProperty('ndk.dir')

        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            commandLine "$ndkDir/ndk-build.cmd", 'clean', '-C', file('src/main/jni').absolutePath
        } else {
            commandLine "$ndkDir/ndk-build", 'clean', '-C', file('src/main/jni').absolutePath
        }
    }

    clean.dependsOn 'ndkClean'
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile project(':stmobile')
    compile project(':rajawali')
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
    testCompile 'junit:junit:4.12'
    compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.3.1'
    compile 'com.github.bumptech.glide:glide:3.8.0'
    compile 'com.android.support:cardview-v7:25.0.0'
    compile 'com.facebook.android:audience-network-sdk:4.+'
    compile project(':library')
}

Error:Execution failed for task ':app:transformNative_libsWithMergeJniLibsForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK lib/armeabi-v7a/libgpuimage-library.so
 File1: C:\Users\DASF\Desktop\\ssss\app\build\intermediates\exploded-aar\jp.co.cyberagent.android.gpuimage\gpuimage-library\1.4.1\jni
 File2: C:\Users\DASF\Desktop\ssssp\app\build\intermediates\exploded-aar\facesnap\library\unspecified\jni

What am I doing wrong and how to fix it ? . thank you support

Xuân Mai
  • 45
  • 1
  • 10

1 Answers1

0

Working solution for me is to add following in top-level build.gradle config:

  allprojects {
repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
 }}