简体   繁体   中英

Missing java.beans.Introspector in Spring LibGDX Android application

I'm trying to run LibGDX based Android application, which is built with Spring Framework (not Spring for Android, but plain Spring). There is an exception:

ClassNotFoundException: Didn't find class "java.beans.Introspector"

As far as I know Android runtime does not have fully-featured java.beans package as on regular JRE.

Is there any workaround for this issue (probably some 3d-party jar with missing classes)?

I can't change package name, because AnnotationBeanNameGenerator class that using this Introspector is a part of Spring-Context.

As it finally appears, normal Spring (not Spring for Android) could not be run on Android, because it uses CGLIB. CGLIB can only manipulate Java byte code, but on Android there is a special Dalvik byte code.

Issue with missing java.beans classes could be fixed by manual adding such classes (you can use some open source JRE implementation like Apache Harmony ) and passing --core-library option to dex.

How to pass --core-library option:

put following into android section of Gradle Android plugin configuration:

dexOptions {
    preDexLibraries = false
}

and add new parameter:

tasks.withType(com.android.build.gradle.tasks.Dex) {
    additionalParameters=['--core-library']
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM