Android Storage Permission [Solved]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
nehu
Prole
Posts: 11
Joined: Fri Feb 25, 2022 1:12 am
Location: Argentina, Maybe under your bed

Android Storage Permission [Solved]

Post by nehu »

Hello! :crazy:
So... i finished a little app designed to be used on Android and you need to pick an image from your phone, to achieve this i made an in-game file explorer using nativefs(https://github.com/EngineerSmith/nativefs). Everything works fine when using the löve app you can easily install on the Play Store. :awesome:
However, when i build the game using APKTool, i can't handle to ask for reading storage permission. :ehem:
My AndroidManifest.xml looks like this:

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest package="insert.package.com"
      android:versionCode="7"
      android:versionName="0.0.6"
      android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>
    <uses-feature android:glEsVersion="0x00020000"/>
    <application
        android:allowBackup="true"
        android:icon="@drawable/love"
        android:label="insert label lol"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    >
        <activity
            android:configChanges="orientation|screenSize"
            android:label="insert label lol"
            android:launchMode="singleTask"
            android:name="org.love2d.android.GameActivity"
            android:screenOrientation="fullSensor"
        >
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <category android:name="tv.ouya.intent.category.GAME"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
            </intent-filter>
        </activity>
    </application>
</manifest>
as you can see, the android.permission.READ_EXTERNAL_STORAGE is present. :?
when i install the APK and go to app permision setting and select the app, i found out the game is not even asking for storage permission. I tried different things, like changing the target SDK to something lower than 22 (so i don't need to ask for permission in runtime), changing from love 11.3 to 11.4 and a bunch more things that didn't work, so... :(

¿How can i make my app ask for storage permission so the user can enable it throught settings?
and otherwise,
¿How can i ask for storage permission on runtime?

Thanks in advance. :monocle:

EDIT:
I forgot to mention that i tested this on android 11 and android 13 and both have the same problem. :death:
Last edited by nehu on Mon Feb 20, 2023 11:36 pm, edited 1 time in total.

Code: Select all

for i, v in pairs(problems) do
	fix(v)
end
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

Re: Android Storage Permission

Post by Bigfoot71 »

I cannot help you with APKTool, especially because this method is deprecated, if you want to distribute your application on Android, do it from this repository: https://github.com/love2d/love-android

Or else with the awesome repository of flamendless which is very easy to use to manage package name/version/etc...

But avoid using APKTool especially since your app will not be accepted on the PlayStore.

Sources:
https://love2d.org/wiki/Game_Distribution
https://android-developers.googleblog.c ... ments.html
My avatar code for the curious :D V1, V2, V3.
User avatar
nehu
Prole
Posts: 11
Joined: Fri Feb 25, 2022 1:12 am
Location: Argentina, Maybe under your bed

Re: Android Storage Permission

Post by nehu »

Bigfoot71 wrote: Sun Feb 19, 2023 10:32 pm I cannot help you with APKTool, especially because this method is deprecated, if you want to distribute your application on Android, do it from this repository: https://github.com/love2d/love-android

Or else with the awesome repository of flamendless which is very easy to use to manage package name/version/etc...

But avoid using APKTool especially since your app will not be accepted on the PlayStore.

Sources:
https://love2d.org/wiki/Game_Distribution
https://android-developers.googleblog.c ... ments.html
I understand, but this app is for personal use, I don't will publish it on PlayStore or any other site. I used APK tool since i thought it was the easiest methods, however, I'm going to try building the app with the methods you showed, thank you! ^^

Code: Select all

for i, v in pairs(problems) do
	fix(v)
end
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

Re: Android Storage Permission

Post by Bigfoot71 »

nehu wrote: Sun Feb 19, 2023 11:48 pm I understand, but this app is for personal use, I don't will publish it on PlayStore or any other site. I used APK tool since i thought it was the easiest methods, however, I'm going to try building the app with the methods you showed, thank you! ^^
I advise you then to go to the official löve-android, you should be sure that you no longer have your problem.
APKTool is probably the fastest method but not necessarily more complicated or simpler than compiling from the repository I sent you. (Question of perspective)

Otherwise I only think about it now, maybe the problem comes from the version of Löve that you were using with APKTool? Maybe you could try again with the latest release before starting the full build for android? (because if you are missing Android Studio or some tools, it can take a long time to set up)

I will still try with the latest APK offered before compiling if it is not to be published.
https://github.com/love2d/love-android/ ... s/tag/11.4
My avatar code for the curious :D V1, V2, V3.
User avatar
nehu
Prole
Posts: 11
Joined: Fri Feb 25, 2022 1:12 am
Location: Argentina, Maybe under your bed

Re: Android Storage Permission [Solved]

Post by nehu »

Idk know why this worked but... :crazy:
I moved to love 11.4, used the embed apk from from https://github.com/love2d/love-android/ ... s/tag/11.4, used this manifest layout

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest package="insert.package.com"
      android:versionCode="7"
      android:versionName="0.0.6"
      android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="29"/>
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <!--Uncomment line below if your game uses microphone capabilities. !-->
    <!--uses-permission android:name="android.permission.RECORD_AUDIO" /!-->
    <uses-feature android:glEsVersion="0x00020000"/>
    <application
        android:allowBackup="true"
        android:icon="@drawable/love"
        android:label="label lol uwu xddd"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    >
        <activity
            android:configChanges="orientation|screenSize"
            android:label="coleccion de autos"
            android:launchMode="singleTask"
            android:name="org.love2d.android.GameActivity"
            android:screenOrientation="fullSensor"
        >
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <category android:name="tv.ouya.intent.category.GAME"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
            </intent-filter>
        </activity>
    </application>
</manifest>
and this apktool.yml

Code: Select all

!!brut.androlib.meta.MetaInfo
apkFileName: love-11.3-android-embed.apk
compressionType: false
doNotCompress:
- resources.arsc
- META-INF/androidx.activity_activity.version
- META-INF/androidx.appcompat_appcompat.version
- META-INF/androidx.arch.core_core-runtime.version
- META-INF/androidx.asynclayoutinflater_asynclayoutinflater.version
- META-INF/androidx.coordinatorlayout_coordinatorlayout.version
- META-INF/androidx.core_core.version
- META-INF/androidx.cursoradapter_cursoradapter.version
- META-INF/androidx.customview_customview.version
- META-INF/androidx.documentfile_documentfile.version
- META-INF/androidx.drawerlayout_drawerlayout.version
- META-INF/androidx.fragment_fragment.version
- META-INF/androidx.interpolator_interpolator.version
- META-INF/androidx.legacy_legacy-support-core-ui.version
- META-INF/androidx.legacy_legacy-support-core-utils.version
- META-INF/androidx.lifecycle_lifecycle-livedata-core.version
- META-INF/androidx.lifecycle_lifecycle-livedata.version
- META-INF/androidx.lifecycle_lifecycle-runtime.version
- META-INF/androidx.lifecycle_lifecycle-viewmodel.version
- META-INF/androidx.loader_loader.version
- META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version
- META-INF/androidx.print_print.version
- META-INF/androidx.slidingpanelayout_slidingpanelayout.version
- META-INF/androidx.swiperefreshlayout_swiperefreshlayout.version
- META-INF/androidx.vectordrawable_vectordrawable-animated.version
- META-INF/androidx.vectordrawable_vectordrawable.version
- META-INF/androidx.versionedparcelable_versionedparcelable.version
- META-INF/androidx.viewpager_viewpager.version
- png
isFrameworkApk: false
packageInfo:
  forcedPackageId: '127'
  renameManifestPackage: null
sdkInfo:
  minSdkVersion: '14'
  targetSdkVersion: '28'
sharedLibrary: false
sparseResources: false
unknownFiles:
  androidsupportmultidexversion.txt: '0'
usesFramework:
  ids:
  - 1
  tag: null
version: 2.7.0
versionInfo:
  versionCode: '28'
  versionName: '11.4'
and somehow everything works FINE! :cool:
i didn't manage to prompt the storage permission, but if you go to settings, you can give the storage permissions manually. This works on android 11 and android 13 :awesome:
i think the <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/> from manifest was the hero here. :o:
Thanks to Bigfoot71 for replying!!!! :ultrahappy:

Code: Select all

for i, v in pairs(problems) do
	fix(v)
end
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests