> 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
这个问题今天早上在运行react-native run-android而没有对代码进行任何更改或添加新软件包时开始发生,它现在工作正常,直到现在!
“react-native”:“0.50.3”,“react-native-fbsdk”:“0.6.3”
我可以看到我在android support libraries
子文件夹中缺少sdk/extras/android/m2repository/com/android/support
,所有子文件夹都将26.0.0-alpha1
文件夹作为最后一个文件夹。
我已经尝试删除支持存储库并通过android studio再次安装并手动下载最新的android_m2repository
但文件夹仍然缺失。
我无法理解的原因是google's maven repository
(https://dl.google.com/dl/android/maven2/index.html)说明下 m2repository/com/android/support/appcompat-v7
的原因我应该有一个名为{{1}的文件夹(以及一些以前的版本也缺少),但即使在他们提供的最新android_m2存储库中也缺少它!
https://dl.google.com/android/repository/android_m2repository_r48.zip
答案 0 :(得分:16)
我也有同样的问题。我能够通过更新我的成功建立
ROOT: android/build.gradle
文件。
步骤:
1.您只需要在maven
部分添加新的allprojects
行maven.google.com
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"
}
}
}
答案 1 :(得分:6)
我看到另一个主题在同一个问题上打开了:getting error when run react-native run-android
推荐的解决方案接近Sutani,即编辑node_modules/react-native-fbsdk/android/build.gradle
并添加
compile('com.facebook.android:facebook-android-sdk:4.28.0')
似乎不是由react-native-fbsdk引入的回归,而是Google Android库引入的回归,但我并不是100%清楚它。
答案 2 :(得分:0)
我有同样的问题,我解决了:
修改package.json
,我从react-native-fbsdk
修改react-native-fbsdk": "0.6.3"
到react-native-fbsdk": "0.6.0"
转到node_modules/react-native-fbsdk/android/build.gradle
。打开build.gradle file.
将compile('com.facebook.android:facebook-android-sdk:4++')
更改为compile('com.facebook.android:facebook-android-sdk:4.22.1')
,
但我不知道这是否是解决此问题的最佳方法, 谢谢
答案 3 :(得分:0)
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"
将上述脚本放在您的react-native项目的根目录中,为其添加执行权限,然后在 postinstall 属性中的package.json中添加 ./ your-script-name .SH; 。例如:
{
"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;"
},
[..]
}
如果您不熟悉postinstall脚本,他们会在运行npm install / yarn命令后立即运行。
建议的解决方案适用于云构建工具:)并且它只是暂时的。未来的rn-fbsdk版本应解决这个问题。
答案 4 :(得分:0)
密钥位于您的案例中显示的错误消息中:
在以下位置搜索:
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
的目录,因为在我的情况下,没有下载最新的buildTool。在我的情况下,我有27.0.0-alpha1
。
因此,在我的应用build.gradle
和
node_modules /反应天然-fbsdk /机器人/的build.gradle
我将27.0.1
替换为27.0.0-alpha1
,构建成功。
答案 5 :(得分:0)
build.gradle ---应用
private class ViewHolder {
public TextView userName;
public View likeButtonLayout;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
final Context context = parent.getContext();
if (convertView == null) {
convertView =
LayoutInflater.from(context).inflate(R.layout.panel_talk_topic, parent, false);
holder = new ViewHolder();
holder.userName = convertView.findViewById(R.id.user_name);
holder.likeButtonLayout = convertView.findViewById(R.id.like_button_layout);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
ImageView likeButtonImage =
holder.likeButtonLayout.findViewById(R.id.like_button_imageView);
TextView likeCountText = holder.likeButtonLayout.findViewById(R.id.like_count_textView);
.
.
.