Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid, scala and eclipse = unstable blend
    primarykey
    data
    text
    <p>Recently, I've written some Android app in scala, working with Eclipse. Everything was okay until my program had only several classes / activities. When I added more code, JVM started to crash, eclipse often freezed and adb constantly lost connection. Task manager showed that Java process was taking from 800 up to 1300 MB memory!</p> <p>My computer's hardware parameters are quite nice like i7 3rd gen, 8GB DDR3 and SSD 256. So it's not the reason.</p> <p>Also my software is up to date and consits of the newest version of Eclipse, Android SDK, Scala and Java development kit, all plugins for eclipse. -vmargs are configured for scala development but it didn't help at all. So I eliminated it to as a cause of problem.</p> <p>When I rewrite my code to Java everythig goes excellent and I can go on with my project.</p> <p>Has anyone find already some solution for working with scala in Android project? I read a couple of similar topics here and on google groups but there was no answer on this question.</p> <p><strong>EDIT:</strong></p> <p>I profiled my code with visual vm, but heap space usage was normal. Here's some snippet of my code.</p> <pre><code>imports ... class MainActivity extends FragmentActivity { private lazy val timePicker = findViewById(R.id.timePicker).asInstanceOf[TimePicker] private lazy val spinner_sourceBank = findViewById(R.id.spinnerSource).asInstanceOf[Spinner] private lazy val spinner_targetBank = findViewById(R.id.spinnerDestination).asInstanceOf[Spinner] private lazy val myApplication = getApplication.asInstanceOf[MyApplication] private var ignoreTimeChange = false override protected def onCreate(savedInstanceState: Bundle) = { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) timePicker.setIs24HourView(true) initializeSpinner(spinner_sourceBank) initializeSpinner(spinner_targetBank) } private def initializeSpinner(spinner: Spinner) = { val adapter = ArrayAdapter.createFromResource(this, R.array.banks, R.layout.spinner_item) adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) spinner.setAdapter(adapter) } def reset(w: View) = { timePicker.setCurrentHour(13) timePicker.setCurrentMinute(00) spinner_sourceBank.setSelection(0) spinner_targetBank.setSelection(0) } def submit(w: View) = { if (spinner_sourceBank.getSelectedItemPosition == 0 || spinner_targetBank.getSelectedItemPosition == 0) { new AlertDialog.Builder(this).setPositiveButton("OK", new OnClickListener { override def onClick(dialog: DialogInterface, which: Int) { dialog dismiss } }).setMessage(getString(R.string.alert_title)).setTitle("Alert Dialog").setIcon(android.R.drawable.ic_dialog_alert).create.show } else manageFragments(sourceBank, targetBank) } def manageFragments(sourceBank: String, targetBank: String) = { val fragmentTransaction = getSupportFragmentManager.beginTransaction if (targetBank == sourceBank) myApplication.setCurrentFragment(MyApplication.NOW) else myApplication.setCurrentFragment(MyApplication.FIRST_SESSION) fragmentTransaction.replace(R.id.fragment_container, myApplication.getCurrentFragment) fragmentTransaction.commit } override def onCreateOptionsMenu(menu: Menu): Boolean = { getMenuInflater.inflate(R.menu.activity_main, menu); true } } </code></pre> <p>I could test my application on mobile device and it ran pretty well. I also could write my code, but eclipse behaved like ran on old computer - switching tabs took a lot of time and so building and deploying.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload