Getting error when run react-native run-android

匿名 (未验证) 提交于 2019-12-03 01:27:01

问题:

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.1.            Searched in the following locations:              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar              file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar            Required by:              beostore:react-native-fbsdk:unspecified          > Could not find com.android.support:appcompat-v7:27.0.1.            Searched in the following locations:              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar              file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar            Required by:              beostore:react-native-fbsdk:unspecified > com.facebook.react:react-native:0.46.4          > Could not find com.android.support:support-annotations:27.0.1.            Searched in the following locations:              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.pom              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.jar              file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/support-annotations/27.0.1/support-annotations-27.0.1.jar            Required by:              beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-core:4.29.0          > Could not find com.android.support:support-core-utils:27.0.1.            Searched in the following locations:              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.pom              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.jar              file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/support-core-utils/27.0.1/support-core-utils-27.0.1.jar            Required by:              beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-core:4.29.0          > Could not find com.android.support:appcompat-v7:27.0.1.            Searched in the following locations:              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar              file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar            Required by:              beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0          > Could not find com.android.support:cardview-v7:27.0.1.            Searched in the following locations:              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.pom              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.jar              file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/cardview-v7/27.0.1/cardview-v7-27.0.1.jar            Required by:              beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0          > Could not find com.android.support:customtabs:27.0.1.            Searched in the following locations:              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/customtabs/27.0.1/customtabs-27.0.1.pom              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/customtabs/27.0.1/customtabs-27.0.1.jar              file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/customtabs/27.0.1/customtabs-27.0.1.jar            Required by:              beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0          > Could not find com.android.support:support-v4:27.0.1.            Searched in the following locations:              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-v4/27.0.1/support-v4-27.0.1.pom              file:/home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support/support-v4/27.0.1/support-v4-27.0.1.jar              file:/home/ubuntu/git/mstore-pro/android/sdk-manager/com/android/support/support-v4/27.0.1/support-v4-27.0.1.jar            Required by:              beostore:react-native-fbsdk:unspecified > com.facebook.android:facebook-android-sdk:4.29.0 > com.facebook.android:facebook-common:4.29.0

compileSdkVersion 25

buildToolsVersion "25.0.0"

targetSdkVersion 25

回答1:

I've faced the same issue today.

Looks like there is some problem with react-native-fbsdk package;

I've found the only way to solve it for now:

at node_modules/react-native-fbsdk/android/build.gradle

change compile('com.facebook.android:facebook-android-sdk:4+')

to compile('com.facebook.android:facebook-android-sdk:4.26.0')

This is very bad solution.

If you will find proper way to solve it - please share.



回答2:

The accepted answer does the trick but a cleaner solution would be to restrict the android fbsdk version used in the react native fbsdk library. Adding the below code to project(root) build.gradle made sure that the specified version of fbsdk is used by all library projects.

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


回答3:

I have the same issue since this morning and as far as I can see it is a problem with the react-native-fbsdk library and android support repository.

If you go into any of the subfolders on the path where your sdk is installed (in your case) "home/ubuntu/Android/Sdk/extras/android/m2repository/com/android/support" you will probably see the "26.0.0-alpha1" as the last folder even though google (https://dl.google.com/dl/android/maven2/index.html - collapse com.android.support) clearly suggests the last folder should be "27.0.2"!

I have tried downloading the latest android_m2repository from the acquired link: https://dl.google.com/android/repository/android_m2repository_r47.zip but it is also missing all the following folders: 26.0.0-beta1, 26.0.0-beta2, 26.0.0, 26.0.1, 26.0.2, 26.1.0, 27.0.0, 27.0.1, 27.0.2

I managed to remove the error by editing node_modules/react-native-fbsdk/android/build.gradle

compile('com.facebook.android:facebook-android-sdk:4.28.0')

but am still not able to build and I am sure this is not the propper way to go even if you are able to build!



回答4:

Follow these Steps and Make your Build Successful

  1. Go to Project build.gradle file adding maven {url"https://maven.google.com"} Will download the missing items .

  2. android/build.gradle file and restrict fbsdk Version to 4.28.0.

OTHER WAY

Go to node_modules/react-native-fbsdk : build.gradle change to compileSdkVersion 26 or 27

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


回答5:

Updating Android studio solved this for me...

Below are the steps I followed

  • Updated android-sdk(downloaded platform and build tools for version 27 and other auto suggests)
  • Updated Android Studio
  • Synced the dependency projects
  • Android Studio automatically asked for updating gradle
  • Running react-native run-android auto downloaded dependencies from gradle-4.1-all.zip which was auto added into my "gradle-wrapper.properties" file because of gradle update from the above step


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!