Android Question AppCompat crash on Android 8 [SOLVED]

madru

Active Member
Licensed User
Longtime User
Hi guys,

I have question, maybe a stupid one ?

running the non modified example from Erel (b4a_b4xdrawer-zip.95460) on my Android 8 test device I get this error...... any idea why?

B4X:
Logger connected to:  HUAWEI PRA-LX1
--------- beginning of crash
Fatal signal 6 (SIGABRT), code -6 in tid 31933 (RenderThread)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'HUAWEI/PRA-LX1/HWPRA-H:8.0.0/HUAWEIPRA-LX1/384(C02):user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 31911, tid: 31933, name: RenderThread  >>> b4a.example <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'Failed to create EGLSurface for window 0x7bc41c7010, eglErr = EGL_BAD_ALLOC'
    x0   0000000000000000  x1   0000000000007cbd  x2   0000000000000006  x3   0000000000000008
    x4   0000000000000000  x5   0000000000000000  x6   0000000000000000  x7   7f7f7f7f7f7f7f7f
    x8   0000000000000083  x9   9b8866d9da7ebe18  x10  0000000000000000  x11  0000000000000001
    x12  ffffffffffffffff  x13  ffffffffffffffff  x14  ff00000000000000  x15  ffffffffffffffff
    x16  0000007bc86582d0  x17  0000007bc85f9800  x18  0000000000000000  x19  0000000000007ca7
    x20  0000000000007cbd  x21  0000007bb5b7ba80  x22  0000007ba5678c98  x23  0000007bc57b90fc
    x24  0000007bc57b9060  x25  7fffffffffffffff  x26  0000007ba6e7a338  x27  0000007bc408ef30
    x28  7fffffffffffffff  x29  0000007ba6e79cf0  x30  0000007bc85acb54
    sp   0000007ba6e79cb0  pc   0000007bc85f9808  pstate 0000000060000000
backtrace:
    #00 pc 000000000006a808  /system/lib64/libc.so (tgkill+8)
    #01 pc 000000000001db50  /system/lib64/libc.so (abort+88)
    #02 pc 0000000000007f4c  /system/lib64/liblog.so (__android_log_assert+304)
    #03 pc 000000000004e314  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread10EglManager13createSurfaceEP13ANativeWindow+192)
    #04 pc 000000000004c790  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread14OpenGLPipeline10setSurfaceEPNS_7SurfaceENS1_12SwapBehaviorE+64)
    #05 pc 00000000000492b4  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread13CanvasContext10setSurfaceEPNS_7SurfaceE+140)
    #06 pc 0000000000051344  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthreadL20Bridge_updateSurfaceEPNS1_17updateSurfaceArgsE+16)
    #07 pc 0000000000052fc4  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread22MethodInvokeRenderTask3runEv+24)
    #08 pc 0000000000053f1c  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread12RenderThread10threadLoopEv+348)
    #09 pc 0000000000011670  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+280)
    #10 pc 00000000000bd4a8  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+136)
    #11 pc 00000000000671b8  /system/lib64/libc.so (_ZL15__pthread_startPv+36)
    #12 pc 000000000001eee4  /system/lib64/libc.so (__start_thread+68)
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 0 (B4XDrawer)
java.lang.RuntimeException: java.lang.ClassCastException: b4a.example.main cannot be cast to androidx.appcompat.app.AppCompatActivity
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
    at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:293)
    at b4a.example.main._activity_create(main.java:392)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.example.main.afterFirstLayout(main.java:104)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:808)
    at android.os.Handler.dispatchMessage(Handler.java:101)
    at android.os.Looper.loop(Looper.java:166)
    at android.app.ActivityThread.main(ActivityThread.java:7523)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.ClassCastException: b4a.example.main cannot be cast to androidx.appcompat.app.AppCompatActivity
    at de.amberhome.objects.appcompat.ACToolBarWrapper.DesignerCreateView(ACToolBarWrapper.java:119)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:70)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    ... 19 more
** Activity (main) Resume **
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
 

DonManfred

Expert
Licensed User
Longtime User
Where is the relevant main activity code?
 
Upvote 0

madru

Active Member
Licensed User
Longtime User
as said, non modified example from Erel

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
    #Extends: android.support.v7.app.AppCompatActivity
Sub Process_Globals

End Sub

Sub Globals
    Private ACToolBarLight1 As ACToolBarLight
    Private ToolbarHelper As ACActionBar
    Private Drawer As B4XDrawer
    Private ListView1 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Drawer.Initialize(Me, "Drawer", Activity, 300dip)
    Drawer.CenterPanel.LoadLayout("1")
    ToolbarHelper.Initialize
    ToolbarHelper.ShowUpIndicator = True 'set to true to show the up arrow
    Dim bd As BitmapDrawable
    bd.Initialize(LoadBitmap(File.DirAssets, "hamburger.png"))
    ToolbarHelper.UpIndicatorDrawable =  bd
    ACToolBarLight1.InitMenuListener
    Drawer.LeftPanel.LoadLayout("Left")
    For i = 1 To 30
        ListView1.AddSingleLine("Item " & i)

    Next
End Sub

Sub ACToolBarLight1_NavigationItemClick
    Drawer.LeftOpen = Not(Drawer.LeftOpen)
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK And Drawer.LeftOpen Then
        Drawer.LeftOpen = False
        Return True
    End If
    Return False
End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

SetApplicationAttribute(android:theme, "@style/MyAppTheme")

CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">#0098FF</item>
        <item name="colorPrimaryDark">#007CF5</item>
        <item name="colorAccent">#AAAA00</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:windowTranslucentNavigation">false</item>
         <item name="android:windowTranslucentStatus">true</item>
    </style>
</resources>
)
 
Upvote 0

madru

Active Member
Licensed User
Longtime User
it is somehow related to the crappy HUAWEI phone with Android 8. (8.0.0.384 C02)

the exact same APK runs on different Sony Android 8 phones without a problem
 
Upvote 0

madru

Active Member
Licensed User
Longtime User
little update, wiped the HUAWEI P10 lite and ..... it is working now - very strange
 
Upvote 0
Top