Android Question Crash on first run. Debug & Release

Revisable5987

Member
Licensed User
Recently my app has started to crash.
Its only seems to happen after it is run the first time after being installed.
Every other time the app is launched after the crash everything works as it should and then if I reinstall the app it happens again.
Tried on both debug and release.

Java:
java.lang.IncompatibleClassChangeError: Class 'org.apache.xmlbeans.impl.store.Cur' does not implement interface 'java.util.List' in call to 'int java.util.List.size()' (declaration of 'org.apache.xmlbeans.impl.store.Saver' appears in base.apk!classes3.dex)
    at org.apache.xmlbeans.impl.store.Saver.pushMappings(Saver.java:546)
    at org.apache.xmlbeans.impl.store.Saver.processElement(Saver.java:406)
    at org.apache.xmlbeans.impl.store.Saver.process(Saver.java:307)
    at org.apache.xmlbeans.impl.store.Saver.<init>(Saver.java:123)
    at org.apache.xmlbeans.impl.store.Saver$TextSaver.<init>(Saver.java:916)
    at org.apache.xmlbeans.impl.store.Cursor._xmlText(Cursor.java:546)
    at org.apache.xmlbeans.impl.store.Cursor.xmlText(Cursor.java:2436)
    at org.apache.xmlbeans.impl.values.XmlObjectBase.xmlText(XmlObjectBase.java:1500)
    at org.apache.poi.xssf.model.SharedStringsTable.getKey(SharedStringsTable.java:134)
    at org.apache.poi.xssf.model.SharedStringsTable.addEntry(SharedStringsTable.java:180)
    at org.apache.poi.xssf.usermodel.XSSFCell.setCellValue(XSSFCell.java:368)
    at org.apache.poi.xssf.usermodel.XSSFCell.setCellValue(XSSFCell.java:332)
    at de.donmanfred.XSSFCellwrapper.setStringCellValue(XSSFCellwrapper.java:69)
    at b4a.example.week$ResumableSub_Button1_Click.resume(week.java:795)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    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:348)
    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 anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA$2.run(BA.java:370)
    at anywheresoftware.b4a.BA.setActivityPaused(BA.java:442)
    at b4a.example.week$ResumeMessage.run(week.java:306)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7682)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
** Activity (week) Resume **
 

DonManfred

Expert
Licensed User
Longtime User
Hard to help with the informations you provide.
Please upload a small project which shows the issue.
 
Upvote 0

Revisable5987

Member
Licensed User
Apologies, please see attached example project.
*Requires aPOI and Runtime Permissions*
(Plus additional Jars for aPOI)

Creating the example project has actually helped narrow down the cause of the problem. It only happens if I add a line like this:
B4X:
Cell.StringCellValue = File.ReadString(File.DirInternal, "name.txt")

And only an issue on first run after install.
 

Attachments

  • example project.zip
    15.8 KB · Views: 227
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
- The file in assets is named book1.xlsx
B4X:
        File.Copy(File.DirAssets,"Book1.xlsx",File.DirInternal,"Book1.xlsx")
        xls.Initialize("xls", File.Combine(File.DirInternal,"Book1  .xlsx")) ' Does NOT do anything useful.


It works for me using

B4X:
Sub Button1_Click
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    wait for Activity_PermissionResult (Permission As String, Result1 As Boolean)
    If Result1 Then
        File.Copy(File.DirAssets,"book1.xlsx",File.DirInternal,"book1.xlsx")
        xls.Initialize("xls", File.Combine(File.DirInternal,"book1.xlsx"))
        Dim sheet As XLSSheet = xls.getSheetAt(xls.ActiveSheetIndex)
        Dim Row As XSSFRow = sheet.CreateRow(1)
        Dim Cell As XSSFCell = Row.createCell(1)
        Cell.StringCellValue = "Test file"
        Dim Cell As XSSFCell = Row.createCell(2)
        Cell.StringCellValue = EditText1.Text
        Dim Cell As XSSFCell = Row.createCell(3)
        Cell.StringCellValue = File.ReadString(File.DirInternal, "name.txt")
    
        xls.write2(File.DirInternal, "TestSheet.xlsx")
    Else
        ToastMessageShow("Permissions not granted", True)
    End If
End Sub
 
Upvote 0

Revisable5987

Member
Licensed User
Weirdly my file name in assets is Book1 not book1, maybe it was changed when exported to zip?
However changing the code to book1 has fixed the issue in my example, although not in my real app.

I've removed all other code in my app so it is identical to the example app (that now works) yet I still get the same issue.

Could this be caused by me updating the library part way through the project maybe?
Failing that I'm at a loss as the two projects are now the same.

[EDIT]
Seems to be related to the phone library possibly. I can't replicate the crash as it is so random. But removing the phone library and then adding it again seems to solve the problem temporarily??
 
Last edited:
Upvote 0

Revisable5987

Member
Licensed User
It is not related to the Phone library. Removing and adding a library is similar to cleaning the project (Ctrl + P). Might be related to this.

Does it happen in release mode?

Ah ok, it's just very strange behaviour. Started a new project transferring my code over bit by bit. Initially the problem had gone until I added the FileProvider Class, JavaObject lib and Phone lib. This appears to have triggered the behaviour somehow? Which is why I looked into removing and adding the library.

Yes also happens in release mode, but If you restart the app after it crashes then it works properly every time.
 
Upvote 0
Top