plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

Geolocation permissions to recognized in AndroidManifest.xml

Open mike-lloyd03 opened this issue 5 months ago • 4 comments

I've followed the installation instructions but cannot get the geolocation plugin to work. After installing with:

pnpm add @tauri-apps/plugin-geolocation

My AndroidManifest.xml file was not updated. I manually added the necessary permissions.

src-tauri/gen/android/app/src/main/AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
...

I have this in the layout.svelte file in my SvelteKit app:

    onMount(async () => {
        let permissions = await checkPermissions();
        if (permissions.location === "prompt" || permissions.location === "prompt-with-rationale") {
            permissions = await requestPermissions(["location"]);
        }
        console.log(JSON.stringify(permissions));
    });

However, upon running the app, I get this error:

Uncaught (in promise) Missing the following permissions in AndroidManifest.xml:
    android.permission.ACCESS_FINE_LOCATION
    android.permission.ACCESS_COARSE_LOCATION

What am I missing?

mike-lloyd03 avatar Jul 01 '25 23:07 mike-lloyd03

I tried restarting the dev server and I started getting this content for the permissions object:

{"location":"denied","coarseLocation":"denied"}

But now I'm getting the previous error again ("Missing the following permissions..."). Nothing changed in my AndroidManifest.xml.

mike-lloyd03 avatar Jul 02 '25 00:07 mike-lloyd03

The permissions error appears both on an emulated device and a physical device.

mike-lloyd03 avatar Jul 02 '25 00:07 mike-lloyd03

My AndroidManifest.xml file was not updated. I manually added the necessary permissions.

The file you're seeing won't be updated. The android build tools will merge the plugin's manifest with your main one at build time. The wording in the readme is a bit confusing which is my bad.

After installing with: pnpm add @tauri-apps/plugin-geolocation

This is only the JS package, what else did you did? (i assume you did more, otherwise you should get some "plugin not found error i think)

FabianLars avatar Jul 02 '25 11:07 FabianLars

I followed the install instructions in the readme. I think this is everything

cargo add tauri-plugin-geolocation

lib.rs

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_geolocation::init())
...

capabilities/default.json

	"permissions": [
		"core:default",
		"opener:default",
		"blec:default",
		"log:default",
		"geolocation:allow-check-permissions",
		"geolocation:allow-request-permissions",
		"geolocation:allow-get-current-position"
	]

mike-lloyd03 avatar Jul 03 '25 05:07 mike-lloyd03