[英]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 repository
( https://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
行到allprojects
节maven.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 : 我有同样的问题,我解决了:
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"
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.
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.1
与27.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.