Android Question list.initialize runs in Debug not in Release

Discussion in 'Android Questions' started by koffie, May 6, 2015.

  1. koffie

    koffie Member Licensed User

    Big sigh....

    Just as the thread says. Everything runs fine when in debugger, but I get a 'not initialized' error when in release when it comes to a list : "object should first be initialized(List).".

    Like I said everything smooth in Debug.

    What am I doing wrong.

    Thanks,
     
  2. klaus

    klaus Expert Licensed User

    Without seeing what exactly you have done, how could you expect getting any concrete help.
     
    DonManfred likes this.
  3. koffie

    koffie Member Licensed User

    Thought there were 1 or 2 general common errors when it comes to populating lists.
    Code:
    Sub Activity_Create(FirstTime As Boolean)

     
    Activity.LoadLayout("Layout1")
      
    Dim GD As GradientDrawable
      GD.Initialize(
    "TR_BL"Array As Int(Colors.Blue, Colors.LightGray))
      
    Activity.Background = GD
     
       
      ImageView1.Initialize(
    "test")
      ImageView1.Color = 
    Colors.ARGB(25,0,0,0)
       

      Panel1.visible=
    False
      ListView1.SingleLineLayout.ItemHeight = 
    50dip
      ListView1.SingleLineLayout.Label.TextSize = 
    20
      ListView1.SingleLineLayout.Label.TextColor = 
    Colors.White
      ListView1.SingleLineLayout.Label.Gravity = 
    Gravity.LEFT
      ListView1.FastScrollEnabled = 
    True
      filelist.Initialize
      path1=
    "/storage/extSdCard"
    ListFolderContent(path1)
    End Sub


    Sub ListFolderContent(folder As String'As String
    Dim n As Int

      filelist = 
    File.ListFiles(path1)
      filelist.Sort(
    True)
      
    For n = 0 To filelist.Size-1
      file1 = filelist.Get(n)
       
    'Log ("file1:"&file1)
      ListView1.AddSingleLine(file1)
      
    Next
    End Sub
    Like I said...no problems in Debug.....error in Release....
     
  4. klaus

    klaus Expert Licensed User

    Where do you declare path1 and filelist ?
    When you call the ListFolderContent routine you pass the variable path1 to the variable folder.
    But in the routine you use path1 and not folder.
    I suspect that in ListFolderContent filelist is either not known or empty.
    From the help of ListFiles:
    An uninitialized list will be returned if the folder is not accessible.

    The degugger mode is more foregiving than the release mode.
     
  5. koffie

    koffie Member Licensed User

    Yeah,
    I saw your response in one of the forums. But....

    some more tinkering:
    Code:
    filelist = File.ListFiles("/storage/extSdCard") gives a VALID response in DEBUG BUT an invalid reponse in Release....
     
  6. DonManfred

    DonManfred Expert Licensed User

    In
    Code:
    file.listfiles(folder)
    you should use the given path instead of an variable which can be unknown to the sub.

    I dont know whether it is the problem or not. Hard to say with your code-snippet
     
  7. DonManfred

    DonManfred Expert Licensed User

    If you are using Kitkat or higher you probably dont have access to the ext sdcard.
    On older Android versions you need to add the permission to write external storages.

    Starting with android 5 (Lollipop) you can use this library to get the right path to the external SDCard
     
    KMatle likes this.
  8. koffie

    koffie Member Licensed User

    You guys are great.....

    Code:
    AddPermission(android.permission.WRITE_MEDIA_STORAGE)
    AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
    did it....

    Thanks,
     
  9. DonManfred

    DonManfred Expert Licensed User

    HERE you find a complete list
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    The debugger adds the write permission automatically (as it needs it). This permission is also added when you use File.DirRootExternal or DirDefaultExternal.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice