Accessing Androids UpdateEngine (or other SystemApi classes) from application code

♀尐吖头ヾ 提交于 2019-12-07 03:49:23

问题


I'm trying to write a system-updater application, which uses the UpdateEngine of Android 7+. However, I can't seem to get access to it from my java code, since the class and its methods are marked with @SystemApi.

I integrated my application into the AOSP tree, but I can't start a successful compile from my application directory: When i run mm in the app dir, I directly get the following error:

The import android.os.UpdateEngine cannot be resolved

This also happens if I just add the import statement to an already existing aosp system-app, e.g.

What is the correct way to use UpdateEngine (or actually any other @SystemApi) from an application? I don't want to change the android api by removing all the SystemApi and break compatibility.


回答1:


Of course I find the solution right after posting the question...

In case someone else stumbles upon this in the future - The problem was that I had the following SDK version defined in my Android.mk:

LOCAL_SDK_VERSION := current

System APIs (and thus UpdateEngine) became accessible after changing the sdk version as follows:

LOCAL_SDK_VERSION := system_current



来源:https://stackoverflow.com/questions/44941221/accessing-androids-updateengine-or-other-systemapi-classes-from-application-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!