I'm developing a little sdk that has to be included in projects via .aar file. In this sdk I have a method defined like below:

/**
     * Sends an "open lock" request for the bike, with the ble name provided as param. Requires ACCESS_FINE_LOCATION and
     * BLUETOOTH permission
     *
     * @param bikeBleName The BLE name of the searched bike, normally starts with 'BS' prefix
     * @param listener   Listener for the operation state, returns success or an error string with the detailed error

     */
    @RequiresPermission(allOf = [Manifest.permission.BLUETOOTH, Manifest.permission.ACCESS_FINE_LOCATION])
    override fun startRent(bikeBleName: String, bikeMode: BikeMode, listener: StartRentListener) {
        GlobalScope.launch {
            startRentManager.startRent(bikeBleName, bikeMode, listener)
        }
    }

As you can see, the method is annotated with @RequiresPermission(allOf = [Manifest.permission.BLUETOOTH, Manifest.permission.ACCESS_FINE_LOCATION]), however, if I call the method from my project MainActivity, Android Studio tells me that the method requires a permission check, but it doesn't tell me which permissions are required. What I would like to obtain is Android Studio telling me "this method requires ACCESS_FINE_LOCATION and BLUETOOTH permissions", something similar to the screenshot below. How can I achieve that? Thanks

enter image description here

The manifest file of the library module is:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="it.zehus.bikeaccesssdk">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>
</manifest>
Answer

Problem was that I placed

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="it.zehus.bikeaccesssdk">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>
</manifest>

in the library module. I removed the permissions from the library manifest and now Android Studio is providing the correct hint.

  • 1
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions