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:
- Decompile the apk file and in
res/values
find thepublic.xml
andids.xml
- Find all resources related to RemoteView in your app and copy them ( strings, dimen, drawable, layout, id, color... )
- Create
public.xml
andids.xml
underres/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)
}
}
}
}