简体   繁体   English

react-native-fb sdk com.android.support依赖性错误

[英]react-native-fb sdk com.android.support dependency error

 > 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:/<location_to_sdk>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom
           file:/<location_to_sdk>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
           file:/<location_to_app>/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
       Required by:
           newPtMobile:react-native-fbsdk:unspecified

This issue started happening this morning when running react-native run-android without making any changes to the code or adding new packages, it was working fine untill now! 这个问题今天早上在运行react-native run-android而没有对代码进行任何更改或添加新软件包时开始发生,它现在工作正常!

"react-native":"0.50.3", "react-native-fbsdk":"0.6.3" “react-native”:“0.50.3”,“react-native-fbsdk”:“0.6.3”

I can see that I am missing android support libraries in my sdk/extras/android/m2repository/com/android/support subfolders, all the subfolders have the 26.0.0-alpha1 folder as the last one. 我可以看到我在我的sdk/extras/android/m2repository/com/android/support子文件夹中缺少android support libraries ,所有子文件夹都将26.0.0-alpha1文件夹作为最后一个。 I already tried removing support repository and installing again through android studio and downloading the latest android_m2repository manually but the folders are still missing. 我已经尝试删除支持存储库并通过android studio再次安装并手动下载最新的android_m2repository但文件夹仍然缺失。

What I am having trouble understanding is why google's maven repository ( https://dl.google.com/dl/android/maven2/index.html ) states that under for example m2repository/com/android/support/appcompat-v7 I should have a folder named 27.0.2 (along with some previous versions which are also missing) but even in the latest android_m2repository which they offer it is also missing! 什么我无法理解就是为什么google's maven repositoryhttps://dl.google.com/dl/android/maven2/index.html )指出,在例如 m2repository/com/android/support/appcompat-v7我应该有一个名为27.0.2的文件夹(以及一些以前的版本也缺少),但即使在他们提供的最新的android_m2存储库中也缺少它!

https://dl.google.com/android/repository/android_m2repository_r48.zip https://dl.google.com/android/repository/android_m2repository_r48.zip

I also have the same issue. 我也有同样的问题。 I was able to successfully build by updating my 我能够通过更新我的成功建立
ROOT : android/build.gradle file. ROOT: android/build.gradle文件。

STEPS : 脚步 :
1. All you have to do is add a new maven line to the allprojects section for maven.google.com 1.所有你需要做的就是新添加maven行到allprojectsmaven.google.com
2. Add resolutionStrategy Will Restrict your android fbsdk version to 4.28.0 2.添加resolutionStrategy会将你的android fbsdk版本限制为4.28.0

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        configurations.all {
        resolutionStrategy {
            force 'com.facebook.android:facebook-android-sdk:4.28.0'
        }
    }
        maven {
            url "https://maven.google.com"
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
      }
  }

I see that another thread was open on this very same issue: getting error when run react-native run-android 我看到另一个线程在这个同样的问题上打开了: 运行react-native run-android时出错

The solution recommended there is close to Sutani one, that is editing node_modules/react-native-fbsdk/android/build.gradle and adding 推荐的解决方案接近Sutani一个,即编辑node_modules/react-native-fbsdk/android/build.gradle并添加

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

It seems not to be a regression introduced by react-native-fbsdk but by Google Android libraries but I am not 100% clear about it. 它似乎不是由react-native-fbsdk引入的回归,而是谷歌Android库,但我并不是100%清楚它。

i have same problem, and i solved with : 我有同样的问题,我解决了:

  1. edit package.json and i am edit react-native-fbsdk from react-native-fbsdk": "0.6.3" to react-native-fbsdk": "0.6.0" 编辑package.json ,我从react-native-fbsdk": "0.6.3"编辑react-native-fbsdk react-native-fbsdk": "0.6.3"react-native-fbsdk": "0.6.0"

  2. go to your node_modules/react-native-fbsdk/android/build.gradle . 转到你的node_modules/react-native-fbsdk/android/build.gradle open build.gradle file. 打开build.gradle file.

  3. Change compile('com.facebook.android:facebook-android-sdk:4++') to compile('com.facebook.android:facebook-android-sdk:4.22.1') , 更改compile('com.facebook.android:facebook-android-sdk:4++')进行compile('com.facebook.android:facebook-android-sdk:4.22.1')

