我有一个启动器应用程序,其服务作为用户应用程序正常运行,但是在我将它作为系统应用程序放入 /system/app/ 后,它无法安装,这是奇怪的 logcat:
F/FileObserver( 367): Unhandled exception in FileObserver com.android.server.pm.PackageManagerService$AppDirObserver@41130430
F/FileObserver( 367): java.lang.NullPointerException: name == null
F/FileObserver( 367): at java.io.File.<init>(File.java:150)
F/FileObserver( 367): at java.io.File.<init>(File.java:124)
F/FileObserver( 367): at com.android.server.pm.PackageManagerService.getDataPathForPackage(PackageManagerService.java:3579)
F/FileObserver( 367): at com.android.server.pm.PackageManagerService.scanPackageLI(PackageManagerService.java:3940)
F/FileObserver( 367): at com.android.server.pm.PackageManagerService.scanPackageLI(PackageManagerService.java:3382)
F/FileObserver( 367): at com.android.server.pm.PackageManagerService.access$1700(PackageManagerService.java:172)
F/FileObserver( 367): at com.android.server.pm.PackageManagerService$AppDirObserver.onEvent(PackageManagerService.java:5541)
F/FileObserver( 367): at android.os.FileObserver$ObserverThread.onEvent(FileObserver.java:125)
F/FileObserver( 367): at android.os.FileObserver$ObserverThread.observe(Native Method)
F/FileObserver( 367): at android.os.FileObserver$ObserverThread.run(FileObserver.java:88)
D/dalvikvm( 367): GC_FOR_ALLOC freed 1488K, 25% free 11974K/15816K, paused 56ms, total 57ms
一个字符串空指针!发生了什么?
以下是来自 PackageManagerService (Android4.2) 的相关 Android 源代码:
private File getDataPathForPackage(String packageName, int userId) {
/*
* Until we fully support multiple users, return the directory we
* previously would have. The PackageManagerTests will need to be
* revised when this is changed back..
*/
if (userId == 0) {
return new File(mAppDataDir, packageName);
} else {
return new File(mUserAppDataDir.getAbsolutePath() + File.separator + userId
+ File.separator + packageName);
}
}
但我仍然不知道原因。
UDPATE:
这是<original-package>
清单中标记的原因,删除它并且问题消失了。