将Project迁移到AndroidX后,com.paymob.acceptsdk.PayActivity崩溃androidx.appcompat.app.ActionBar无效

时间:2019-10-03 13:20:16

标签: android android-actionbar androidx

将项目迁移到AndroidX之后,我便崩溃了

 Unable to start activity ComponentInfo{oackagename/com.paymob.acceptsdk.PayActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.appcompat.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.appcompat.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference

PayActivity是付款门SDK中的活动,我无法更改其代码。

我如何进行活动:

Intent pay_intent = new Intent(this, PayActivity.class);

putNormalExtras(pay_intent);
pay_intent.putExtra(PayActivityIntentKeys.SAVE_CARD_DEFAULT, true);
pay_intent.putExtra(PayActivityIntentKeys.SHOW_ALERTS, showSaveCard);
pay_intent.putExtra(PayActivityIntentKeys.SHOW_SAVE_CARD, showSaveCard);
pay_intent.putExtra(PayActivityIntentKeys.THEME_COLOR, 0x8033B5E5);

startActivityForResult(pay_intent, ACCEPT_PAYMENT_REQUEST);

更新: 库链接:

implementation 'com.paymob:acceptsdk:1.0.6'
implementation 'net.authorize:accept-sdk-android:1.0.2'

1 个答案:

答案 0 :(得分:0)

将此添加到您的Manifest文件

 <activity android:name="com.paymob.acceptsdk.PayActivity"
            android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar"/>