[英]React Native Android app asking to call deprecated 'FacebookSdk.sdkInitialize'
React-Native v. 0.47.2 react-native-fbsdk v. 0.6.0/0.6.1 React-Native v.0.47.2 react-native-fbsdk v.6.0.0 / 0.6.1
I need to get Facebook login setup for an app. 我需要为应用程序获取Facebook登录设置。 It's been a real struggle on Android.
这在Android上是一场真正的挣扎。 When you install via the Facebook docs ( here then through the quickstart) and run your program this is the first error that pops up:
当你通过Facebook文档安装( 这里通过快速入门)并运行你的程序时,这是弹出的第一个错误:
/Users/Parthenon/Desktop/go3/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
As per this thread I've tried explicitly stating the version in react-native-fbsdk gradle at: 根据这个线程,我尝试在react-native-fbsdk gradle中明确说明版本:
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.facebook.android:facebook-android-sdk:4.22.1'
compile 'com.facebook.android:facebook-android-sdk:4.23.0'
With anything but version 4.22.1
I get the above error. 除了版本
4.22.1
我得到上述错误。 For version 4.22.1
the project builds which is awesome but then it throws the error: 对于版本
4.22.1
,项目构建很棒,但然后它会抛出错误:
The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
This is really strange because FacebookSdk.sdkInitialize()
was deprecated well before 4.22
. 这真的很奇怪,因为
FacebookSdk.sdkInitialize()
在4.22
之前就被弃用了。 If I call that method the app runs then crashes. 如果我调用该方法应用程序运行然后崩溃。 But it crashes with no error log.
但它没有错误日志崩溃。
What's going on here or what should I try next? 这里发生了什么或接下来应该尝试什么?
I have the same issue and I realize that I have to complete all steps to configure the native facebook sdk for android. 我有同样的问题,我意识到我必须完成所有步骤来配置Android的原生facebook sdk。 Its mean you need to have a facebook account for this work.
这意味着你需要有一个facebook帐户来完成这项工作。 What you need to do next is:
你接下来要做的是:
In your project open yourapp/android/build.gradle
在你的项目中打开
yourapp/android/build.gradle
Add the Maven Central Repository to build.gradle before dependencies: 在依赖项之前将Maven Central Repository添加到build.gradle:
repositories { mavenCentral() }
Add compile 'com.facebook.android:facebook-android-sdk:[4,5)'
to your build.gradle
dependencies 将
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
添加到build.gradle
依赖项中
Build project 建立项目
Open your strings.xml file, for example: /app/src/main/res/values/strings.xml.
打开strings.xml文件,例如:
/app/src/main/res/values/strings.xml.
and add <string name="facebook_app_id">xxxxxxxx</string>
并添加
<string name="facebook_app_id">xxxxxxxx</string>
Open your AndroidManifest.xml and add <uses-permission android:name="android.permission.INTERNET"/>
打开AndroidManifest.xml并添加
<uses-permission android:name="android.permission.INTERNET"/>
Add meta to application element <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
添加meta到应用程序元素
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
Generate a development key hash 生成开发密钥哈希
You can see detail in quick start of developer facebook page (developers.facebook.com/quickstarts/) 您可以在开发者Facebook页面的快速入门中看到详细信息(developers.facebook.com/quickstarts/)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.