Error SDK Facebook

1

I am working on android studio, modifying a file of an app that was done in react-native, however when wanting to import facebook sdk I get an error:

How can I solve it?

this is the code of that part:

apply plugin: "com.android.application"

import com.android.build.OutputFile
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;


project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false


def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 26


    defaultConfig {
        applicationId "com.platzi2"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    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"
        }
    }
    // 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 {
    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.facebook.react:react-native:+'


    // From node_modules
}

// 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'
}
    
asked by Revsky01 29.03.2018 в 19:03
source

1 answer

-1

The build.gradle of classes should not be added within the import file , the dependencies should be added, for example:

dependencies {
    ...
    ...
    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
}

Delete these lines within your build.gradle file:

import com.android.build.OutputFile
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;

the import of the classes must be added within the classes where necessary.

    
answered by 29.03.2018 / 19:31
source