AIDL Service and Android Open Source

人走茶凉 提交于 2019-12-12 03:24:12

问题


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

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

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

Any help would be appreciated.


回答1:


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.

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

  1. Go to your Android build area and run . build/envsetup.sh
  2. Run the command "make update-api" in your build area. This will update the files with the changes or additions you have made to the api.
  3. Run "lunch sdk-eng" to set up the build for the sdk.
  4. To make the SDK, run "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"

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

  1. RIght click on your app, and select "Open Module Settings".
  2. Choose "SDK" from the menu on the Left.
  3. Select your new SDK path.

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



来源:https://stackoverflow.com/questions/37146370/aidl-service-and-android-open-source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!