Eclipse中的Andr​​oid,斯卡拉取得容易,但仍然无法正常工作无法正常、斯卡、容易、工作

2023-09-12 01:26:35 作者:太拽无法显示

最近我跟着编程的方式为Android使用Scala和Eclipse ,从而降低了code和编译时不使用Proguard的或Treeshake。

I recently followed a way of programming for Android using Scala and Eclipse, which reduces the code and the compile time without using Proguard or Treeshake.

以下这篇文章,我应该能够利用最后的Eclipse版本(3.7),斯卡拉几乎是最后一个版本(2.8.1)更新模拟器版本10,2.8.3版本在Eclipse的插件提供研究。

Following this article, I should be able use the last Eclipse build (3.7), almost the last version of Scala (2.8.1) updated on an emulator version 10, the version 2.8.3 within Eclipse with the provided plug-in.

在presented方式是提供一个具体的ramdisk映像的版本,在这里我们可以上传斯卡拉库,从而大大缩小的code尺寸上传到模拟器。

The presented way is to provide a specific ramdisk image version, where we can upload scala libraries, which drastically shrinks the size of the code to upload to the emulator.

我遵循的步骤,创建一个Hello World,添加斯卡拉自然,增加了一个虚拟的Scala类,移动之前的Andr​​oid包安装斯卡拉建设者,一切都建立完美的,但是当我启动的apk上的模拟器在Eclipse中,应用程序崩溃,我得到了下面的错误,它看起来像 一样在这里psented (在文件的结尾)$ P $

I followed the steps, created a hello world, added scala nature, added a dummy scala class, moved the Scala builder before the Android Package Installer, everything builds perfectly, but when I launch the apk on a emulator from Eclipse, the application crashes and I get the following error, which looks like the same as presented here (at the end of the document) :

    03-29 10:29:38.505: E/AndroidRuntime(839): java.lang.NoClassDefFoundError: upg.TestSinceInstallation.ComputeSum

如果我删除了活动文件中的斯卡拉参考,运行良好。

If I remove the scala reference in the activity file, it runs well.

下面是TestSinceInstallation.java文件:

Here is the TestSinceInstallation.java file:

    package upg.TestSinceInstallation;

    import android.app.Activity;
    import android.os.Bundle;
    import upg.TestSinceInstallation.ComputeSum;

    public class TestSinceInstallationActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            int a = 1;
            int b = 5;
            ComputeSum cs = new ComputeSum(a, b);
            if(cs.getResut() == 6) {
              setContentView(R.layout.main);
            }
        }
    }

和这里的ComputeSum.scala文件

and here is the ComputeSum.scala file

    package upg.TestSinceInstallation

    class ComputeSum(a: Int, b: Int) {
      def getResut() : Int = a + b
    }

你觉得我应该做的,使这项工作?我觉得自己如此接近的目标。

What do you think I should do to make this work ? I feel so close to the goal.

推荐答案

下面是解决方案,使用Android使用的的Eclipse 3.7 ,并使用Scala 3.0.0没有任何问题。

Here is the solution, to use Android with Eclipse 3.7 and with Scala 3.0.0 without any problems.

在安装的Eclipse 3.7 (对我来说3.7.2)和< A HREF =htt​​p://developer.android.com/sdk/index.html#ExistingIDE> Android SDK中 - 加的