通知报错

https://stackoverflow.com/questions/25317659/how-to-fix-android-app-remoteserviceexception-bad-notification-posted-from-pac

 

In my app, this kind of bug happens only during upgrading. If the resource id changes in the newer version, Android RemoteView may fail to find the resource and throw out the RemoteServiceException. If you publish a 3rd version and do not change the resource id, the bugs may disappear only temporarily.

It is possible to reduce this kind of bugs by editing res/values/public.xml and res/values/ids.xml. Compiler will generate an individual resource id if the resource id is not in public.xml or ids.xml. When u change the resource name or add some new resources, the id may change and some devices may fail to find it. 

So the step is as following:

  1. Decompile the apk file and in res/values find the public.xml and ids.xml
  2. Find all resources related to RemoteView in your app and copy them ( strings, dimen, drawable, layout, id, color... )
  3. Create public.xml and ids.xml under res/values in your source code and paste the lines u just copied

Note:

Gradle 1.3.0 and above ignore the local public.xml. To make it work, u need to add some script in your build.gradle

afterEvaluate {
    for (variant in android.applicationVariants) {
        def scope = variant.getVariantData().getScope()
        String mergeTaskName = scope.getMergeResourcesTask().name
        def mergeTask = tasks.getByName(mergeTaskName)
        mergeTask.doLast {
            copy {
                int i=0
                from(android.sourceSets.main.res.srcDirs) {
                    include 'values/public.xml'
                    rename 'public.xml', (i == 0? "public.xml": "public_${i}.xml")
                    i++
                }
                into(mergeTask.outputDir)
            }
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值