AOSP:在Activity.java中创建SystemService实例时出错

时间:2014-05-20 21:47:29

标签: android-activity android-service android-source start-activity android-service-binding

我已向AOSP添加了自定义系统服务。我想在Activity.java类中使用我的服务,并希望在startActivityForResult()方法中进行一些更改。我想以同样的方式为PackageManagerService创建一个实例。但由于某些原因我无法运行,我从logcat得到以下错误:

***********************************************
F/SystemServer(  500): BOOT FAILURE starting Input Manager Service
F/SystemServer(  500): java.lang.RuntimeException: Unable to get provider com.android.providers.settings.SettingsProvider: java.lang.ClassNotFoundException: com.android.providers.settings.SettingsProvider
F/SystemServer(  500):  at android.app.ActivityThread.installProvider(ActivityThread.java:4201)
F/SystemServer(  500):  at android.app.ActivityThread.getProvider(ActivityThread.java:4010)
F/SystemServer(  500):  at android.app.ActivityThread.acquireProvider(ActivityThread.java:4026)
F/SystemServer(  500):  at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:1612)
F/SystemServer(  500):  at android.content.ContentResolver.acquireProvider(ContentResolver.java:948)
F/SystemServer(  500):  at android.provider.Settings$NameValueCache.getString(Settings.java:701)
F/SystemServer(  500):  at android.provider.Settings$Secure.getString(Settings.java:2207)
F/SystemServer(  500):  at com.android.server.InputMethodManagerService.buildInputMethodListLocked(InputMethodManagerService.java:1966)
F/SystemServer(  500):  at com.android.server.InputMethodManagerService.(InputMethodManagerService.java:556)
F/SystemServer(  500):  at com.android.server.ServerThread.run(SystemServer.java:273)
F/SystemServer(  500): Caused by: java.lang.ClassNotFoundException: com.android.providers.settings.SettingsProvider
F/SystemServer(  500):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
F/SystemServer(  500):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
F/SystemServer(  500):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
F/SystemServer(  500):  at android.app.ActivityThread.installProvider(ActivityThread.java:4186)
F/SystemServer(  500):  ... 9 more
I/SystemServer(  500): Accessibility Manager
W/SystemServer(  500): ***********************************************
F/SystemServer(  500): BOOT FAILURE making display ready

如何在Activity.java中创建服务实例。在Activity.java中还有一个systemReady()方法,我知道在PackageManagerService中有这种方法,但这是一个服务,而不是Activity。所以想知道检查它的最佳方法是什么。任何想法赞赏

1 个答案:

答案 0 :(得分:0)

这是因为SettingsProvider.apk的dex opt签名不匹配为了测试目的,我通过设置以下env变量来禁用此检查,从而解决了这个问题:

导出WITH_DEXPREOPT = false export DISABLE_DEXPREOPT = true

提供者: https://groups.google.com/forum/#!msg/android-building/vJCkg8Yq9Ic/mgev8ODDia4J