Android 无法识别 Scala 活动

发布于 2024-11-01 00:51:36 字数 856 浏览 0 评论 0原文

我正在尝试在 Android 中使用 Scala,但清单无法识别我的主要/到目前为止的活动。

我根据这篇博客文章进行了设置: http://novoda.com /2009/10/17/scala-on-android/ 一切正常,直到我尝试运行我的应用程序,此时 logcat 说它找不到我的 Activity。关于这个问题我能找到的就是这样的: http ://tiliman.wordpress.com/2010/02/10/android-development-with-scala/。根据这篇文章,清单无法识别 Activity,因为它不是 Java 文件,因此他创建了一个从 Scala 扩展的 Java 类,我认为这根本不是一个好的解决方案。

我需要做什么才能开始?我想我没有遗漏任何东西。

根据之前提出的问题,似乎没有解决方案,我的意思是没有人提供解决方案。但我不敢相信使用像 sbt 这样的东西是在 Scala 中制作完整且实质性的 Android 应用程序的唯一方法。真的,根本没有解决办法吗?

更新:至于给出的答案,我会尝试一下SBT。但我仍然认为有必要采取更直接的方式来做到这一点。在我参加的一次 Google Dev Fest 上,Tim Bray 几乎说你可以用 Scala 或 Java 来制作 Android 应用程序,自然而然,没有任何问题:我不明白这与 Manifest 不识别 Scala 活动有何关系。

I'm trying to play with Scala in Android but the Manifest doesn't recognizes my main/only-so-far activity.

I did the set up according to this blog post: http://novoda.com/2009/10/17/scala-on-android/ and everything works until i try to run my app, moment in which the logcat saids that it just doesn't find my Activity. the thing is all i can found about this problem is this: http://tiliman.wordpress.com/2010/02/10/android-development-with-scala/. According to this post the manifest doesn't recognizes the Activity because it ain't a Java file, so he creates a Java class that extends from Scala, which i don't think is a good solution at all.

What do i have to do to get started? I think i'm not missing anything.

According to previously asked questions, there seems to be no solution, i mean no one provided one. But i can't believe that using something like sbt is the only way to make full and substantial Android apps in Scala. Truly, no solution at all?

UPDATE: As for the answer given, i'll give SBT a try. But i still think that is necessary a more straightforward way to do it. In a Google Dev Fest i attended, Tim Bray practically said that you could jut make Android apps in Scala or in Java, naturally and without problems: i don't see how this fits with Manifest doesn't recognizing a Scala activity.

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

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

发布评论

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

评论(2

琴流音 2024-11-08 00:51:36

您正在查看的页面相当旧。我建议使用 AndroidPlugin,它构建在 SBT 之上 (https://github.com/jberkel/android-plugin)。它处理构建、测试、部署到模拟器/设备等。

我已经用它构建了我的 Android 应用程序,而我唯一的 java 文件是自动生成的 R.java。

使用 SBT,您还可以生成 IDEA 和 Eclipse 配置,因此您应该可以开始使用了。

The page you're looking at is pretty old. I'd recommend using AndroidPlugin, which is built on top of SBT (https://github.com/jberkel/android-plugin). It handles building, testing, deploying to the emulator/device, etc.

I've got this building my android app, and the only java file I have is the autogenerated R.java.

With SBT you can also generate IDEA and Eclipse configurations, so you should be good to go.

红尘作伴 2024-11-08 00:51:36

这里发布的解决方案使用AndroidProguardScala插件,其中如果scala文件的名称与主活动的名称匹配,那么用scala编写主活动是没有问题的。

https://stackoverflow.com/a/11084146/1287856

The solution posted here uses the AndroidProguardScala plug-in, in which if the name of the scala file matches the name of the main activity, there is not problem to have your main activity written in scala.

https://stackoverflow.com/a/11084146/1287856

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文