Android Question ClassNotFoundException

mw71

Active Member
Licensed User
hi,

i use this Modul (ZipManager, with Inline Java) to Zip the Files before upload to Google Drive:
https://www.b4x.com/android/forum/threads/zip-multiple-files-with-abzipunzip.96968/#post-611629

now a user and Firebase Report a Crash. The Main reason/error is:
Caused by java.lang.ClassNotFoundException
Didn't find class "de.xxxsoft.xxx.gdrive_service$ResumableSub_upload_Backup" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/de.xxxsoft.xxx-em5hdsfUiOPOzd0LR2oyww==/base.apk"],nativeLibraryDirectories=[/data/app/de.xxxsoft.xxx-em5hdsfUiOPOzd0LR2oyww==/lib/arm64, /system/lib64, /vendor/lib64]]
dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134)
(if you Need more Error Message vom CrashAnalyics, or Code, let me know)

Device is a Samsung with Android 9 (on my Device with Android 9, and lower, all fine)


what is the reason and what can i do to fix it?
 

mw71

Active Member
Licensed User
B4X:
Sub Process_Globals
    Dim FileList_Backup As List
    Dim FileList_Backup_Archiv As List
    Dim FileList_Backup_Remote As Map
    Dim FileList_Backup_Remote_Archiv As Map
......
FileList_Backup_Remote, hold the Name and ID from the Files in the Google Drive
FileList_Backup & FileList_Backup_Archiv hold the Phat and Name from the local Files to Upload

B4X:
Sub upload_Backup
    Starter.cl.lg("upload_Backup")
   
    varSize=FileList_Backup.Size + FileList_Backup_Archiv.Size

    For i=0 To FileList_Backup.Size-1
        varCounter=i + 1
        varDrive_qDatei = FileList_Backup.Get(i)
       
        varReturn_FileFound_ID =""
       
        Dim erweiterung As String
        If varDrive_qDatei.Contains(".zip") Then
            erweiterung=""
        Else
            erweiterung=".bak"
        End If
       
        If FileList_Backup_Remote.ContainsKey(varDrive_qDatei & erweiterung)=True Then
            Starter.cl.lg("* Datei Remote")
            varDrive_zFileID=FileList_Backup_Remote.Get(varDrive_qDatei & erweiterung)
        Else
            Starter.cl.lg("* Datei new")
            varDrive_zFileID=""
        End If

        Starter.cl.lg("Upload_File_to_Google, File: " & varDrive_qPhath & "/" & varDrive_qDatei)
        Start_Backup.Count_Upload=Start_Backup.Count_Upload+1
        GDrive.UploadFile(varDrive_qDatei & erweiterung,varDrive_qPhath,varDrive_qDatei,varDrive_zPhath_ID,varDrive_zFileID)
        wait for Drive_FileUploaded(FileID As String)
    Next
   
    Starter.cl.lg("=============")
    CallSubDelayed(Me,"Upload_Backup_fin")
