本文介绍了不能使用Facebook帐号工具包:错误充气类com.facebook.accountkit.ui.ConstrainedLinearLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to integrate Facebook AccountKit to allow users to sign-up with their e-mail or phone number. But when launching the AccountKitActivity, the app crash because it can't inflate a "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}

我在我的毕业生中使用: p>

I'm using in my gradle:

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

我打电话给AccountKit.initialize()在尝试启动AccountKitActivity之前。

I'm calling AccountKit.initialize() before trying to launch the AccountKitActivity.

我的简单登录由两个按钮组成:

My simple login activity, made of two buttons:

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;
            }
        }
    }
}

任何人作为一个想法?

推荐答案

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

I ran in to this exact same problem today integrating Account Kit. Their documentation isn't explicit on this, but you need to add the AppLoginTheme to your themes.xml:

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

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

Another possible solution is to remove the theme override for the AccountKitActivity in the manifest like so:

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

这篇关于不能使用Facebook帐号工具包:错误充气类com.facebook.accountkit.ui.ConstrainedLinearLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 22:43