Grafting Scala compiler into a NBAndroid project....What steps am I missing?

  2 posts   Feedicon  
Replies: 1 - Last Post: April 11, 2010 16:22
by: mwkohout
showing 1 - 2 of 2
 
Posted: April 11, 2010 16:19 by mwkohout
Hi All;

Due to Apple's recent T+C hijinks, I've become interested in developing for Android.

Anyways, I'm trying to get a mixed-language Android project going in Netbeans. The two languages being Java and Scala(2.8 head build). To get this to work, I've modified the projects's build.xml file:

<target name="-pre-compile">
	  <property name="scala-home" value="/Users/development/Applications/scala-2.8.0/build/pack"/>
	  <property name="scala-library" value="/Users/development/Applications/scala-2.8.0/build/pack/lib/scala-library.jar"/>
	  <echo message="scala-library = ${scala-library}"/>
	  <echo message="scala-home = ${scala-home}"/>
	  <path id="build.classpath">
	    <pathelement location="${scala-library}"   />
	    <!--<pathelement location="${your.path}"   />-->
	    <pathelement location="${build.classes.dir}"   />
	  </path>
	  <taskdef resource="scala/tools/ant/antlib.xml">
	    <classpath>
	      <pathelement location="${scala.home}/lib/scala-compiler.jar"   />
	      <pathelement location="${scala-library}"   />
	      <pathelement location="${javac.classpath}" /> 
	    </classpath>
	  </taskdef>
	  <scalac srcdir="${src.ScalaSource.dir}" destdir="${build.classes.dir}" >
	     <classpath>
	      <pathelement location="/Users/development/Documents/AndroidTest/scala-library.jar"   />
	      <pathelement location = "${scala-library}" />
	      <pathelement location = "${file.reference.android.jar}" />
	      <pathelement path="${javac.classpath}" /> 
	    </classpath>
	  </scalac>
	  <echo message="file.reference.android.jar: ${file.reference.android.jar}"/>
	  <echo message="file.reference.scala-library.jar: ${file.reference.scala-library.jar}"/>
	</target>


I've gotten the project so that it'll build, but it errors on startup in my Android Emulator(inside the emulator, Android tells me my application has stopped unexpectedly). I suspected that it was because it's not including scala-library.jar and scala-compiler.jar so I included them as external jar references in my netbeans project but it still failed.

So my questions are: Does anyone see what I may be doing wrong? And is there any way to get access to the logs that the emulator must create?

thanks
Mike Kohout

FYI, I've uploaded my project to http://philosophicalsoftware.com/AndroidTest.zip. All the file references will be wrong, but it still might be helpful.
 
Posted: April 11, 2010 16:22 by mwkohout
Also, I'm doing this with Netbeans 6.8 and nbandroid v0.10, for Android 2.1

I've updated the script to include Proguard. I'm also pretty sure that the SDK's dx tool is now including my required jars. Still same error, though.

here's my Netbeans build script customizations(in projectRoot/build.xml)
	<target name="-pre-compile" depends="init">
	  <property name="scala-home" value="/Users/development/Applications/scala-2.8.0/build/pack"/>
	  <property name="scala-library" value="/Users/development/Applications/scala-2.8.0/build/pack/lib/scala-library.jar"/>
	  <echo message="scala-library = ${scala-library}"/>
	  <echo message="scala-home = ${scala-home}"/>
	  <echo message="platform.bootcp = ${platform.bootcp}"/>
	  <echo message="dist.apk.dir = ${dist.apk.dir}"/>
	  <echo message="build.classes.dir = ${build.classes.dir}"/>
	  <path id="build.classpath">
	    <pathelement location="${scala-library}"   />
	    <!--<pathelement location="${your.path}"   />-->
	    <pathelement location="${build.classes.dir}"   />
	  </path>
	  <taskdef resource="scala/tools/ant/antlib.xml">
	    <classpath>
	      <pathelement location="${scala.home}/lib/scala-compiler.jar"   />
	      <pathelement location="${scala-library}"   />
	      <pathelement location="${javac.classpath}" /> 
	    </classpath>
	  </taskdef>
	  <scalac srcdir="${src.ScalaSource.dir}" destdir="${build.classes.dir}" >
	     <classpath>
	      <pathelement location="/Users/development/Documents/AndroidTest/scala-library.jar"   />
	      <pathelement location = "${scala-library}" />
	      <pathelement location = "${file.reference.android.jar}" />
	      <pathelement path="${javac.classpath}" /> 
	    </classpath>
	  </scalac>
	  <echo message="file.reference.android.jar: ${file.reference.android.jar}"/>
	  <echo message="file.reference.scala-library.jar: ${file.reference.scala-library.jar}"/>
	</target>

	<target name="-pre-jar">
        <!-- Empty placeholder for easier customization. -->
        <!-- You can override this target in the ../build.xml file. -->
	<taskdef resource="proguard/ant/task.properties"
		 classpath="tools/proguard.jar" />
	<proguard>
	  -injars ${scala-library}(!META-INF/MANIFEST.MF,!library.properties)
	  -outjars "${build.classes.dir}/classes.min.jar"
	  -libraryjars "${file.reference.android.jar}"
	  -dontwarn
	  -dontoptimize
	  -dontobfuscate
	  -keep public class * extends android.app.Activity
	  -keep public class scala.xml.include.sax.Main**
	</proguard>
    </target>
Replies: 1 - Last Post: April 11, 2010 16:22
by: mwkohout
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close