AIDL服务和Android开源 [英] AIDL Service and Android Open Source

查看:265
本文介绍了AIDL服务和Android开源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个名为IHelloService的AIDL服务,我正在尝试从libcore模块下的IOBridge调用它.

I've created an AIDL service called IHelloService and I am trying to call it from IOBridge under the libcore module.

当前我的代码如下

// import
import android.os.IHelloService;
import android.os.ServiceManager;

....

IHelloService helloService = IHelloService.Stub.asInterface(ServiceManager.getService("hello"));
int val = helloService.getVal();

在进行标准构建时遇到错误. 错误包括package android.os does not existcannot find symbol ServiceManagerIHelloService

I run into errors when doing a standard build. The errors include package android.os does not exist and cannot find symbol ServiceManager and IHelloService

我已经在HelloService aidl文件中声明了package android.os,所以我认为这不是问题.

I've already declared package android.os in the HelloService aidl file, so I don't think that's the issue.

任何帮助将不胜感激.

推荐答案

桑,

您的问题实际上是我一直在解决的问题.您需要做的是构建一个可与该特定服务一起使用的新SDK,以便Android Studio(我假设您正在使用的)可以将其识别为您的ROM版本中可用的.

Your issue is actually one I have been working through. What you need to do is build a new SDK for use with that specific service so that Android Studio (I am assuming that is what you are using) can recognize it as being available in your version of the ROM.

这是您应该做的:(位于 https://android.googlesource.com/platform/sdk/+/master/docs/howto_build_SDK.txt )

Here is what you should do: (found at https://android.googlesource.com/platform/sdk/+/master/docs/howto_build_SDK.txt)

  1. 转到您的Android构建区域并运行. build/envsetup.sh
  2. 在构建区域中运行命令"make update-api".这将使用您对api所做的更改或添加来更新文件.
  3. 运行午餐sdk-eng"以设置sdk的构建.
  4. 要制作SDK,请运行"make sdk".这可能会花费一些时间(20m-2小时),但以"Package SDK:out/host/darwin-x86/sdk/android-sdk_eng..zip"行结束

现在已完成SDK的制作,您需要将Android Studio指向新的SDK.为此:

Now that the SDK is made, you will need to point Android Studio to the new SDK. TO do this:

  1. 右键单击您的应用,然后选择打开模块设置".
  2. 从左侧菜单中选择"SDK".
  3. 选择新的SDK路径.

也许还有其他方法可以做到这一点,但这就是我目前正在使用的过程.

There might be other ways to do this, but that is the process I am working with currently.

这篇关于AIDL服务和Android开源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