我在运行react-native run-android
命令时遇到问题,这只发生在Android
,在iOS中一切正常(包括使用Facebook登录)。
终端中出现的错误。
> FAILURE: Build failed with an exception. > > * What went wrong: A problem occurred configuring project ':app'. > > Could not resolve all dependencies for configuration ':app:_debugApk'. > > A problem occurred configuring project ':react-native-fbsdk'. > > Could not resolve all dependencies for configuration ':react-native-fbsdk:_debugPublishCopy'. > > Could not find com.android.support:appcompat-v7:27.0.2. > Searched in the following locations: > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar > file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar > Required by: > Vesti:react-native-fbsdk:unspecified > > Could not find com.android.support:appcompat-v7:27.0.2. > Searched in the following locations: > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar > file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar > Required by: > Vesti:react-native-fbsdk:unspecified > com.facebook.react:react-native:0.53.0 > > Could not find com.android.support:support-annotations:27.0.2. > Searched in the following locations: > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.2/support-annotations-27.0.2.pom > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.2/support-annotations-27.0.2.jar > file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/support-annotations/27.0.2/support-annotations-27.0.2.jar > Required by: > Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 > > com.facebook.android:facebook-core:4.31.0 > > Could not find com.android.support:support-core-utils:27.0.2. > Searched in the following locations: > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.2/support-core-utils-27.0.2.pom > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.2/support-core-utils-27.0.2.jar > file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/support-core-utils/27.0.2/support-core-utils-27.0.2.jar > Required by: > Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 > > com.facebook.android:facebook-core:4.31.0 > > Could not find com.android.support:support-v4:27.0.2. > Searched in the following locations: > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-v4/27.0.2/support-v4-27.0.2.pom > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/support-v4/27.0.2/support-v4-27.0.2.jar > file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/support-v4/27.0.2/support-v4-27.0.2.jar > Required by: > Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 > > com.facebook.android:facebook-common:4.31.0 > > Could not find com.android.support:appcompat-v7:27.0.2. > Searched in the following locations: > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar > file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar > Required by: > Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 > > com.facebook.android:facebook-common:4.31.0 > Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 > > com.facebook.android:facebook-login:4.31.0 > > Could not find com.android.support:cardview-v7:27.0.2. > Searched in the following locations: > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.2/cardview-v7-27.0.2.pom > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.2/cardview-v7-27.0.2.jar > file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/cardview-v7/27.0.2/cardview-v7-27.0.2.jar > Required by: > Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 > > com.facebook.android:facebook-common:4.31.0 > > Could not find com.android.support:customtabs:27.0.2. > Searched in the following locations: > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/customtabs/27.0.2/customtabs-27.0.2.pom > file:/usr/local/share/android-sdk/extras/android/m2repository/com/android/support/customtabs/27.0.2/customtabs-27.0.2.jar > file:/Users/rafaelaugusto/Documents/Aplicativos/ReactNative/Vesti/android/sdk-manager/com/android/support/customtabs/27.0.2/customtabs-27.0.2.jar > Required by: > Vesti:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.31.0 > > com.facebook.android:facebook-common:4.31.0
我已经尝试了一些我在互联网上找到的解决方案,到目前为止,我还没有成功,通过Google的研究,我在这里设法解决了iOS
中发生的错误,但我无法做到与Android
答案 0 :(得分:0)
只需更改build.gradle
即可
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
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 {
url "https://maven.google.com"
}
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.28.0'
}
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}