So, I am trying to compile a react-native android app with two AARs - one of them being the react-native implementation.
I have included the additional anyline sdk through maven in the build.gradles and the gradle syncs fine.
I get the following error and could not resolve this issue. Any hints from react-native Android experienced?
:app:packageDebug
Error: duplicate files during packaging of APK /Users/chris/dev/Enffi/mobile/android/app/build/outputs/apk/app-debug-unaligned.apk
Path in archive: lib/x86/libgnustl_shared.so
Origin 1: /Users/chris/dev/Enffi/mobile/android/app/build/intermediates/exploded-aar/com.facebook.react/react-native/0.20.1/jni/x86/libgnustl_shared.so
Origin 2: /Users/chris/dev/Enffi/mobile/android/app/build/intermediates/exploded-aar/io.anyline/anylinesdk/3.4.0/jni/x86/libgnustl_shared.so
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'lib/x86/libgnustl_shared.so'
}
}
:app:packageDebug FAILED
My build.gradle looks like this:
apply plugin: "com.android.application"
import com.android.build.OutputFile
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.enffi_mobile"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
enable enableSeparateBuildPerCPUArchitecture
universalApk false
reset()
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile project(':Anyline')
compile 'io.anyline:anylinesdk:3.4.0@aar'
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:0.20.+"
}
The build.gradle of the anyline module looks like this - i.e. it should exclude this file. However, this is not working.
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
packagingOptions {
exclude 'lib/armeabi-v7a/libgnustl_shared.so'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
}
repositories {
maven { url 'https://anylinesdk.blob.core.windows.net/maven/'}
}
dependencies {
compile 'com.facebook.react:react-native:0.20.1'
compile 'io.anyline:anylinesdk:3.4.0@aar'
}
Many thanks!