【发布时间】:2018-05-20 07:00:05
【问题描述】:
我正在使用 react native 0.49.5 和 react 16.0.0-beta.5 来制作应用程序。
我正在使用 react native-fbsdk(^0.6.3) 进行 Facebook 登录。已采取所有必要步骤将 android 与 facebook sdk 链接。
但是当我运行react-native run-android 时,它抛出了一个错误。
CLI(终端)中的错误日志:
/home/sunny/projects/ReactNativeApp/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15:21-54: AAPT:找不到与给定名称匹配的资源:attr 'android:keyboardNavigationCluster'。
/home/sunny/projects/ReactNativeApp/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15:错误:错误:没有资源找到与给定名称匹配的:attr 'android:keyboardNavigationCluster'。
:react-native-fbsdk:processReleaseResources 失败
FAILURE:构建失败并出现异常。
出了什么问题: 任务“:react-native-fbsdk:processReleaseResources”执行失败。 com.android.ide.common.process.ProcessException: 无法执行 aapt
尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。
构建失败
总时间:4.015 秒 无法在设备上安装应用程序,请阅读上面的错误以了解详细信息。 确保您有一个正在运行的 Android 模拟器或连接的设备,并且有 设置您的 Android 开发环境: https://facebook.github.io/react-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'
}
我该如何解决这个问题?有什么帮助吗?
【问题讨论】:
标签: android reactjs react-native react-native-fbsdk