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

andreas-hofmann :

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.

andreas-hofmann :

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

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=472055&siteId=1