End Sub
Upload the File to Google Part:
B4X:
'Upload a file to Google Drive
'Name       - The Name of the filename (Name at Google Drive)
'UploadDir  - The (local) folder of the upload file.
'UploadFile - Filename (local) of the upload file
'FileID     - The file ID on Google Drive. If not known, a new file will created.
'
'Events : FileUploadDone(FileID as string)
'Update einbauen/Testen
'Parrent testen
Sub UploadFile(Name As String, LocalDir As String, LocalFilename As String, Parrent As String, FileId As String)

    Starter.cl.lg("-------------------")
    Starter.cl.lg("GoogleDrive, UploadFile")

    Dim data() As Byte

    If Name = "" Then Name = LocalFilename

    Starter.cl.lg("LocalDir:" & LocalDir)
    Starter.cl.lg("LocalFilename:" & LocalFilename)
    Starter.cl.lg("Parent:" & Parrent)
    Starter.cl.lg("FileID:" & FileId)
   
    Try
        Dim h_ul As HttpJob
        h_ul.Initialize("",Me)
   
        If FileId = "" Then
            Starter.cl.lg("Upload w/o File ID (create new File)")
            'Create the stream
            Dim boundary As String = "foo_bar_baz"
            Dim ContentType As String = "application/octet-stream"
            Dim EOL As String= Chr(13) & Chr(10)

            Dim In As InputStream = File.OpenInput(LocalDir, LocalFilename)
            Dim out2 As OutputStream
            out2.InitializeToBytesArray(1000)

            Dim m As Map
            m.Initialize
            m.Put("name", Name)
            If Parrent <>"" Then m.Put("parents",Array As String(Parrent))

            Dim Jg As JSONGenerator
            Jg.Initialize(m)

            'The first half of the POST contains the JSON data AND the Content Type from above.
            Dim RR As String = "--" & boundary & EOL & _
                            "Content-Type: application/json; charset=UTF-8" & EOL & EOL & _
                            Jg.ToString & EOL & EOL & _
                            "--" & boundary & EOL & _
                            "Content-Type: " & ContentType & EOL & EOL
                           
            data = (RR).GetBytes("UTF-8")
   
            out2.WriteBytes(data, 0, data.Length)                            'Write it To the Stream.
            File.Copy2(In, out2)                                            'Add the File itself To the Stream.
            data = (EOL & EOL & "--" & boundary & "--").GetBytes("UTF-8")    'Add the final boundary to the POST
            out2.WriteBytes(data, 0, data.Length)                            'Write it To the Stream Then make the Bytes the complete Stream.
            data = out2.ToBytesArray
       
            h_ul.PostBytes("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", data)
            h_ul.GetRequest.SetContentType("multipart/related; boundary=" & boundary)
            h_ul.GetRequest.SetHeader("Authorization", "Bearer " & myAccessToken)
        Else
            Starter.cl.lg("Upload mit File ID (File Content Update)")
            'Create a new stream
            Dim OutUpdate As OutputStream
            Dim InUpate As InputStream = File.OpenInput(LocalDir, LocalFilename)
       
            OutUpdate.InitializeToBytesArray(1000)            'Initialize the stream
            File.Copy2(InUpate, OutUpdate)                    'Copy the filestream in the output stream
            data = OutUpdate.ToBytesArray                    'Fill export data array
       
            h_ul.PatchBytes("https://www.googleapis.com/upload/drive/v3/files" & "/" & FileId & "?uploadType=media", data)
            h_ul.getrequest.SetHeader("Authorization", "Bearer " & myAccessToken)
        End If

        wait For (h_ul) JobDone(h_ul As HttpJob)

        If h_ul.Success Then
            Starter.cl.lg("Upload File Success")
            'starter.cl.lg(h_ul.GetString)
            Dim j As JSONParser
            Dim Map1 As Map
       
            J.Initialize(h_ul.GetString)
            Map1 = J.NextObject
            FileId=Map1.Get("id")
        else
           
       
        End If

    Catch
        Starter.cl.lg("GoogleUpload File Error")
        Starter.cl.lg(LastException.Message)
        Dim writer As TextWriter
        writer.Initialize(File.OpenOutput(Starter.DirRootExternal,"Log_Backup_Err.txt",True))
        writer.WriteLine(LocalFilename & ", " & LastException.Message)
        writer.Close
    End Try
   
    CallSubDelayed2(evModule, evName & "_FileUploaded", FileId)
End Sub
 

mw71

Active Member
Licensed User
This code is not needed. HttpJob has built-in support for multipart requests.
now, i know (and use it for new cases). i have write this code a view years before and it works.

This is a strange error. If there is only a single report of this error then you should probably ignore it for now.
Yes, at the moment it is a single Report (1 User/Device, a view times). I will see what will happen in the future.

many thanks for view/help
 
Top