Android Marshmallow, api 23, permissions broken on a Cordova application
<p>I inherited a Cordova hybrid application with an error in its manifest file. The targetSdkVersion is set to 24 which, as far as I am concerned doesn't exists yet.</p>

<p>The app wasn't tested on an Android 6 device so it was uploaded to Play Store with that error. Since the permission model on Android 6 has changed the app crashes on those devices.</p>

<pre><code>03-12 21:10:05.991  24366-24475/? E/PluginManager﹕ Uncaught exception from plugin
    java.lang.SecurityException: getDeviceId: Neither user 10111 nor current process has android.permission.READ_PHONE_STATE.
            at android.os.Parcel.readException(Parcel.java:1620)
            at android.os.Parcel.readException(Parcel.java:1573)
            at com.android.internal.telephony.ITelephony$Stub$Proxy.getDeviceId(ITelephony.java:4207)
            at android.telephony.TelephonyManager.getDeviceId(TelephonyManager.java:706)
            at org.pgsqlite.SQLitePlugin.getAppKey(SQLitePlugin.java:783)
            at org.pgsqlite.SQLitePlugin.executeSqlBatch(SQLitePlugin.java:347)
            at org.pgsqlite.SQLitePlugin.executeAndPossiblyThrow(SQLitePlugin.java:195)
            at org.pgsqlite.SQLitePlugin.execute(SQLitePlugin.java:93)
            at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:95)
            at org.apache.cordova.PluginManager.exec(PluginManager.java:130)
            at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
            at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
            at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
            at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:39)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
</code></pre>

<p>Thanks to this blog I found that if I change the targetSdkVersion to 22 the app works as before
<a href="http://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en" rel="nofollow">http://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en</a></p>

<p>And the documentation shows how to ask for permissions at run time:
<a href="http://developer.android.com/intl/es/training/permissions/requesting.html" rel="nofollow">http://developer.android.com/intl/es/training/permissions/requesting.html</a></p>

<p>I have several questions regarding this issue.</p>

<ol>
<li>If I downgrade the targetSdkVersion to 22 (or 23 for that matter) and upload the app to Play Store, would the app update if I increase the version? I don't really know what would happen.</li>
<li>How should I work with permissions on Android Marshmallow on a cordova App? Should I ask for permissions int the activity overriding the default one created by Cordova after installation?</li>
<li>Are there any other ideas to solve this issue?</li>
</ol>

<p>Here is my manifest.xml file.</p>

<pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
&lt;manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0" android:windowSoftInputMode="adjustResize" package="com.myorg.myapp" xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /&gt;
    &lt;uses-sdk android:minSdkVersion="14" android:targetSdkVersion="24" /&gt;
    &lt;application android:allowBackup="true" android:icon="@drawable/icon" android:label="@string/app_name"&gt;
       &lt;blablabla /&gt;
    &lt;/application&gt;
    &lt;uses-permission android:name="android.permission.READ_CALENDAR" /&gt;
    &lt;uses-permission android:name="android.permission.WRITE_CALENDAR" /&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
    &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
    &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
    &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
    &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /&gt;
    &lt;uses-feature android:glEsVersion="0x00020000" android:required="true" /&gt;
    &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
    &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt;
    &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
&lt;/manifest&gt;
</code></pre>