Use freemarker library in android

后端 未结 1 2009
一向
一向 2021-01-20 19:32

I am trying to use freemarker library into my project but I am getting error while initializing Configuration object.

I further investigated the the issue and I foun

相关标签:
1条回答
  • 2021-01-20 19:45

    Problem:

    Although Freemarker officially does not support Android, it published special *.jars for GAE to provide some support, and a lot of other Android solutions could successfully use Freemarker in their application (either rendering view/code, or just to evaluate some expressions).

    Cause:

    The root cause of the issue is that Freemarker would use a few things from java.beans package which is for some reason not included in Android core libraries.

    According to a reply on Stackoverflow (/questions/15065545/using-jars-that-use-java-beans-classes-introspector-beaninfo-or-propertydescri), this is a disadvantage of Android, and to accomplish the task, we should “fork all 3th party jars from source and rewrite them so they don't use java.beans.* classes (possibly by replacing them for openbeans).”

    Solution:

    Find a substitution for java.beans, which can be changed, so it would work on Android. It can be openbeans, or mad-robot for example.

    Even there is a patch existing for Freemarker, which is basically changing java.beans to mad-robot beans in its source code - you can find the patch and the related thread here.

    Possible workarounds:

    • Applying the patch for Freemarker Android support
    • Manually recompiling with openbeans.jar: code.google.com/p/openbeans/
    • Manually recompiling with mad-robot beans: code.google.com/p/mad-robot/
    0 讨论(0)
提交回复
热议问题