0
votes

I am submitting an updated version of my app (sdk 23) on the Play Store and is giving this error of the permissions when having to publish the section in the Beta Tester.

I've done the changes with requestPermission for sdk 23:

if (Utils.isMarshmallow()) {
    if (ContextCompat.checkSelfPermission(activity, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
                ContextCompat.checkSelfPermission(activity, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

            ActivityCompat.requestPermissions(activity, new String[] {android.Manifest.permission.ACCESS_COARSE_LOCATION},
                    Utils.MY_PERMISSION_ACCESS_COARSE_LOCATION);
    }
}

But to contemplate devices with Android sdk < 23 my manifest looks like this:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> `

My build.gradle is:

android {
    compileSdkVersion 23 
    buildToolsVersion "23.0.3"
    defaultConfig {
        applicationId "br.com.app.vertz"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 36
        versionName "2.8"
    }
...

Still getting the error message:

It is not possible to downgrade devices that previously used the M permissions (SDK 23 and above) to APKs using the old-style permissions (SDK 22 and lower). This occurs in changing the version 32 (23 SDK) for version 29 (SDK 19).

2

2 Answers

2
votes

You need to ask runtime permission for WRITE_EXTERNAL_STORAGE also

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

//declare permissions and request code

private static final String[] REQUEST_PERMISSIONS = new String[]{
            Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION
    };
    private static final int REQUEST_PERMISSION_CODE = 007;

//check if permissions are needed

       if (!checkPermission()) {
            requestPermission();
        } else {
//perform your task      
  }



private boolean checkPermission () {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
                return true;
            }
            for (String permission : REQUEST_PERMISSIONS) {
                if (ActivityCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {
                    return false;
                }
            }


            return true;
        }
    private void requestPermission () {
        ActivityCompat.requestPermissions(this, REQUEST_PERMISSIONS, REQUEST_PERMISSION_CODE);
    }

    @Override
    public void onRequestPermissionsResult ( int requestCode, @NonNull String[] permissions,
    @NonNull int[] grantResults){
        if (requestCode == REQUEST_PERMISSION_CODE) {
            if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                //perform your task
            }
        }
    }
1
votes

targetSdkVersion in your manifest and/or build.gradle should be 23 or greater.