从应用程序代码访问Androids

从应用程序代码访问Androids

本文介绍了从应用程序代码访问Androids UpdateEngine(或其他SystemApi类)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个系统更新程序,该应用程序使用 UpdateEngine .但是,由于该类及其方法用@SystemApi标记,因此我似乎无法从Java代码中访问它.

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.

我将应用程序集成到AOSP树中,但是无法从应用程序目录开始成功编译:当我在应用程序目录中运行 mm 时,我直接遇到以下错误:

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:

如果我只是将import语句添加到一个已经存在的aosp system-app中,也会发生这种情况,例如

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

从应用程序使用UpdateEngine(或实际上任何其他@SystemApi)的正确方法是什么?我不想通过删除所有SystemApi并破坏兼容性来更改android api.

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...

以防将来有人偶然发现-问题是我在Android.mk中定义了以下SDK版本:

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:

按如下所示更改sdk版本后,可以访问系统API(因此也可以使用UpdateEngine):

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

这篇关于从应用程序代码访问Androids UpdateEngine(或其他SystemApi类)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 11:39