Important: Please read the Qt Code of Conduct -

Android “gps requires ACCESS_FINE_LOCATION” error

  • As of Android API 23, there is a new way to request location permissions. It doesn't look like QT5.6 beta has been updated to use this method, so I wrote a quick work around. This API 23 change might affect the camera and contacts permissions also, I'm not sure.

    Before anyone says, I already have the fine location permission in my manifest:
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    Inside your android project, create a template. In the manifest, change:

    Create the path inside your android template directory:

    Now create the extended activity which requests the permissions as follows:

    public class MyActivity
      extends QtActivity
      private static final String[] LOCATION_PERMS={
      private static final int LOCATION_REQUEST = 1337;
      public void onCreate(Bundle savedInstanceState) 
          //Ensure we can run the app
        if ( !canAccessLocation() ) 
          requestPermissions( LOCATION_PERMS, LOCATION_REQUEST );
      public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) 
          //Figure out what was given to us
          case LOCATION_REQUEST:
            if ( canAccessLocation() ) 
              log("Access to location is granted");
              log("Access to location is denied");
      private boolean hasPermission(String perm) 
        return ( PackageManager.PERMISSION_GRANTED == checkSelfPermission(perm) );
      public boolean canAccessLocation() 
        return hasPermission(Manifest.permission.ACCESS_FINE_LOCATION);
      public static void log( String s )
        Log.d("Radius", s );

    This "fix" was taken from the following post:

  • Lifetime Qt Champion


    Thanks for sharing your findings. You should also bring that to the Qt Android development mailing list. You'll find there Qt's Android port developers/maintainers. This forum is more user oriented.

  • Thanks for the tip, I'll do that. I'm interested to get in touch with those guys anyway to extend the default implementation of the QML Map library.

  • Lifetime Qt Champion

    You're welcome !

    Extend it Android wise or globally ?

  • I guess I'll have to see once I get in there. Ideally it would be global.

    I'd like to get two finger rotation logic implemented. Also I'd like to change how the zoom works; instead of showing the user a gray square while zooming, I'd rather zoom the best fit tile.

Log in to reply