views:

359

answers:

1

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 2.1 project going in Netbeans 6.8 (with the NBAndroid 0.10 plugin). The two languages being Java and Scala(2.8 head build). To give you a basic idea of what the app does right now, it's just a simple "Hello World" app.

To get this to build, I've modified the projects's build.xml file:

 <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>

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).

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

Edit: FYI, here's the output from adb logcat:

I/dalvikvm(  369): Failed resolving Lorg/me/androidtest/MainActivity; interface 35 'Lscala/ScalaObject;'
W/dalvikvm(  369): Link of class 'Lorg/me/androidtest/MainActivity;' failed
D/AndroidRuntime(  369): Shutting down VM
W/dalvikvm(  369): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
E/AndroidRuntime(  369): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(  369): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.me.androidtest/org.me.androidtest.MainActivity}: java.lang.ClassNotFoundException: org.me.androidtest.MainActivity in loader dalvik.system.PathClassLoader@43d02720
E/AndroidRuntime(  369):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
E/AndroidRuntime(  369):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime(  369):    at android.app.ActivityThread.access$2200(ActivityThread.java:119)
E/AndroidRuntime(  369):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime(  369):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  369):    at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  369):    at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime(  369):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  369):    at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  369):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime(  369):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime(  369):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  369): Caused by: java.lang.ClassNotFoundException: org.me.androidtest.MainActivity in loader dalvik.system.PathClassLoader@43d02720
E/AndroidRuntime(  369):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
E/AndroidRuntime(  369):    at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
E/AndroidRuntime(  369):    at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
E/AndroidRuntime(  369):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime(  369):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
E/AndroidRuntime(  369):    ... 11 more
I/Process (   56): Sending signal. PID: 369 SIG: 3
I/dalvikvm(  369): threadid=7: reacting to signal 3
I/dalvikvm(  369): Wrote stack trace to '/data/anr/traces.txt'
W/ActivityManager(   56): Launch timeout has expired, giving up wake lock!

Clearly, it's some type of classloader/classpath issue or something(at least that's what I'd say if this was the JVM), but when I look inside my Proguard'd jarfile I find The classes I'd expect: scala.ScalaObject, org.me.androidtest.MainActivity, and some others.

If it helps the project with all it's dependencies made internal is located at http://philosophicalsoftware.com/AndroidTest.zip

+1  A: 

Does anyone see what I may be doing wrong?

Yes. You don't have any source code. :-)

And is there any way to get access to the logs that the emulator must create?

I'm not sure about inside of Netbeans, but you can use adb logcat or DDMS to examine the logs, which will contain...well...something. Ordinarily, I'd say "a Java stack trace showing the cause of your exception", but I'm not 100% certain what happens with a Scala app (though I am planning on doing some Scala/Android experiments soonish).

CommonsWare