Android Question Please error after adding SetApplicationAttribute(android:requestLegacyExternalStorage, true) help

Makumbi

Well-Known Member
Licensed User
Please help iam stilling getting this error despite the fact that i have allowed the device to access the storage please help
i have also reinstalled the b4a software
using the configurations below but the error still pops up

1606201615835.png

code

B4X:
Sub DownloadAndSaveFileP2 (Link As String)
    Dim FilePath2 As String = File.Combine(File.DirRootExternal, "Download")
    Dim FileName As String = "P2WORK.PDF"
    File.Delete(FilePath2, FileName)
    Dim Phone As Phone
    If Phone.SdkVersion <= 18 Then
        Dim i As Intent
        i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", "file://" & FilePath2)
        Dim p As Phone
        p.SendBroadcastIntent(i)
    Else
        Dim ctxt As JavaObject
        ctxt.InitializeContext
        Dim MediaScannerConnection As JavaObject
        MediaScannerConnection.InitializeStatic("android.media.MediaScannerConnection")
        Dim interface As Object = MediaScannerConnection.CreateEventFromUI("android.media.MediaScannerConnection.OnScanCompletedListener", "ScanCompleted", _
                   Null)
        MediaScannerConnection.RunMethod("scanFile", Array(ctxt, Array As String(FilePath2), Array As String("image/pdf"), interface))
    End If
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download(Link)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
      
        Dim out As OutputStream = File.OpenOutput(File.DirInternal, "P2WORK.PDF", False)
        File.Copy2(j.GetInputStream, out)
        out.Close
              
        Dim rp As RuntimePermissions
        rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
        Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        If Result Then
            File.Copy(File.DirInternal, "P2WORK.PDF", File.DirRootExternal, "Download/P2WORK.PDF")
            Dim FilePath As String = File.Combine(File.DirRootExternal, "Download/P2WORK.PDF")
            Dim Phone As Phone
            If Phone.SdkVersion <= 18 Then           ' min - 4.3.1
                Dim i As Intent
                i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", "file://" & FilePath)
                Phone.SendBroadcastIntent(i)
            Else
                Dim ctxt As JavaObject
                ctxt.InitializeContext
                Dim MediaScannerConnection As JavaObject
                MediaScannerConnection.InitializeStatic("android.media.MediaScannerConnection")
                Dim interface As Object = MediaScannerConnection.CreateEventFromUI("android.media.MediaScannerConnection.OnScanCompletedListener", "ScanCompleted", _
                   Null)
                MediaScannerConnection.RunMethod("scanFile", Array(ctxt, Array As String(FilePath), Array As String("image/pdf"), interface))
            End If
        End If
      
    End If
    j.Release

    MsgboxAsync("The downloaded work has been placed in Downloads of Adobe acrobat reader. Please Install adobe acrobat reader incase it is not yet installed on your phone thank you. And Check in Adobe click files. ","Homework Downloaded")
    'Sleep(0)'saveimag
    ProgressDialogHide
End Sub

B4X:
B4A Version: 10.2
Java Version: 11
Parsing code.    (0.65s)
Building folders structure.    (0.17s)
Compiling code.    (1.24s)
Compiling layouts code.    (0.03s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Generating R file.    (0.00s)
Compiling debugger engine code.    (0.07s)
Compiling generated Java code.    (0.07s)
Convert byte code - optimized dex.    (12.93s)
Packaging files.    Error
AndroidManifest.xml:39: error: No resource identifier found for attribute 'requestLegacyExternalStorage' in package 'android'

AAPT path: D:\sdk-tools-windows-4333796\tools\..\build-tools\27.0.1\aapt.exe
Exit code:1


below is my manifest editor

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:usesCleartextTraffic, "true")
SetApplicationAttribute(android:allowBackup, "false")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
    SetActivityAttribute(SendsmschatV2, android:windowSoftInputMode, adjustPan|stateHidden)
    SetActivityAttribute(loadlessons, android:hardwareAccelerated, "true")
    
SetActivityAttribute(sendlessondata, android:hardwareAccelerated, "true")
CreateResourceFromFile(Macro, Themes.DarkTheme)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, Core.NetworkClearText)
AddPermission(com.majeur.launcher.permission.UPDATE_BADGE)
AddPermission(com.sec.android.provider.badge.permission.READ)
AddPermission(com.sec.android.provider.badge.permission.WRITE)
AddPermission(com.htc.launcher.permission.READ_SETTINGS)
AddPermission(com.htc.launcher.permission.UPDATE_SHORTCUT)
AddPermission(com.anddoes.launcher.permission.UPDATE_COUNT)
AddPermission(com.majeur.launcher.permission.UPDATE_BADGE)
AddPermission(com.huawei.launcher3.permission.READ_SETTINGS)
AddPermission(com.huawei.launcher3.permission.WRITE_SETTINGS)
AddPermission(com.huawei.launcher2.permission.READ_SETTINGS)
AddPermission(com.huawei.launcher2.permission.READ_SETTINGS)
AddPermission(com.huawei.android.launcher.permission.WRITE_SETTINGS)
AddPermission(com.huawei.android.launcher.permission.READ_SETTINGS)
AddPermission(android.permission.READ_EXTERNAL_STORAGE)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
AddPermission(com.sonyericsson.home.permission.BROADCAST_BADGE)
AddPermission(com.anddoes.launcher.permission.UPDATE_COUNT)
SetApplicationAttribute(android:requestLegacyExternalStorage, true)
AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)

 

CreateResource(values, colors.xml,
<resources>
    <color name="actionbar">#0098FF</color>
    <color name="statusbar">#ff006db3</color>
    <color name="textColorPrimary">#ffffffff</color>
    <color name="navigationBar">#ff006db3</color>
</resources>
)
CreateResource(values-v20, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
         <item name="android:colorPrimary">@color/actionbar</item>
         <item name="android:colorPrimaryDark">@color/statusbar</item>
         <item name="android:textColorPrimary">@color/textColorPrimary</item>
         <item name="android:navigationBarColor">@color/navigationBar</item>
    </style>
</resources>
)

'End of default text.





'End of default text.

'
 
Top