I'm trying to create and test a simple dummy Android application written in Scala without the ProGuard step (useProguard := false).
I have pushed scala library to the /system/framework
:
/system/framework/scala-library-2.9.1.jar
and a permissions file to /system/etc/permissions
:
/system/etc/permissions/scala-library-2.9.1.xml
The contents of permissions xml:
<?xml version="1.0" encoding="utf-8"?>
<permissions>
<library
name="scala-library-2.9.1"
file="/system/framework/scala-library-2.9.1.jar"
/>
</permissions>
Here is my MainActivity.scala
:
package com.google.summer
import _root_.android.app.Activity
import _root_.android.os.Bundle
import _root_.android.graphics.Typeface
import _root_.android.text.Html
class MainActivity extends Activity with TypedActivity {
override def onCreate(bundle: Bundle) {
super.onCreate(bundle)
setContentView(R.layout.main)
// my dummy code here
}
}
Here is my AndroidManifest.xml
:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.summer">
<application
android:icon="@drawable/android:star_big_on"
android:label="@string/app_name"
android:debuggable="true">
<activity android:label="@string/app_name" android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<uses-library android:name="scala-library-2.9.1" />
</application>
<uses-sdk android:minSdkVersion="10"/>
</manifest>
I managed to install it on my device without using ProGuard, however, when I try to run it, I get the following exception (captured using logcat):
dalvikvm I Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
dalvikvm I Failed resolving Lcom/google/summer/TypedViewHolder; interface 48 'Lscala/ScalaObject;'
dalvikvm W Link of class 'Lcom/google/summer/TypedViewHolder;' failed
dalvikvm I Failed resolving Lcom/google/summer/TypedActivityHolder; interface 30 'Lcom/google/summer/TypedViewHolder;'
dalvikvm W Link of class 'Lcom/google/summer/TypedActivityHolder;' failed
dalvikvm I Failed resolving Lcom/google/summer/TypedActivity; interface 19 'Lcom/google/summer/TypedActivityHolder;'
dalvikvm W Link of class 'Lcom/google/summer/TypedActivity;' failed
dalvikvm I Failed resolving Lcom/google/summer/MainActivity; interface 18 'Lcom/google/summer/TypedActivity;'
dalvikvm W Link of class 'Lcom/google/summer/MainActivity;' failed
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.google.summer/com.google.summer.MainActivity}: java.lang.ClassNotFoundException: com.google.summer.MainActivity in loader dalvik.system.PathClassLoader[/system/framework/scala-library-2.9.1.jar:/data/app/com.google.summer-1.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1680)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
at android.app.ActivityThread.access$1500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.google.summer.MainActivity in loader dalvik.system.PathClassLoader[/system/framework/scala-library-2.9.1.jar:/data/app/com.google.summer-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1672)
... 11 more
Force finishing activity com.google.summer/.MainActivity
Does anyone know where the error might be and what to do to resolve it?
Thanks in advance :D
BTW, could it be that there is a problem with scala library that was pushed?
Logcat says it cannot find scala.ScalaObject
but it is present in the jar I pushed.
You can't add new external libraries (i.e. that is shared between apps) at will to devices. You will need to include the scala jar in every app you create.
It could be done by creating a custom rom with Scala available on it, but then everyone who wanted to run your app would need that custom rom. Not very practical :)