Reputation: 1270
I have a react-native app and I'm trying to import the FB Android SDK and FB Audience Network SDK with the mediation adapter.
When I add these dependencies in my app/build.gradle, I get the following errors during build.
compile 'com.facebook.android:facebook-android-sdk:4.22.1'
compile 'com.facebook.android:audience-network-sdk:4.26.1'
compile 'com.google.ads.mediation:facebook:4.26.1.0'
Errors:
C:\ig3\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
C:\ig3\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
C:\ig3\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
C:\ig3\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
The only way I could get my project to compile was to do this in android/build.gradle:
allprojects {
....
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
details.useVersion "0.49.5" // Your real React Native version here
}
}
force 'com.facebook.android:facebook-android-sdk:4.22.1' <---Add this line
force 'com.facebook.android:audience-network-sdk:4.26.1' <---Add this line
}
}
}
And comment out these two lines in android/app/build.gradle:
//compile 'com.facebook.android:facebook-android-sdk:4.22.1'
//compile 'com.facebook.android:audience-network-sdk:4.26.1'
compile 'com.google.ads.mediation:facebook:4.26.1.0'
If I try any other version of FB Android SDK in android/build.gradle I get the same errors mentioned earlier. After some research, I tried changing the com.android.support:appcompat version but it will always give the same error as above if I do not use 23.
Is this an acceptable way to include these dependencies? It feels like a hack, I don't know why I could not just include the sdks in android/app/build.gradle, and I don't want to be stuck on FB android sdk version 4.22.1 forever.
Also, after testing it does not seem like ad mediation is working from Admob for Facebook Audience Network but I am unsure if it is due to the way I import the sdk like above or an unrelated issue.
If anybody can show me how to correctly include the sdks I would appreciate it. Thanks!
EDIT: Full android/build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
details.useVersion "0.49.5" // Your real React Native version here
}
}
force 'com.facebook.android:facebook-android-sdk:4.22.1'
force 'com.facebook.android:audience-network-sdk:4.26.1'
}
}
}
And full android/app/build.gradle:
android {
compileSdkVersion 23
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 50
versionName "1.11.11"
ndk {
abiFilters "armeabi-v7a", "x86"
}
multiDexEnabled true
}
dexOptions {
jumboMode = true
javaMaxHeapSize "4g"
}
signingConfigs {
release {
....
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// 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
}
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.android.support:appcompat-v7:23+'
compile project(':react-native-fetch-blob')
compile 'com.android.support:multidex:1.0.1'
compile project(':react-native-billing')
compile project(':bugsnag-react-native')
compile project(':react-native-admob')
compile fileTree(dir: "libs", include: ["*.jar"])
compile project(':react-native-fbsdk')
compile project(':react-native-code-push')
compile project(':react-native-device-info')
compile project(':react-native-config')
compile project(':react-native-fast-image')
compile project(':react-native-camera')
compile project(':react-native-google-analytics-bridge')
compile project(':react-native-vector-icons')
compile(project(":react-native-google-signin")) {
exclude group: "com.google.android.gms" // very important
}
compile 'com.google.android.gms:play-services-auth:11.6.0'
compile 'com.google.firebase:firebase-appindexing:11.6.0'
compile 'com.facebook.android:facebook-android-sdk:4.22.1'
compile 'com.facebook.android:audience-network-sdk:4.26.1'
compile 'com.google.ads.mediation:facebook:4.26.1.0'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
Upvotes: 1
Views: 1607
Reputation: 1270
My solution was to update all these:
gradle to 3.01
gradle wrapper to 4.1
compilesdkversion to 26
buildtoolsversion to 26.02
com.android.support:appcompat-v7 to 26+
com.facebook.android:facebook-android-sdk:4.28.0
and my app builds successfully
Upvotes: 0