问题
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)
- Go to your Android build area and run . build/envsetup.sh
- 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.
- Run "lunch sdk-eng" to set up the build for the sdk.
- 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:
- RIght click on your app, and select "Open Module Settings".
- Choose "SDK" from the menu on the Left.
- 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