我正在尝试在没有 ProGuard 步骤的情况下创建和测试一个用 Scala 编写的简单虚拟 Android 应用程序(useProguard := false)。
我已将 scala 库推送到/system/framework
:
/system/framework/scala-library-2.9.1.jar
和一个权限文件/system/etc/permissions
:
/system/etc/permissions/scala-library-2.9.1.xml
权限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>
这是我的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
}
}
这是我的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>
我设法在不使用 ProGuard 的情况下将它安装在我的设备上,但是,当我尝试运行它时,出现以下异常(使用 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
有谁知道错误可能在哪里以及如何解决它?
先谢谢了
顺便说一句,可能是被推送的 scala 库有问题吗?
Logcat 说它找不到scala.ScalaObject
,但它存在于我推送的 jar 中。