2

I have an issue which I'm pretty sure is related to multidex. Basically one of the libraries I use has a .properties resource bundle in a jar. As my application started growing I started having issues with it. I've made a couple of posts about it in the past but never had any solutions (post 1, post 2). Post 2 actually has a lot more details about the issue.

Basically this resource is missing unless I force some of the code on that Jar to run on the Application onCreate method. At least that was the issue until yesterday.

enter image description here

Yesterday I update a jar that has nothing to do with this but is now larger than it used to be (which I'm assuming means it has more methods), and now the code fails again on this same issue java.util.MissingResourceException: Can't find bundle for base name javax.servlet.LocalStrings, locale en_US but now it fails for everyone, not just some users.

I took apart the apks using apktool for one that works and one that doesn't (basically downgrading those unrelated jars) and there is an unknown folder in both apks but the one that works has those LocalStrings.properties in that folder and the one that doesn't work doesn't have them in that folder. I have unzipped those unrelated jars just to make sure and they don't have that javax.servlet package in there and they are jars so they don't have anything else that might affect the gradle build.

Basically my theory right now is that those jars are just large enough to push the javax.servlet stuff out of the first dex file, but that isn't entirely right because the properties files don't even go in the dex file. If I just unzip the apk, I can see the javax package on the root folder and the resource files inside the right place but not LocalStrings.properties whereas if I do that for an apk that works, I can see LocalStrings.properties in there.

Right now I've been testing multiDexKeepProguard and I got all javax.servlet to go in the main dex file but I still can't get LocalStrings.properties to show up in the apk, even with:

-keepclassmembers class **$Properties

I've also tried a few other crazy things like putting the LocalStrings.properties files inside my main app package using the javax.servlet package and it didn't help either.

So what else can I try? Is this a bug or am I doing something wrong?

Thanks.

Edit: I would like to report that I've once again gotten past this issue by removing a dependency (an ad network) that I'm no longer using. I realized I still had that dependency when I used dex2smali to look at the first dex file and saw it was there. So it definitely appears to be an issue with the size of the jars it puts on the first dex file.

Edit: I have this on my proguard settings:

-keep class javax.** {*;}
-keep interface javax.** {*;}
-keepclassmembers class javax.** {*;}
-keepclassmembers class **$Properties
casolorz
  • 8,486
  • 19
  • 93
  • 200

2 Answers2

1

Not sure if this was the right way to do it, but apparently proguard was mistakenly deleting the *.properties files for me.

What fixed it was doing a build with

minifyEnabled false

and then going back to

minifyEnabled true

After that, the *.properties files were all available in the final build again.

joaomgcd
  • 5,287
  • 4
  • 28
  • 39
0

It looks like your package property file is stripped by ProGuard. I am not sure whether you have tried below configurations

-keep class javax.servlet.** 

or

-keep class javax.servlet.** { *; }

or

-optimizations !javax.servlet
-dontoptimize

Also, more additional references:

shizhen
  • 12,251
  • 9
  • 52
  • 88
  • Thanks. I do have those on proguard, only things I don't have are `-optimizations !javax.servlet` and `-dontoptimize`, I'm guessing I want it to optimize so I hope that isn't the problem. I will test those as soon as I can reproduce the issue. Yesterday I removed an ad network and that fixed the issue, well today readding it and doing everything the same still isn't reproducing the issue, I even went back on git and checked out the old commits and still not reproducing it. Also I did want to add that whether those things fix it or not, this works most of the time without those two things. – casolorz Oct 12 '18 at 16:44