运行 sbt install-emulator 时出错

发布于 2024-12-08 17:07:58 字数 1349 浏览 1 评论 0原文

我正在关注此页面上的视频 http:// /zegoggl.es/2009/12/building-android-apps-in-scala-with-sbt.html 使用 SBT 创建 Android 项目。但是,我尝试使用安装模拟器

sbt install-emulator

,但出现以下错误:

    [info] Nothing to compile.
    [info]   Post-analysis: 1 classes.
    [info] == tests / compile ==
    [info]
    [info] == awesomepad / proguard ==
    ProGuard, version 4.4
    ProGuard is released under the GNU General Public License. The authors of all
    programs or plugins that link to it (sbt, ...) therefore
    must ensure that these programs carry the GNU General Public License as well.
    Reading program directory [C:\Projects\Scala\sbt2test\awesomepad\target\scala_2.
    9.1\classes]
    java.io.IOException: Can't read [proguard.ClassPathEntry@550a17fb] (Can't proces
    s class [com/kickass/awesomepad/R$attr.class] (Unsupported version number [51.0]
     for class format))
            at proguard.InputReader.readInput(InputReader.java:230)
            at proguard.InputReader.readInput(InputReader.java:200)
            at proguard.InputReader.readInput(InputReader.java:178)
            at proguard.InputReader.execute(InputReader.java:78)
            at proguard.ProGuard.readInput(ProGuard.java:195)

I am following the video on this page http://zegoggl.es/2009/12/building-android-apps-in-scala-with-sbt.html which use SBT to create an Android project. However I get to the point of trying to install the emulator using

sbt install-emulator

And I get the following error:

    [info] Nothing to compile.
    [info]   Post-analysis: 1 classes.
    [info] == tests / compile ==
    [info]
    [info] == awesomepad / proguard ==
    ProGuard, version 4.4
    ProGuard is released under the GNU General Public License. The authors of all
    programs or plugins that link to it (sbt, ...) therefore
    must ensure that these programs carry the GNU General Public License as well.
    Reading program directory [C:\Projects\Scala\sbt2test\awesomepad\target\scala_2.
    9.1\classes]
    java.io.IOException: Can't read [proguard.ClassPathEntry@550a17fb] (Can't proces
    s class [com/kickass/awesomepad/R$attr.class] (Unsupported version number [51.0]
     for class format))
            at proguard.InputReader.readInput(InputReader.java:230)
            at proguard.InputReader.readInput(InputReader.java:200)
            at proguard.InputReader.readInput(InputReader.java:178)
            at proguard.InputReader.execute(InputReader.java:78)
            at proguard.ProGuard.readInput(ProGuard.java:195)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

望喜 2024-12-15 17:07:58

我有同样的问题。我意识到这是因为我使用的是 JDK 1.7。虽然使用 1.6 创建的 jar 可在 1.7 上运行,但 1.6 jar 的 proguard 不适用于 1.7 jar。目前,Proguard 1.7 仅提供 Beta 版。因此,android 工具和 Maven 存储库具有适用于 1.6 jar 的 proguard。当它尝试修剪 1.7 jar 时,它会抛出该错误。

为了解决这个问题,我降级到 JDK 1.6,卸载了 1.7,并确保我的 jar 是由 1.6 JDK 工具创建的。

为了从本地存储库中删除 1.7 jar,我刚刚删除了 ~/.ivy2 下的目录并使用该插件重新创建了 android 项目。我只是按照 Android 插件的自述文件进行操作。

I had the same issue. I realized it was because I was using JDK 1.7. Though jars created with 1.6 work on 1.7, proguard for 1.6 jars does not work with 1.7 jars. Currently, only beta releases of Proguard are available for 1.7. So, android tools and maven repositories have proguard for 1.6 jars. When it tries to trim 1.7 jars, it throws that error.

To solve this problem, I downgraded to JDK 1.6, uninstalled 1.7 and made sure my jars are created by 1.6 JDK tools.

To remove 1.7 jars from local repository, I just deleted the directories under ~/.ivy2 and re-created the android project using the plugin. And I just followed the README for the android plugin to the tee.

不必了 2024-12-15 17:07:58

正如您链接到的页面所说,“注意:本文已经有一段时间没有更新并且已经过时。如有疑问,请参阅 sbt-android-plugin 的自述文件。”那里的自述文件(README.md)包含唯一的一组我已经找到了实际适用于当前版本的 scala、sbt 和 Android SDK 的说明。

我只需要做一些小的调整就可以让它工作:

  1. 修改你的 sbt 脚本(可能是 ~/bin/sbt)并添加一个“-XX:MaxPermSize=512m”参数,否则你会用完 PermGen 空间
  2. 确保使用0.10 模板(默认)而不是您可以选择指定的 0.11 模板。
  3. 确保在提示时跳至“插件破解”部分。

希望这有帮助。

As the page that you link to says, "Note: this article hasn't been updated in a while and is out of date. In doubt refer to the README of the sbt-android-plugin." The readme there (README.md) contains the only set of instructions that I have been able to find that actually works with current versions of scala, sbt, and the Android SDK.

I had to make only minor tweaks to get it to work:

  1. Modify your sbt script (probably ~/bin/sbt) and add a "-XX:MaxPermSize=512m" parameter, otherwise you run out of PermGen space
  2. Make sure to use the 0.10 template (the default) instead of the 0.11 one that you can optionally specify.
  3. Make sure that you skip down to the "Hacking on the plugin" section when it tells you to.

Hope this helps.

蘑菇王子 2024-12-15 17:07:58

对我来说,插件网站上的描述就足够了:链接

你尝试过这样做吗?

For me, the description on the plugins site was sufficient: link.

Have you tried to do it that way?

好多鱼好多余 2024-12-15 17:07:58

因为显然jdk1.7不兼容,我也遇到了同样的问题。
在我的 build.scala 文件中,我添加了以下行:

javaHome := Some(file("c:\\Program Files\\Java\\jdk1.6.0_35"))

然后它就起作用了。

Because apparently the jdk1.7 is not compatible, I had the same problem.
In my build.scala file, I added the following line:

javaHome := Some(file("c:\\Program Files\\Java\\jdk1.6.0_35"))

and then it worked.

人心善变 2024-12-15 17:07:58

我收到错误“(类格式不支持的版本号 [51.0])”,java 版本为“1.7.0_51”。

通过向 Build.scala 添加 javac 兼容性行修复了此问题:

val settings = Defaults.defaultSettings ++ Seq (
  ...
  javacOptions ++= Seq("-encoding", "UTF-8", "-source", "1.6", "-target", "1.6")
)

I've obtained error "(unsupported version number [51.0] for class format)" with java version "1.7.0_51".

This issue fixed by adding javac compatibility line to Build.scala:

val settings = Defaults.defaultSettings ++ Seq (
  ...
  javacOptions ++= Seq("-encoding", "UTF-8", "-source", "1.6", "-target", "1.6")
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文