附图显示了在两台不同机器上从同一项目生成的 APK(解压缩)。
如您所见,两种场景中的APK内容不同。在第二个APK edu中,lib,or,Android.mk,classes.dex,LICENSE.txt,pocketsphinx.i,pocketsphinx_wrap.c都不存在。我做不明白为什么在不同机器上使用相同代码的 APK 内容会有这种差异。显然,第二个 APK 没有给我正确的输出,在尝试启动时,崩溃并显示以下日志:
01-01 00:17:13.092: DEBUG/dalvikvm(3458): Late-enabling CheckJNI
01-01 00:17:13.100: INFO/ActivityManager(2302): Start proc or.exp.voicereco for activity or.exp.voicereco/.CameraMain: pid=3458 uid=10070 gids={1015}
01-01 00:17:13.124: INFO/dalvikvm(2302): Zip is good, but no classes.dex inside, and no .odex file in the same directory
01-01 00:17:13.124: WARN/PackageManager(2302): IOException reading apk: /system/app/PocketSphinxDemo.apk
01-01 00:17:13.124: WARN/PackageManager(2302): java.io.IOException: /system/app/PocketSphinxDemo.apk
01-01 00:17:13.124: WARN/PackageManager(2302): at dalvik.system.DexFile.isDexOptNeeded(Native Method)
01-01 00:17:13.124: WARN/PackageManager(2302): at com.android.server.pm.PackageManagerService.performDexOptLI(PackageManagerService.java:3172)
01-01 00:17:13.124: WARN/PackageManager(2302): at com.android.server.pm.PackageManagerService.performDexOpt(PackageManagerService.java:3157)
01-01 00:17:13.124: WARN/PackageManager(2302): at com.android.server.am.ActivityManagerService.ensurePackageDexOpt(ActivityManagerService.java:1869)
01-01 00:17:13.124: WARN/PackageManager(2302): at com.android.server.am.ActivityManagerService.attachApplicationLocked(ActivityManagerService.java:3876)
01-01 00:17:13.124: WARN/PackageManager(2302): at com.android.server.am.ActivityManagerService.attachApplication(ActivityManagerService.java:4013)
01-01 00:17:13.124: WARN/PackageManager(2302): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:351)
01-01 00:17:13.124: WARN/PackageManager(2302): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1616)
01-01 00:17:13.124: WARN/PackageManager(2302): at android.os.Binder.execTransact(Binder.java:338)
01-01 00:17:13.124: WARN/PackageManager(2302): at dalvik.system.NativeStart.run(Native Method)
01-01 00:17:13.131: INFO/dalvikvm(2302): Zip is good, but no classes.dex inside, and no .odex file in the same directory
01-01 00:17:13.131: INFO/ActivityManager(2302): app/or.exp.voicereco[RESUMED] app.idle/false ...realStartActivityLocked
01-01 00:17:13.131: WARN/PackageManager(2302): IOException reading apk: /system/app/PocketSphinxDemo.apk
01-01 00:17:13.131: WARN/PackageManager(2302): java.io.IOException: /system/app/PocketSphinxDemo.apk
01-01 00:17:13.131: WARN/PackageManager(2302): at dalvik.system.DexFile.isDexOptNeeded(Native Method)
01-01 00:17:13.131: WARN/PackageManager(2302): at com.android.server.pm.PackageManagerService.performDexOptLI(PackageManagerService.java:3172)
01-01 00:17:13.131: WARN/PackageManager(2302): at com.android.server.pm.PackageManagerService.performDexOpt(PackageManagerService.java:3157)
01-01 00:17:13.131: WARN/PackageManager(2302): at com.android.server.am.ActivityManagerService.ensurePackageDexOpt(ActivityManagerService.java:1869)
01-01 00:17:13.131: WARN/PackageManager(2302): at com.android.server.am.ActivityStack.realStartActivityLocked(ActivityStack.java:601)
01-01 00:17:13.131: WARN/PackageManager(2302): at com.android.server.am.ActivityManagerService.attachApplicationLocked(ActivityManagerService.java:3925)
01-01 00:17:13.131: WARN/PackageManager(2302): at com.android.server.am.ActivityManagerService.attachApplication(ActivityManagerService.java:4013)
01-01 00:17:13.131: WARN/PackageManager(2302): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:351)
01-01 00:17:13.131: WARN/PackageManager(2302): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1616)
01-01 00:17:13.131: WARN/PackageManager(2302): at android.os.Binder.execTransact(Binder.java:338)
01-01 00:17:13.131: WARN/PackageManager(2302): at dalvik.system.NativeStart.run(Native Method)
01-01 00:17:13.147: INFO/dalvikvm(3458): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
01-01 00:17:13.155: DEBUG/AndroidRuntime(3458): Shutting down VM
01-01 00:17:13.155: WARN/dalvikvm(3458): threadid=1: thread exiting with uncaught exception (group=0x40b021f8)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): FATAL EXCEPTION: main
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{or.exp.voicereco/ or.exp.voicereco.CameraMain}: java.lang.ClassNotFoundException: or.exp.voicereco.CameraMain
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1882)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1989)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at android.app.ActivityThread.access$600(ActivityThread.java:125)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1149)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at android.os.Handler.dispatchMessage(Handler.java:99)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at android.os.Looper.loop(Looper.java:137)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at android.app.ActivityThread.main(ActivityThread.java:4368)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at java.lang.reflect.Method.invokeNative(Native Method)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at java.lang.reflect.Method.invoke(Method.java:511)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at dalvik.system.NativeStart.main(Native Method)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): Caused by: java.lang.ClassNotFoundException: or.exp.voicereco.CameraMain
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1873)
01-01 00:17:13.155: ERROR/AndroidRuntime(3458): ... 11 more
01-01 00:17:13.155: WARN/ActivityManager(2302): Force finishing activity or.exp.voicereco/.CameraMain
有人可以告诉我为什么当我从一台机器而不是在另一台机器上编译和运行应用程序时得到正确的输出。而对于所有其他应用程序,生成的 APK 在第二台机器上是完美的。
任何帮助深表感谢。
问候,阿内斯
PS:这是一个基于ndk的应用程序。