but I don't know if this is the best way for this problem, thank you 但是我不知道这是否是解决这个问题的最好办法,谢谢

CUR_SPACE=.
culpritLocation=$CUR_SPACE/node_modules/react-native-fbsdk/android/build.gradle

sed -i -e 's/com.facebook.android:facebook-android-sdk:4.+/com.facebook.android:facebook-android-sdk:4.26.0/' $culpritLocation

printf "Fixed Could not resolve all dependencies for configuration ':react-native-fbsdk:_debugPublishCopy'.\n> Could not find com.android.support:appcompat-v7:27.0.1."
printf "fix_rn_fbsdk_google_libraries.sh should be removed at a later time\n"

Place the above script in the root of your react-native project, add executing permissions to it, then in package.json within the postinstall property add ./your-script-name.sh; 将上面的脚本放在react-native项目的根目录中,为其添加执行权限,然后在postinstall属性中的package.json中添加./your-script-name.sh; . Ex: 例如:

{
  "name": "AppName",
  "version": "1.28.14",
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "postinstall": "./fix_rn_fbsdk_google_libraries.sh; ./infuse_version.sh;"
  },
  [..]
}

If you're not familiar with postinstall scripts, they'll run immediately after running npm install / yarn command. 如果您不熟悉postinstall脚本,它们将在运行npm install / yarn命令后立即运行。

The proposed solution works with cloud build tools :) and it is only temporary. 建议的解决方案适用于云构建工具:)并且它只是暂时的。 Future rn-fbsdk releases should fix the issue. 未来的rn-fbsdk版本应该解决这个问题。

The key is in the error message shown in your case: 密钥在您的案例中显示的错误消息中:

Searched in the following locations: file:/<location_to_sdk>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/ 在以下位置搜索: file:/<location_to_sdk>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/

I have had the same. 我有同样的。 Then I went to the location: 然后我去了位置:

file:<location_to_sdk>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/

And found that there is no directory named 27.0.1 because in my case the latest buildTool was not downloaded. 并且发现没有名为27.0.1目录,因为在我的情况下没有下载最新的buildTool。 In my case I have had 27.0.0-alpha1 . 在我的情况下,我有27.0.0-alpha1

So in both of my app build.gradle and in 所以在我的app build.gradle和in中

node_modules/react-native-fbsdk/android/build.gradle node_modules /反应天然-fbsdk /机器人/的build.gradle

I replaced 27.0.1 with 27.0.0-alpha1 and build was successful. 我换成27.0.127.0.0-alpha1和构建成功。

build.gradle --- app build.gradle --- app

dependencies {
    compile 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
    compile('com.facebook.android:facebook-android-sdk:4.+')
}

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


Solution:

How to fix the file permissions, after loading end react-native start

First, Go to android folder

cd android

Now clean the project...

gradlew clean //for Mac users, change gradlew to ./gradlew

Now run the build process again in the root folder 
cd ..
react-native run-android

Solved Issue Happy Coding!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:与项目中的依赖项“com.android.support:multidex”冲突 - Error: Conflict with dependency 'com.android.support:multidex' in project 将Connect SDK添加到Gradle文件时与依赖项&#39;com.android.support::support-v4&#39;发生冲突 - Conflict with dependency 'com.android.support::support-v4' when adding Connect SDK to gradle file react-native运行Android构建错误-无法解决:com.android.support:appcompat-v7:26.0.2 - react-native run-android build error - Failed to resolve: com.android.support:appcompat-v7:26.0.2 警告:与依赖项“com.android.support:support-annotations”冲突 - Warning:Conflict with dependency 'com.android.support:support-annotations' Maven:com.android.support:support-annotations:28.0.0的依赖项收敛错误 - Maven: Dependency convergence error for com.android.support:support-annotations:28.0.0 与项目中的依赖项“ com.android.support:support-annotations”冲突 - Conflict with dependency 'com.android.support:support-annotations' in project 与依赖项&#39;com.android.support:support-v4&#39;冲突 - Conflict with dependency 'com.android.support:support-v4' React Native - 无法解析com.android.support:support-compat:26.1.0 - React Native - Could not resolve com.android.support:support-compat:26.1.0 与依赖项&#39;com.android.support:support-annotations&#39;冲突 - Conflict with dependency 'com.android.support:support-annotations' com.android.support:appcompat抛出错误 - com.android.support:appcompat throwing error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM