Search code examples
androidzendesk

You need to use a Theme.AppCompat theme (or descendant) with this activity in zendesk sdk


I am using external activity of zendesk sdk in my android application

I just open it using the following code

Intent intent = new Intent(ContactUsActivity.this, ContactZendeskActivity.class);
startActivity(intent);

Then I got the following crash

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.forsale.forsale/com.zendesk.sdk.feedback.ui.ContactZendeskActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3149)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:331)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:264)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:130)
at com.zendesk.sdk.feedback.ui.ContactZendeskActivity.onCreate(ContactZendeskActivity.java:103)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
... 10 more

can anyone please tell me what to do?

EDIT

I know that I need to use this theme in the activity, but the activity is not part of my code, it is part of zendesk sdk, and it is not defined in my manifest file, and I don't want to use this theme for my whole application


Solution

  • You can do one of two things:

    1) Redefine the activity in your own manifest

    <activity
      android:name="com.zendesk.sdk.feedback.ui.ContactZendeskActivity"
      android:label="@string/contact_fragment_title"
      android:windowSoftInputMode="stateVisible|adjustResize"
      android:theme="your_theme" />
    

    2) Subclass the activity and define the style in your Activity.