简体   繁体   English

AIDL服务和Android开源

[英]AIDL Service and Android Open Source

I've created an AIDL service called IHelloService and I am trying to call it from IOBridge under the libcore module. 我创建了一个名为IHelloService的AIDL服务,并且尝试从libcore模块下的IOBridge调用它。

Currently my code looks like this 目前我的代码看起来像这样

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

....

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

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 错误包括package android.os does not exist并且cannot find symbol ServiceManagerIHelloService

I've already declared package android.os in the HelloService aidl file, so I don't think that's the issue. 我已经在HelloService aidl文件中声明了package android.os ,所以我认为这不是问题。

Any help would be appreciated. 任何帮助,将不胜感激。

Sang,

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. 您需要做的是构建一个可与该特定服务一起使用的新SDK,以便Android Studio(我假设您正在使用的)可以将其识别为您的ROM版本中可用的。

Here is what you should do: (found at https://android.googlesource.com/platform/sdk/+/master/docs/howto_build_SDK.txt ) 这是您应该执行的操作:(位于https://android.googlesource.com/platform/sdk/+/master/docs/howto_build_SDK.txt

  1. Go to your Android build area and run . 转到您的Android构建区域并运行。 build/envsetup.sh build / envsetup.sh
  2. Run the command "make update-api" in your build area. 在构建区域中运行命令“ make update-api”。 This will update the files with the changes or additions you have made to the api. 这将使用您对api所做的更改或添加来更新文件。
  3. Run "lunch sdk-eng" to set up the build for the sdk. 运行“午餐sdk-eng”以设置sdk的构建。
  4. To make the SDK, run "make sdk". 要制作SDK,请运行“ make sdk”。 This could take some time (20m - 2hr), but will end with the line "Package SDK: out/host/darwin-x86/sdk/android-sdk_eng..zip" 这可能会花费一些时间(20m-2小时),但以“ Package SDK:out / host / darwin-x86 / sdk / android-sdk_eng..zip”行结束

Now that the SDK is made, you will need to point Android Studio to the new SDK. 制作完SDK后,您需要将Android Studio指向新的SDK。 TO do this: 去做这个:

  1. RIght click on your app, and select "Open Module Settings". 单击您的应用程序,然后选择“打开模块设置”。
  2. Choose "SDK" from the menu on the Left. 从左侧菜单中选择“ SDK”。
  3. Select your new SDK path. 选择新的SDK路径。

There might be other ways to do this, but that is the process I am working with currently. 可能还有其他方法可以做到这一点,但这就是我目前正在使用的过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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