Android Question Access to directory fails when compiles for release

Discussion in 'Android Questions' started by blakemail, Feb 1, 2015.

  1. blakemail

    blakemail Member

    I'm new to B4A. I have been trying it out by writing an app to replace one I wrote in VB6. It's been fun playing with B4A. My app works great in debug mode, but when I compile for release then run it the app throws an error when it tries to access the same directory.

    The code failing:


    I'm planning to get the full version if I can get my app to work. Is this a limitation of the free version?


  2. DonManfred

    DonManfred Expert Licensed User

    and we should GUESS what this error is?
  3. RandomCoder

    RandomCoder Well-Known Member Licensed User

    And what @DonManfred forgot to do was welcome you to the forum, I see this is your first post.
    With any type of fault it is always good to include the actual fault message or copy and paste the log.
    If you are able to share your code then the best way to get help is to zip your project and upload it.

    KMatle likes this.
  4. blakemail

    blakemail Member

    Duh@me the error message would help.

    Error Occurred
    An error has occurred in sub: is not a folder.

    and it offers a yes and no button.

    /storage/extSdCard/lscpr/music is a folder according to the file browser on my android device. And when I run the same app but in debug mode the folder is found and the assignment to the list works. I can even play the songs.

    I'm sure I'm doing something wrong.
  5. Erel

    Erel Administrator Staff Member Licensed User

    Change your code to:
    File.ListFiles(File.Combine(File.DirRootExternal, lscpr/music))
    1. The external storage varies between different devices.
    2. When you call File.DirRootExternal or File.DirDefaultExternal the compiler adds the required permission automatically.
  6. blakemail

    blakemail Member

    I'll check again, but I think File.DirRootExternal returned the emulated storage which is actually internal versus the actual SD card. This is for a Galaxy Tab 3 running android 4.4.2.

    Assuming I can't use File.DirRootExternal is there a workaround to make this work. It's frustrating that it works in debug mode but not in release mode. Makes me think there is something else that needs to be deployed.
  7. blakemail

    blakemail Member

    Well this is interesting. I added Msgbox(File.DirDefaultExternal,"2") and after it prompts me and I hit ok the program works like it does in debug mode. I guess there is something wonky about File.DirDefaultExternal on the Galaxy Tab 3. At lease I know it will work.
  8. blakemail

    blakemail Member

    OK I used File.DirDefaultExternal in an assignment (dummy=File.DirDefaultExternal) and that fixed my issue as well. Easy fix for a nagging problem.
  9. Erel

    Erel Administrator Staff Member Licensed User

  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