简体   繁体   中英

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.

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.

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.

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