1

我已经被这个问题困扰了多少天了。基本上,SDK现在可以生成 Token,但是当程序转到registerCallback()方法时,我的应用程序崩溃了,说它需要Theme.AppCompatActivity.

我已经设置了Activity我正在使用的AppCompatActivity(并应用AppCompat主题),但它不起作用。我也将整个清单的AppCompat主题设置为主题,但它仍然不起作用。

这是日志:

05-24 18:47:23.636 21619-21619/com.app.turnstonepizza E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.turnstonepizza, PID: 21619
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.turnstonepizza/com.payfort.fort.android.sdk.activities.InitSecureConnectionActivity}:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
 Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:359)
    at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:328)
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
    at com.payfort.fort.android.sdk.activities.InitSecureConnectionActivity.onCreate(InitSecureConnectionActivity.java:51)
    at android.app.Activity.performCreate(Activity.java:6955)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) 
    at android.app.ActivityThread.-wrap14(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:154) 
    at android.app.ActivityThread.main(ActivityThread.java:6776) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

任何帮助,将不胜感激。谢谢你。

4

2 回答 2

0

我认为您正在使用自定义工具栏或其他自定义功能。

如果自定义工具栏然后

  <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

 <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

否则请阅读:

https://developer.android.com/training/material/theme.html

https://developer.android.com/guide/topics/ui/look-and-feel/themes.html

https://www.tutorialspoint.com/android/android_styles_and_themes.htm

于 2017-10-06T12:33:03.540 回答
0

我刚刚通过从与 Payfort SDK 基本冲突的 style.xml 文件中删除这些项目来解决问题。这解决了问题。

<style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>


    <style name="Theme.Transparent" parent="android:Theme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:backgroundDimEnabled">false</item>
    </style>


    <style name="MyTheme" parent="android:Theme.Holo.Dialog">
        <item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:textColorPrimary">#FFFFFF</item>
        <item name="android:backgroundDimEnabled">false</item>
        <item name="android:textColor">#FFFFFF</item>
        <item name="android:textStyle">normal</item>
        <item name="colorAccent">@color/colorPrimaryDark</item>
        <item name="android:textSize">12sp</item>
    </style>

    <style name="CustomAlertDialogStyle">
        <item name="android:bottomBright">@android:color/transparent</item>
        <item name="android:bottomDark">@android:color/transparent</item>
        <item name="android:bottomMedium">@android:color/transparent</item>
        <item name="android:centerBright">@android:color/transparent</item>
        <item name="android:centerDark">@android:color/transparent</item>
        <item name="android:centerMedium">@android:color/transparent</item>
        <item name="android:fullBright">@android:color/transparent</item>
        <item name="android:fullDark">@android:color/transparent</item>
        <item name="colorAccent">@color/colorPrimaryDark</item>
        <item name="android:topBright">@android:color/transparent</item>
        <item name="android:topDark">@android:color/transparent</item>
    </style>
于 2017-10-10T16:23:03.850 回答