Android Question Error uploading APK to google console

Scantech

Well-Known Member
Licensed User
Duplicate declarations of permission android.permission.WRITE_EXTERNAL_STORAGE with different maxSdkVersions.

I use rp.GetSafeDirDefaultExternal and file.DirRootExternal.

My manifest
B4X:
AddManifestText(
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)

AddManifestText(
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="29"/>)

'SetApplicationAttribute(android:icon, "@drawable/icon")    'using adaptive icons.  this not needed
SetApplicationAttribute(android:label, "$LABEL$")

'Increase memory just in case memory crash
SetApplicationAttribute(android:largeHeap,"true")

'Icons new method
SetApplicationAttribute(android:icon, "@mipmap/ic_launcher")
CreateResource(mipmap-anydpi-v26, ic_launcher.xml,
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@mipmap/background"/>
    <foreground android:drawable="@mipmap/foreground"/>
</adaptive-icon>
)

'Permissions--------------------------------------------------------------------------------
AddPermission(android.permission.BLUETOOTH_ADMIN)
AddPermission(android.permission.ACCESS_COARSE_LOCATION)
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)
'-------------------------------------------------------------------------------------------

'Trip GPS
AddManifestText(<uses-feature android:name="android.hardware.location.gps"/>)

'Set Theme
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="@style/Theme.AppCompat">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="preferenceTheme">@style/PreferenceThemeOverlay.Material</item>
        <item name="asp_preferenceIconTint">?colorAccent</item>
        <item name="asp_preferenceDialogIconTint">?asp_preferenceIconTint</item>
        <item name="windowActionModeOverlay">true</item>
    </style>
</resources>
)

'Disable this for Amazon and Blackberry
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)

'Google Billing
CreateResourceFromFile(Macro, GooglePlayBilling.GooglePlayBilling)

'Use this with BLE2.  Some user says Android 9 and 10 crashes without this
'AddPermission(android.permission.FOREGROUND_SERVICE)

'This is a sample AdMob app id. You need to change it to your id.
AddReplacement($ADMOB_APP_ID$, ca-app-pub-xxxxxxxxxxxxxxxxxxxx)

'File uri for sharing files
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" />
)
 
'Used for B4XPreferenceDialog
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)

'Used with GetSafeDirExternal
AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="19" />
)

'Requires Android.jar 29 and fixes a workaround for File.DirRootExternal
SetApplicationAttribute(android:requestLegacyExternalStorage, true)

'End of default text.

Should i disable
B4X:
AddManifestText(

<uses-permission

  android:name="android.permission.WRITE_EXTERNAL_STORAGE"

  android:maxSdkVersion="19" />

)

This was a requirement as per post. I hope all i need to do is disable this?

Soon, i will be eliminating File.DirRootExternal, by then, i think i should enable it, right?
 

Erel

Administrator
Staff member
Licensed User
This was a requirement as per post. I hope all i need to do is disable this?
You need to understand the reason behind this version specific permission. It is a permission that is added to Android 4.4- devices and allows them to access rp.GetSafeDirDefaultExternal. On Android 5+ no permission is required for that folder.

The bottom line is that in your case, you are requesting the permission on all versions as you are accessing File.DirRootExternal so you can safely remove the version specific permission.
 
Upvote 0
Top