Android Question EACCES (Permission denied) (Solved)

Roger Daley

Well-Known Member
Licensed User
Hi All,

I know this question has been asked many times and the answer is always this : Runtime permissions: https://www.b4x.com/search?query=Runtime+permissions .
Well I have read through this several times and am more baffled than before.

My Question:
I have used the following code to copy the "Help File" to external memory where the user can access it for viewing on a PC, printing, etc.
I have used DirRootExternal because that what pops up when I access via a file manager.
The following code in Activity Create has worked well in Target SDK 28 but causes a Permission Denied error when changed to SDK 29.

B4X:
'Permission to READ/WRITE External Memory
        rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
        Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        '....  and then
        If Result Then     'The HepFile is copied to an external directory where it can transferred/printed etc.
'Copy Help file to the C_Calc folder
            If File.Exists(File.DirRootExternal&"/C_Calc/", "") = False Then File.MakeDir(File.DirRootExternal&"/C_Calc/", "")
            File.Copy(File.DirAssets,"helpfile.htm",File.DirrootExternal&"/C_Calc/","helpfile.htm")
        End If

The tutorial "Seems" to point me towards using
B4X:
RuntimePermissions.GetSafeDirDefaultExternal("")
leaving me with more questions.

1. Where/What is DirDefaultExternal when you access via a file manager?
2. What I read in the tutorial, implies that additional code is also required in the manifest, or is this an alternative to code in Activity Create.


Is there a simple fix to keep using DirRootExternal or do I need to use DirDefaultExternal with the previous questions in mind?
Thanks in advance.

Regards Roger
 

Roger Daley

Well-Known Member
Licensed User
Xfood

Unfortunately, compile error.

B4A Version: 10.0
Java Version: 11
Parsing code. (0.11s)
Building folders structure. (0.02s)
Compiling code. (0.43s)
Compiling layouts code. (0.02s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. (0.00s)
Compiling debugger engine code. (2.54s)
Compiling generated Java code. (2.19s)
Convert byte code - optimized dex. (2.07s)
Packaging files. Error
fakeLogOpen(/dev/log_crash) failed
fakeLogOpen(/dev/log_security) failed
fakeLogOpen(/dev/log_crash) failed
fakeLogOpen(/dev/log_security) failed
AndroidManifest.xml:24: error: No resource identifier found for attribute 'requestLegacyExternalStorage' in package 'android'

AAPT path: C:\android-sdk\tools\..\build-tools\27.0.1\aapt.exe
Exit code:1


Thanks for the try
Roger
 
Upvote 0

Xfood

Well-Known Member
Licensed User
you need to isare sdk 29, and compile with new sdk 29, look here


 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Xfood


Downloaded SDK and recompiled, still fails.

B4A Version: 10.0
Java Version: 11
Parsing code. (0.11s)
Building folders structure. (0.04s)
Compiling code. (0.46s)
Compiling layouts code. (0.03s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. Error
AndroidManifest.xml:21: error: No resource identifier found for attribute 'requestLegacyExternalStorage' in package 'android'


Regards Roger
 
Upvote 0

Xfood

Well-Known Member
Licensed User
look at this picture
 

Attachments

  • 1598016570268.png
    1598016570268.png
    13.1 KB · Views: 129
Upvote 0

Xfood

Well-Known Member
Licensed User
Created Folder Android-29, copied All from 28, configured paths to Android-29. Same problem.
Time to take a break and untwist my brain.

Roger
I think you have not read my suggestion correctly
 

Attachments

  • 1598016284173.png
    1598016284173.png
    24.9 KB · Views: 104
Upvote 0

DonManfred

Expert
Licensed User
Doesn´t look like an properly configured SDK.
When filter is set to "29" it should list some artifacts and even some Systemimages.

Snap3.png

I suggest to reinstall the SDK based on the Installationinstructions.
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
A while back Erel unzipped and prepared a ready to use SDK that you simply copy or maybe unzip to your Android folder and you were ready to go without going through the SDK Manager installation process. It eliminated a lot of installation missteps. . Is there something like that for SDK 29 somewhere in the forum where we can just copy it, that will take care of API 29.
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
We have drifted a bit off the original post a bit but I am thankful that we have.

Xfood, your change to the manifest seems to have solved the permissions issue now that I have "sort of" fixed the SDK version issue.

DonManfred. Thanks for the heads-up that the SDK looks wrong. Unfortunately installing the SDK using the instructions is what I have done already, setting the search box to 28 gives a similar result. Nothing like what you describe.

I found Android-29 at this location :
C:\Users\roger\AppData\Local\Android\Sdk\platforms
Setting the path to this location throws an error, copying the file to the recommended location seems to work.
I don't know what else can be done short of uninstalling B4A completely and reinstall from ground up. That seems a bit drastic to me.

Mahares/Erel I will give the zip a try when it is available. Even if I don't need to update to Android-29 at the moment it's time time will come, I might as well do it now.

Many thanks
Roger
 
Upvote 0
Top