Runtime Error while using payu-custom-browser Xamarin Android Binding Library Says CBActivity : You need to use a Theme.AppCompat theme

116 Views Asked by At

I am integrating PayU Payment gateway in My Xamarin forms application. So I have converted all the given Libraries using Xamarin Binding Libs. I am getting this erron when click on pay Button

Java.Lang.RuntimeException: 'Unable to start activity ComponentInfo{com.optimiserfood.bakers_lounge/com.payu.custombrowser.CBActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.'

However I have seen that CBActivity Using AppCompatActivity on decomplinig the library. it is also works fine with android studio.

1

There are 1 best solutions below

1
On

In this case, you can try to change the Java inheritance from AppCompatActivity to Activity .

The general rule is that if you want your code to support older versions of Android, it should have the AppCompat theme and the java code should extend AppCompatActivity. If you have an activity that doesn't need this support, such as you only care about the latest versions and features of Android, you can apply any theme to it but the java code must extend plain old Activity.

NOTE:

When changing from AppCompatActivity (or a subclass, ActionBarActivity), to Activity, we should also change the various calls with support to the corresponding call without support. For example, instead of using getSupportFragmentManager,we should use getFragmentManager.

Another option is to use following style in style resource:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">