React Native-FBSDK未知问题



我正在使用React Native 0.49.5,React 16.0.0-Beta.5用于制作应用程序。
我正在为Facebook登录使用React Antive-FBSDK(^0.6.3)。采取所有必要的步骤将Android与Facebook SDK链接。
但是当我运行react-native run-android时,它会丢下错误。

CLI中的错误日志(终端):

没有发现与给定名称匹配的资源:attr" android:keyboardNavigationCluster"。

/home/sunny/projects/reactnativeapp/node_modules/react-native-fbsdk/android/build/build/intermediates/res/res/mered/mered/release/values-values-values-values-v26/values-v26/values-v26.xml:15:errial:发现与给定名称匹配:attr" android:keyboardNavigationCluster"。

:react-native-fbsdk:ProcessReleasEresources失败

失败:构建失败而异常。

  • 出了什么问题: 执行失败的任务':react-native-native-fbsdk:processRelealeSources'。 com.android.ide.common.process.processexception:无法执行AAPT

  • 尝试: 使用-StackTrace选项运行以获取堆栈跟踪。使用-Info或-debug选项运行以获取更多日志输出。

构建失败

总时间:4.015秒 无法在设备上安装应用程序,请阅读上面的错误以获取详细信息。 确保您有一个Android模拟器运行或连接的设备并具有 设置您的Android开发环境: https://facebook.github.io/reaeact-native/docs/android-setup.html

这是我的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'
        }
    }
}

这是我的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'
}

我该如何解决这个问题?对此有任何帮助吗?

似乎您的问题是由新版本Facebook-SDK-4.29.0引起的,您需要将此依赖性限制在4.28.0版本中。最佳解决方案是添加到您的{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("********************************************************")
      }
    }
  }
}

转到Android级别构建Gradle并添加/更新此行。

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

}

这解决了我的问题。

我一直在寻找解决方案数小时,最后用此帖子修复了

您必须转到node-modules/react-native-fbsdk/android,然后将 compilesdkVersion更改为26, buildToolVersion to 26.0.1, targetsdkVersion至26,最后com.android.support:appcompat-v7:26.+

而 @eclipticwld的答案显然有效,这有点令人费解。添加一个force实际上就足够了;

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

从重复问题借来的答案

相关内容

  • 没有找到相关文章

最新更新