[newbie] Compiling a native C++ app using Binder for Android

10,536 views
Skip to first unread message

Jay

unread,
May 12, 2011, 6:02:35 PM5/12/11
to android-ndk
Hi,

I downloaded a sample native app using Binders from
https://github.com/mcr/Android-HelloWorldService. I then downloaded
both Android SDK and NDK (latest versions). However I notice the above
app refers to some header files (some examples eg. IInterface.h,
IServiceManager.h) that I dont see anywhere either in the SDK or NDK.

I checked the Froyo 2.2 for Android-x86 sources but again not there.
Just to dbl-check if I was missing I placed the app sources under
external

I realize the above sample app is old so could it be that whatever
headers it is referring to dont exist any more?

tia
jay

Jay

unread,
May 12, 2011, 6:42:47 PM5/12/11
to android-ndk
Minor correction in second para below - hit send hastily..

> I checked the Froyo 2.2 for Android-x86 sources but again not there.
> Just to dbl-check if I was missing I placed the app sources under
> external and tried compiling the iso_img but got errors complaining the headers not found.

related q: Is there any latest version of any sample native code
demonstrating use of Binder?


On May 12, 3:02 pm, Jay <Jayant_s...@hotmail.com> wrote:
> Hi,
>
> I downloaded a sample native app using Binders fromhttps://github.com/mcr/Android-HelloWorldService. I then downloaded

Chris Stratton

unread,
May 12, 2011, 10:39:48 PM5/12/11
to andro...@googlegroups.com
On Thursday, May 12, 2011 6:02:35 PM UTC-4, Jay wrote:
I downloaded a sample native app using Binders from
https://github.com/mcr/Android-HelloWorldService. I then downloaded
both Android SDK and NDK (latest versions). However I notice the above
app refers to some header files (some examples eg. IInterface.h,
IServiceManager.h) that I dont see anywhere either in the SDK or NDK.

I don't think that project is within the "bounds" of what the NDK and SDK are intended to enable - it seems to require pulling in private (ie, unstable) interfaces from the platform sources, and having an engineering or rooted device to deploy to.


Jay

unread,
May 13, 2011, 11:08:03 AM5/13/11
to android-ndk

Are you implying it is not possible or recommended to develop a native
app(s) to use Binder? OR it is possible but it should be done
differently? I am constrained to use native code and not Java or JNI
etc.

Can someone from the Android platform team comment on this?

thx
Jay

David Turner

unread,
May 13, 2011, 12:02:59 PM5/13/11
to andro...@googlegroups.com
On Fri, May 13, 2011 at 5:08 PM, Jay <Jayan...@hotmail.com> wrote:

Are you implying it is not possible or recommended to develop a native
app(s) to use Binder? OR it is possible but it should be done
differently? I am constrained to use native code and not Java or JNI
etc.

Can someone from the Android platform team comment on this?


Yes, the Binder is not exposed by the NDK, neither its interface or implementation, which means that applications built with the NDK should never depend on it, or they risk crashing / stop working in a future system update, or on specific OEM devices that have otherwise been accepted as compatible.

 
thx
Jay

On May 12, 7:39 pm, Chris Stratton <cs07...@gmail.com> wrote:
> On Thursday, May 12, 2011 6:02:35 PM UTC-4, Jay wrote:
>
> > I downloaded a sample native app using Binders from
> >https://github.com/mcr/Android-HelloWorldService. I then downloaded
> > both Android SDK and NDK (latest versions). However I notice the above
> > app refers to some header files (some examples eg. IInterface.h,
> > IServiceManager.h) that I dont see anywhere either in the SDK or NDK.
>
> I don't think that project is within the "bounds" of what the NDK and SDK
> are intended to enable - it seems to require pulling in private (ie,
> unstable) interfaces from the platform sources, and having an engineering or
> rooted device to deploy to.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


David Turner

unread,
Apr 17, 2013, 3:48:46 AM4/17/13
to andro...@googlegroups.com

On Wed, Apr 17, 2013 at 12:52 AM, Alexandre Bodi <alexan...@gmail.com> wrote:
Hi David,

If the Binder mechanism is not available for native code, how come I can find it under android/frameworks/native/include/binder/?

You're referring to code that is part of the platform itself, and not available to applications. This means these declarations are not stable, not guaranteed to be available or even working on any compatible device.

The official NDK headers are under android/development/ndk/platforms/
 
Has it become available at some late release?

No, I don't think so.
 
Or, even though it's there, you discourage its use since it can become deprecated at an upcoming release?

As usual, usage is discouraged because these APIs/ABIs could be removed or changed by any OEM, or any new platform release. There is no guarantee that using them will work.

Generally speaking, it takes several iterations for a system API to be considered stable / good enough to be exposed to application developers. The team tries really hard exposing stuff that isn't ready yet for consumption.

In the case of native code APIs, things are even more restrictive due to various technical considerations. Consider using JNI to call through platform APIs instead whenever possible.

 
Thanks and regards,
Alexandre Bodi
Reply all
Reply to author
Forward
0 new messages