I'm trying to write some native code in my Flutter app to integrate with Zendesk using their SDK. Thus far, my Flutter app has not required me to drop down and write any actual native code, so I'm getting a bit stuck here. What I have looks like this:
public class MainActivity extends FlutterActivity {
private static final String ZENDESK_CHANNEL = "zendesk";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
new MethodChannel(getFlutterView(), ZENDESK_CHANNEL).setMethodCallHandler(
this::invokeZendesk);
}
private void invokeZendesk(MethodCall call, MethodChannel.Result result) {
if (call.method.equals("init")) {
Zendesk.INSTANCE.init(this, "https://myapp.zendesk.com",
"myappid",
"myclientid");
Identity identity = new AnonymousIdentity();
Zendesk.INSTANCE.setIdentity(identity);
Support.INSTANCE.init(Zendesk.INSTANCE);
} else if (call.method.equals("launch")) {
RequestActivity.builder().show(this);
}
}
...
When I invoke the "launch" code I get this error:
E/AndroidRuntime(18326): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackage.myapp/zendesk.support.request.RequestActivity}: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class com.google.android.material.appbar.AppBarLayout
E/AndroidRuntime(18326): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
E/AndroidRuntime(18326): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
E/AndroidRuntime(18326): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
E/AndroidRuntime(18326): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
E/AndroidRuntime(18326): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
E/AndroidRuntime(18326): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
E/AndroidRuntime(18326): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(18326): at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(18326): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/AndroidRuntime(18326): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18326): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime(18326): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/AndroidRuntime(18326): Caused by: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class com.google.android.material.appbar.AppBarLayout
E/AndroidRuntime(18326): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.google.android.material.appbar.AppBarLayout
E/AndroidRuntime(18326): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime(18326): at java.lang.reflect.Constructor.newInstance0(Native Method)
E/AndroidRuntime(18326): at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
E/AndroidRuntime(18326): at android.view.LayoutInflater.createView(LayoutInflater.java:647)
E/AndroidRuntime(18326): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
E/AndroidRuntime(18326): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
E/AndroidRuntime(18326): at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
E/AndroidRuntime(18326): at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
E/AndroidRuntime(18326): at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
E/AndroidRuntime(18326): at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
E/AndroidRuntime(18326): at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
E/AndroidRuntime(18326): at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
E/AndroidRuntime(18326): at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
E/AndroidRuntime(18326): at zendesk.support.request.RequestActivity.onCreate(RequestActivity.java:85)
E/AndroidRuntime(18326): at android.app.Activity.performCreate(Activity.java:7136)
E/AndroidRuntime(18326): at android.app.Activity.performCreate(Activity.java:7127)
E/AndroidRuntime(18326): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
E/AndroidRuntime(18326): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
E/AndroidRuntime(18326): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
E/AndroidRuntime(18326): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
E/AndroidRuntime(18326): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
E/AndroidRuntime(18326): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
E/AndroidRuntime(18326): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
E/AndroidRuntime(18326): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(18326): at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(18326): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/AndroidRuntime(18326): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18326): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime(18326): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/AndroidRuntime(18326): Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).
E/AndroidRuntime(18326): at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:221)
E/AndroidRuntime(18326): at com.google.android.material.internal.ThemeEnforcement.checkAppCompatTheme(ThemeEnforcement.java:196)
E/AndroidRuntime(18326): at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:131)
E/AndroidRuntime(18326): at com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(ThemeEnforcement.java:72)
E/AndroidRuntime(18326): at com.google.android.material.appbar.ViewUtilsLollipop.setStateListAnimatorFromAttrs(ViewUtilsLollipop.java:45)
E/AndroidRuntime(18326): at com.google.android.material.appbar.AppBarLayout.<init>(AppBarLayout.java:183)
E/AndroidRuntime(18326): ... 28 more
When googling for that particular error I find some things about ensuring that you create an AppCompat theme for your activity, etc. but since this is not my own activity that I'm trying to launch, I'm not really sure what to do here.