The error is that java.version returns 0 in Android (see the "System Properties" section here - Comparing Java and Android APIs )
Also, if you are observing ByteBuddy ClassFileVersion
forCurrentJavaVersion () : this method checks for a versionString that should return any valid Java / JDK else version
throws IllegalStateException("This JVM version string does not seem to be valid: " + versionString);
& since java.version returns 0 , it throws an IllegalStateException .
Try writing this value:
String versionString = System.getProperty(JAVA_VERSION_PROPERTY); Log.d(TAG, versionString);
Therefore, a workaround for this problem is to add
System.setProperty(JAVA_VERSION_PROPERTY, "1.7.0_79");
before calling
ByteBuddy test = new ByteBuddy();
where JAVA_VERSION_PROPERTY is declared as:
private static final String JAVA_VERSION_PROPERTY = "java.version";
The dependency is also used:
<dependency> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy</artifactId> <version>0.7.7</version> </dependency>
If you are using a studio, you can add
compile 'net.bytebuddy:byte-buddy:0.7.7'
into your build.gradle application.
Hope this helps solve your problem.