Use freemarker library in android

自作多情 提交于 2020-01-04 03:33:05

问题


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 found this link. I have tried to apply patch given in above link but I could not apply it successfully.

Can someone having used Freemarker in Android please help?


回答1:


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/


来源:https://stackoverflow.com/questions/25929542/use-freemarker-library-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!