简体   繁体   中英

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

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, eg

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM