paytabscom / flutter-sdk-bridge

MIT License
12 stars 11 forks source link

Clicked on scan card icon and app crashed on android #56

Closed IgeeTheron closed 1 year ago

IgeeTheron commented 1 year ago

When I go to pay tabs and click on the scan card icon the app crashes and gives back this error message: P.s. I have replaced my app application name with the variable => ${package}

D/AndroidRuntime(21829): Shutting down VM
E/AndroidRuntime(21829): FATAL EXCEPTION: main
E/AndroidRuntime(21829): Process: ${package}, PID: 21829
E/AndroidRuntime(21829): java.lang.RuntimeException: Unable to start activity ComponentInfo{${package}/com.paytabs.paytabscardrecognizer.cards.pay.paycardsrecognizer.sdk.ui.ScanCardActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
E/AndroidRuntime(21829):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3835)
E/AndroidRuntime(21829):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4011)
E/AndroidRuntime(21829):    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
E/AndroidRuntime(21829):    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(21829):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(21829):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2325)
E/AndroidRuntime(21829):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(21829):    at android.os.Looper.loop(Looper.java:246)
E/AndroidRuntime(21829):    at android.app.ActivityThread.main(ActivityThread.java:8633)
E/AndroidRuntime(21829):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(21829):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
E/AndroidRuntime(21829):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
E/AndroidRuntime(21829): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
E/AndroidRuntime(21829):    at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:852)
E/AndroidRuntime(21829):    at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:815)
E/AndroidRuntime(21829):    at androidx.appcompat.app.AppCompatDelegateImpl.onPostCreate(AppCompatDelegateImpl.java:536)
E/AndroidRuntime(21829):    at com.paytabs.paytabscardrecognizer.cards.pay.paycardsrecognizer.sdk.ui.ScanCardActivity.onCreate(ScanCardActivity.java:30)
E/AndroidRuntime(21829):    at android.app.Activity.performCreate(Activity.java:8207)
E/AndroidRuntime(21829):    at android.app.Activity.performCreate(Activity.java:8191)
E/AndroidRuntime(21829):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
E/AndroidRuntime(21829):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3808)
E/AndroidRuntime(21829):    ... 11 more
I/Process (21829): Sending signal. PID: 21829 SIG: 9
Lost connection to device.

I have had a look at the themes in my android/app/src/main/AndroidManifest.xml as well as android/app/src/main/res/values/styles.xml: Here are the files

android/app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="****************">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
   <application
        android:label="****************"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user0..0.0
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
       <activity
           android:name="com.yalantis.ucrop.UCropActivity"
           android:screenOrientation="portrait"
           android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

android/app/src/main/res/values/styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
    <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             the Flutter engine draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    <!-- Theme applied to the Android Window as soon as the process has started.
         This theme determines the color of the Android Window while your
         Flutter UI initializes, as well as behind your Flutter UI while its
         running.

         This Theme is only used starting with V2 of Flutter's Android embedding. -->
    <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">?android:colorBackground</item>
    </style>
</resources>

android/app/src/main/res/values-night/styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             the Flutter engine draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    <!-- Theme applied to the Android Window as soon as the process has started.
         This theme determines the color of the Android Window while your
         Flutter UI initializes, as well as behind your Flutter UI while its
         running.

         This Theme is only used starting with V2 of Flutter's Android embedding. -->
    <style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <item name="android:windowBackground">?android:colorBackground</item>
    </style>
</resources>

All I know is that it has something to do with the theme but I cant figure out what the problem is, please help.

ralmarri12 commented 1 year ago

same issue

KhaledAlramam commented 1 year ago

Issue fixed on version 2.3.5