Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal Exception: java.lang.SecurityException: Missing permission to insert badges

I am new in Android development, I am facing below exception on some of the device after publishing it on play store. It is completly unknown exception for me. This exception force stop/crash my application.

Complete stacktrace logged:

Exception java.lang.SecurityException: Missing permission to insert badges
android.os.Parcel.readException (Parcel.java:1553)
android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:185)
android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:137)
android.content.ContentProviderProxy.insert (ContentProviderProxy.java:476)
android.content.ContentResolver.insert (ContentResolver.java:1213)
android.content.AsyncQueryHandler$WorkerHandler.handleMessage (AsyncQueryHandler.java:96)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:211)
android.os.HandlerThread.run (HandlerThread.java:61)

As mentioned above exception dose not contains any part of code that relate to my application, and also I am not found any satisfactory solution for above issue.

EDIT: I am using an external library(SDK) for push notification, after adding that my App start showing 11 new permission on play store 'Required permission' section when I am going to update my app

Some of those permissions are:

    com.htc.launcher.permission.READ_SETTINGS
    com.htc.launcher.permission.UPDATE_SHORTCUT
    com.huawei.android.launcher.permission.CHANGE_BADGE
    com.huawei.android.launcher.permission.READ_SETTINGS
    com.huawei.launcher.permission.WRITE_SETTINGS
    com.sec.android.provider.badge.permission.READ
    com.sec.android.provider.badge.permission.WRITE
    com.sonyericsson.home.permission.BROADCAST_BADGE
    com.sonymobile.home.permission.PROVIDE_INSERT_BADGE

I am not added these permission in my own manifest file, So that I modified my 'AndroidManifest' file by adding following line of code into application tag:

<application
     <--some code-->
    tools:replace="android:icon, android:allowBackup"
    >

and use a .jar file of SDK instead of compile it like

compile 'com.abc.xyz:3.+@aar' //suggested for android studio in (build.gradle)

After applying above process those permission are removed and I upload my Application.

Only These thing I have performed into my new version of app. I also looked that library project recentally and it contains a folder 'shortcutbadger' that contains some sub-folder and .class file internally

Is due to above changes I am start receiving that exception ? please explain/help!

like image 430
Ankit Kumar Singh Avatar asked Feb 07 '23 06:02

Ankit Kumar Singh


1 Answers

As you said, you can change a gradle dependency with a Jar of the same SDK. But when using Jar, you should make sure all the permissions are added appropriately in manifest in order to make the SDK work properly.

The OneSignal SDK which you have used recommends gradle dependency for Android Studio & Jar file with additional permissions in Manifest for Eclipse. Since you replaced gradle with Jar in Studio, make sure you have the following permissions added to manifest file.

<permission android:name="${manifestApplicationId}.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
<uses-permission android:name="${manifestApplicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<!-- START: ShortcutBadger -->
<!-- Samsung -->
<uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>

<!-- HTC -->
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT"/>

<!-- Sony -->
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>
<uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE"/>

<!-- Apex -->
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>

<!-- Solid -->
<uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>

<!-- Huawei -->
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" />
<uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS" />
<!-- End: ShortcutBadger -->
like image 148
sJy Avatar answered Feb 13 '23 05:02

sJy