Android 无法识别 Scala 活动
我正在尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在查看的页面相当旧。我建议使用 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.
这里发布的解决方案使用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