不能使用Facebook帐户工具包:错误膨胀类com.facebook.accountkit.ui.ConstrainedLinearLayout

我正在尝试整合Facebook AccountKit,允许用户使用他们的电子邮件或电话号码注册。 但是,启动AccountKitActivity时,应用程序崩溃,因为它不能膨胀一个“ConstrainedLayout”。

错误信息 :

java.lang.RuntimeException: Unable to start activity android.view.InflateException: Binary XML file line #45: Error inflating class com.facebook.accountkit.ui.ConstrainedLinearLayout 

和下面:

 Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 12: TypedValue{t=0x3/d=0x512 "res/drawable/scrollbar_handle_material.xml" a=1 r=0x10805cd} 

我在我的gradle中使用:

 compile 'com.facebook.android:facebook-android-sdk:4.11.0' compile 'com.facebook.android:account-kit-sdk:4.11.0' 

在尝试启动AccountKitActivity之前,我调用了AccountKit.initialize()。

我简单的login活动,由两个button组成:

 public class LoginActivity extends Activity implements View.OnClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); Button buttonSMS = (Button) findViewById(R.id.buttonSignInSms); Button buttonEmail = (Button) findViewById(R.id.buttonSignInEmail); buttonSMS.setOnClickListener(this); buttonEmail.setOnClickListener(this); } public static int APP_REQUEST_CODE = 42; public void onLoginPhone(final View view) { final Intent intent = new Intent(this, AccountKitActivity.class); AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder = new AccountKitConfiguration.AccountKitConfigurationBuilder( LoginType.PHONE, AccountKitActivity.ResponseType.CODE); // or .ResponseType.TOKEN // ... perform additional configuration ... intent.putExtra( AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION, configurationBuilder.build()); startActivityForResult(intent, APP_REQUEST_CODE); } public void onLoginEmail(final View view) { final Intent intent = new Intent(this, AccountKitActivity.class); AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder = new AccountKitConfiguration.AccountKitConfigurationBuilder( LoginType.EMAIL, AccountKitActivity.ResponseType.CODE); // or .ResponseType.TOKEN // ... perform additional configuration ... intent.putExtra( AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION, configurationBuilder.build()); startActivityForResult(intent, APP_REQUEST_CODE); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.buttonSignInSms : { onLoginPhone(v); break; } case R.id.buttonSignInEmail : { onLoginEmail(v); break; } } } } 

任何人作为一个想法?

Solutions Collecting From Web of "不能使用Facebook帐户工具包:错误膨胀类com.facebook.accountkit.ui.ConstrainedLinearLayout"

我今天整合了Account Kit,遇到了同样的问题。 他们的文档并不明确,但是你需要将AppLoginTheme添加到你的themes.xml中:

 <style name="AppLoginTheme" parent="Theme.AccountKit" /> 

另一个可能的解决scheme是在清单中移除AccountKitActivity的主题覆盖,如下所示:

 ... <activity android:name="com.facebook.accountkit.ui.AccountKitActivity" /> ... 

我有这个问题。 Zac的解决scheme帮助我解决了这个问题。 以下是我的解决scheme,这可能对别人有帮助。

AndroidManifest.xml中

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.example.screenshot.accountkitclient"> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <meta-data android:name="com.facebook.accountkit.ApplicationName" android:value="@string/app_name" /> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/FACEBOOK_APP_ID" /> <meta-data android:name="com.facebook.accountkit.ClientToken" android:value="@string/ACCOUNT_KIT_CLIENT_TOKEN" /> <activity android:name="com.facebook.accountkit.ui.AccountKitActivity" tools:replace="android:theme" android:theme="@style/AppLoginTheme"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="@string/ak_login_protocol_scheme" /> </intent-filter> </activity> </application> </manifest> 

别忘了在AccountKitActivity中添加工具:replace =“android:theme”

style.xml

 <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="AppLoginTheme" parent="Theme.AccountKit"> <item name="com_accountkit_primary_color">#ef0414</item> <item name="com_accountkit_primary_text_color">@android:color/white</item> <item name="com_accountkit_secondary_text_color">#f10910</item> <item name="com_accountkit_status_bar_color">#e40416</item> <item name="com_accountkit_input_accent_color">?attr/com_accountkit_primary_color</item> <item name="com_accountkit_input_border_color">?attr/com_accountkit_primary_color</item> </style> 

不要做黑客! 只需下载最新的Facebook SDK ,解压缩文件并在文件夹facebook-android-sdk-4.20.0 \ AccountKit中find文件account-kit-sdk-4.20.0.aar 。 将.aar文件的扩展名更改为zip并解压缩此accout-kit-sdk文件。 转到res \ values文件夹,并将values.xml文件复制到您的项目res / values目录中。 瞧!