React native-fbsdk unknown issue?
Asked Answered
K

4

6

I am using react native 0.49.5 and react 16.0.0-beta.5 for making an App.
I am using react native-fbsdk(^0.6.3) for facebook login. All necessary steps are taken to link android with the facebook sdk.
But When I ran react-native run-android, It threw an error.

Error log in CLI(TERMINAL):

/home/sunny/projects/ReactNativeApp/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

/home/sunny/projects/ReactNativeApp/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

:react-native-fbsdk:processReleaseResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':react-native-fbsdk:processReleaseResources'. com.android.ide.common.process.ProcessException: Failed to execute aapt

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.015 secs Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/android-setup.html

Here is my android/build.gradle

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

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

And here is my android/app/build.gradle

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    dexOptions {
        jumboMode true
    }
    defaultConfig {
        applicationId "com.reactnativeapp"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    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
            }
        }
    }
}

dependencies {
    compile project(':react-native-image-crop-picker')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-camera-kit')
    compile(project(':react-native-fbsdk')){
      exclude(group: 'com.facebook.android', module: 'facebook-android-sdk')
    }
    compile 'com.facebook.android:facebook-android-sdk:4.22.1'
    compile project(':react-native-maps')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile project(':react-native-linear-gradient')
}

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

How can I solve this issue? Any help on this?

Kauppi answered 6/12, 2017 at 11:48 Comment(1)
Possible duplicate of getting error when run react-native run-androidFinding
B
7

Seems like your issue was caused by new release facebook-sdk-4.29.0 You need to limit this dependency by 4.28.0 version. The optimal solution would be to add to your {project_root}/android/build.gradle

def versionOverrides = [
  "com.facebook.android:facebook-android-sdk": "4.28.0",
]

allprojects {
  /* your original repository dependencies here... */
  configurations.all {

    resolutionStrategy.eachDependency { DependencyResolveDetails details ->

      def overrideVersion = versionOverrides[details.requested.group + ":" + details.requested.name]

      if (overrideVersion != null && details.requested.version != overrideVersion) {
        println("********************************************************")
        println("Overriding dependency ${details.requested.group}:${details.requested.name} version ${details.requested.version} --> $overrideVersion")
        details.useVersion overrideVersion
        println("********************************************************")
      }
    }
  }
}
Buzzell answered 7/12, 2017 at 4:44 Comment(14)
EclipticWld Need help where to add this line plz tell me here is my {project_root}/android/build.gradle pastebin.com/Urr2QAvDKauppi
@Sunnynegi put def versionOverrides variable in root of android/build.gradle and configurations.all into allprojectsBuzzell
Like this pastebin.com/eHKSrRF4, After react-native run-android build is failledKauppi
It should be 4.28, not 0.28. Thanks, btw, worked for me with the correct version number.Chambless
@EclipticWld Thank you so much it's works but will yo plz explain why i am facing this issue (real cause).Kauppi
@Sunnynegi someone didn't set strict version of facebook-android-sdk in react-native-fbsdk library and when a new release comes it has new android api. ps. you could also set my answer as accepted :)Buzzell
Same issue for android :( . And following your answer doesnt helpTillage
This fixed my issue. But if I understand correctly, even if having a fixed react-native-fbsdk version won't help, no? Since right now, I have mine as ^0.6.3.Hinda
@Hinda I'm not sure when react-native-fbsdk team will fix it. Last time I was waiting for 3 weeks a new patch. They also have a complex approach to new updates and managing issues. Your version is fine with the current hot patch.Buzzell
@Tillage seems like you're doing something wrong. Probably mistyped.Buzzell
@EclipticWld Nope, but then i got it working by updating the build tools to 27Tillage
@Tillage interesting but I doubt is it correct solution based on the particular issue.Buzzell
@EclipticWld For android, its best to use the latest build tools, and i had no restriction to work with a specific build tools version, so works for me!Tillage
Making this generic for a single override seems overkill. Just adding configurations.all { resolutionStrategy { force 'com.facebook.android:facebook-android-sdk:4.28.0' } } should be enough.Finding
I
5

Go to android level build gradle and add/update this line.

subprojects {
   afterEvaluate {project ->
       if (project.hasProperty("android")) {
        android {
            compileSdkVersion 25
            buildToolsVersion '25.0.0'
        } 
       }
   }
}

to

subprojects {
afterEvaluate {project ->
    if (project.hasProperty("android")) {
        android {
            compileSdkVersion 26
            buildToolsVersion '26.0.1'
        }
    }
}

}

this solve my problem.

Intergrade answered 6/12, 2017 at 13:30 Comment(7)
Suryakant Need help over this issue, plz tell me where to add this line, because i have no subprojects in my android level buildKauppi
@Sunnynegi there wont be any you have to add it.Intergrade
then what i have to do with your code, Plz enlighten meKauppi
Will this affect support for older versions of Android? There are multiple *SdkVersion properties, I'm not sure what does what.Chambless
@Sunnynegi All you have to do is go to android gradle and add this line subprojects { afterEvaluate {project -> if (project.hasProperty("android")) { android { compileSdkVersion 26 buildToolsVersion '26.0.1' } } } } at bottom.Intergrade
@AlexeyUkolov this might affect the older version of android... as there is regularly update on Android. so cant comment will if affect or not.Intergrade
@Sunnynegi you might also have to add these lines maven { url "maven.google.com" name 'Google' } in project Gradle file in allproject{ repositories{...Intergrade
B
2

I have been searching for the solution for hours and finally fixed it with this post

You have to go to node-modules/react-native-fbsdk/android and changes compilesdkVersion to 26, buildToolVersion to 26.0.1, targetsdkVersion to 26 and finally com.android.support:appcompat-v7:26.+

Blanka answered 6/12, 2017 at 13:19 Comment(1)
I tried you solution and it's working fine for me, but i have doubt that it is right to update the node-modules/react-native-fbsdk/android.Kauppi
F
0

While @EclipticWld's answer apparently works, it's a bit convoluted. Adding a single force is actually enough;

allprojects {
    repositories {
        ....
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.28.0'
            }
        }
    }
}

Answer borrowed from a duplicate question

Finding answered 14/12, 2017 at 11:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.