Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExceptionInInitializerError on master in Android app #410

Closed
spyhunter99 opened this issue Mar 17, 2016 · 9 comments
Closed

ExceptionInInitializerError on master in Android app #410

spyhunter99 opened this issue Mar 17, 2016 · 9 comments

Comments

@spyhunter99
Copy link

As a result of the addition of OptionalSerializers and TimeSerializers, both of which target Java 1.8+, Kryo does not appear to work on Android when ProGuard is applied to the resultant application (APK). In order for ProGuard to even successfully complete, I had to add the following to the configuration (which is admittedly probably not the right thing to do):
-dontwarn java.time.*
-dontwarn java.util.*

Once on device, I get the following while creating a new Kryo

java.lang.ExceptionInInitializerError
at com.esotericsoftware.kryo.serializers.OptionalSerializers.addDefaultSerializers(OptionalSerializers.java:41)
at com.esotericsoftware.kryo.Kryo.(Kryo.java:219)
at com.esotericsoftware.kryo.Kryo.(Kryo.java:155)

@magro
Copy link
Collaborator

magro commented Mar 17, 2016

Not sure about ProGuard, I've never used it (and I've only played with Android several years ago). Maybe ProGuard would have to be run with jdk8, targeting whatever java/android version you want to support?

Re ExceptionInInitializerError: it seems that the java.version system property indicates java 8 - what's the exact value that's returned for java.version?
We could either fix this by checking if it's running on Android, or we could check if the relevant classes are available. I'm tending to the latter approach. WDYT?

In general, I'd really love to be able to test android compatibility (for some versions) in jenkins. How could that be done?

@spyhunter99
Copy link
Author

there's the maven-android plugin along with an instrumentation test. the jenkins slave will need the android sdk installed and the ability to run an emulator (headless if necessary). i may be able to whip up a test case for it

@spyhunter99
Copy link
Author

so this is going to may take some additional effort and some code isolation to separate the android test cases from the rest of the code base. in addition, those building from source would need the android sdk installed. not sure how you want to proceed

that said, i've been using kryo for a while on android and only ran into the the problem post 3.0.1 (probably post 3.0.3) without issue, aside from the lack of thread safety.

@spyhunter99
Copy link
Author

lastly, java.version, is not available as a system property or system environment variable. at least it's not on my device

@magro
Copy link
Collaborator

magro commented Mar 20, 2016

Re building with android sdk: mvn profiles might be helpful, or maybe running/building in docker.

Re java.version: interesting, I wasn't aware of this. Then we should check if the relevant classes are available.

magro added a commit that referenced this issue Mar 24, 2016
As reported in #410, on android java version detection via `java.version`
system property does not work - it's just not set.
Therefore we now check directly if the class is available as guard
for registering an optional default serializer.

Refs #410, #358, #360
@magro
Copy link
Collaborator

magro commented Mar 24, 2016

@spyhunter99 I've changed the guard, so that we now check if a class is available instead of checking the java version. Can you please test if it's now working for you?

@spyhunter99
Copy link
Author

ok i'll give it a shot

On Thu, Mar 24, 2016 at 5:07 PM, Martin Grotzke [email protected]
wrote:

@spyhunter99 https://github.com/spyhunter99 I've changed the guard, so
that we now check if a class is available instead of checking the java
version. Can you please test if it's now working for you?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#410 (comment)

@spyhunter99
Copy link
Author

Success! Here's the pro guard settings i used for future reference

#kryo
-keep class com.esotericsoftware.* {;}
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes
-keep class org.objectweb.
* {
;}

##java8 stuff that doesnt' exists in adk
-dontnote sun.misc.Unsafe
-dontwarn sun.misc.Unsafe
-dontwarn sun.misc.Cleaner
-dontnote java.beans.**
-dontnote java.util.OptionalDouble.**
-dontwarn java.time.**
-dontwarn sun.nio.ch.**
-dontwarn java.beans.**
-dontwarn java.util.Optional**

@magro
Copy link
Collaborator

magro commented Mar 28, 2016

Great that it's working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants