grit96
grit96

Reputation: 62

Building a react native module that uses an Android AAR library

I'm trying to build a wrapper of liblinphone for React Native (react-native-liblinphone). I'm starting with the Android implementation and I'm using the .aar file of the SDK provided by linphone.

The React Native module builds successfully on it's own, but when it is linked into the RN app (using react native link) the app build fails to find the SDK (Failed to resolve: :liblinphone-sdk:).

From the react-native-liblinphone build.gradle:

repositories {
    mavenCentral()
    flatDir { dirs 'libs' }
}

dependencies {
    compile 'com.facebook.react:react-native:+'
    compile(name: 'liblinphone-sdk', ext: 'aar')
}

From the app settings.gradle:

include ':react-native-liblinphone'
project(':react-native-liblinphone').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-liblinphone/android')
include ':react-native-contacts'
project(':react-native-contacts').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-contacts/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')

include ':app'

From the app build.gradle:

dependencies {
    compile project(':react-native-liblinphone')
    compile project(':react-native-contacts')
    compile project(':react-native-vector-icons')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

Upvotes: 3

Views: 2677

Answers (1)

zeeali
zeeali

Reputation: 1604

No need to change app's gradle or settings.gradle, just make following change to your native module's gradle:

repositories {
    mavenCentral()
    flatDir { dirs "$rootDir/../node_modules/react-native-liblinphone/android/libs" }
}

Hope it helps!

Upvotes: 0

Related Questions