本文介绍了在Android中使用FreeMarker库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的项目中使用freemarker库,但是在初始化配置对象时遇到错误.

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.

曾经在Android中使用Freemarker的人可以帮忙吗?

Can someone having used Freemarker in Android please help?

推荐答案

问题:

尽管Freemarker正式不支持Android,但它为GAE发布了特殊的* .jars,以提供一些支持,许多其他Android解决方案也可以在其应用程序中成功使用Freemarker(呈现视图/代码,或者只是评估某些视图.表达式).

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).

原因:

此问题的根本原因是Freemarker将使用java.beans软件包中的一些内容,由于某些原因,这些内容未包含在Android核心库中.

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.

根据对Stackoverflow的回复(/questions/15065545/using-jars-that-use-java-beans-classes-introspector-beaninfo-or-propertydescri ),这是Android,为了完成任务,我们应该从源代码中分出所有第3方jar并重写它们,以使它们不使用java.beans.*类(可以通过将其替换为openbeans)."

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)."

解决方案:

找到可以替换的java.beans替代品,因此它可以在Android上使用.例如,可以是openbeansmad-robot.

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.

即使存在Freemarker的补丁程序,该补丁程序实际上也在其源代码中将java.beans更改为mad-robot bean-您可以找到该补丁程序和相关的线程此处.

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.

可能的解决方法:

  • 为Freemarker Android支持应用补丁
  • 使用openbeans.jar手动重新编译:code.google.com/p/openbeans/
  • 使用mad-robot bean手动重新编译:code.google.com/p/mad-robot/
  • 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/

这篇关于在Android中使用FreeMarker库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 18:41