Shared library not included in apk file

2,521 views
Skip to first unread message

Tom

unread,
Jun 19, 2010, 3:45:54 AM6/19/10
to android-ndk
The android-ndk-r4 samples do not appear to include the shared native
libraries when generated on my system. E.g. I build the hello-jni
sample on my Mac OS 10.6.4 system, first executing ndk-build which
builds libs/armeabi/libhello-jni.so as expected. However when I export
the project with the Eclipse ADT, the resulting HelloJni.apk file does
not contain the libhello-jni.so file. When I examine the contents of
the apk file with 'jar' I see:

jar tf bin/HelloJni.apk
AndroidManifest.xml
resources.arsc
classes.dex
META-INF/MANIFEST.MF
META-INF/CERT.SF
META-INF/CERT.RSA

I.e. the apk does not include the .so shared library.
What am I doing wrong?

Thanks,
Tom

David Turner

unread,
Jun 20, 2010, 10:56:28 AM6/20/10
to andro...@googlegroups.com
Did you _rebuild_ the package after calling ndk-build ?


--
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.


Onur Cinar

unread,
Jun 20, 2010, 10:41:46 PM6/20/10
to android-ndk

Hi Tom,

If you added the native library after you started the project file
then you will need to close and reopen the project file, and also
refresh (F5) will help sometimes. I had similar problems with Eclipse
too.

Regards,

-onur
---
www.zdo.com

theactiveactor

unread,
Jul 14, 2010, 6:47:24 PM7/14/10
to android-ndk
I am hitting this problem too with the latest version of APT- my
shared libraries located under jni/libs/armeabi are not showing up in
the apk file.

On Jun 20, 10:41 pm, Onur Cinar <onur.ci...@gmail.com> wrote:
> Hi Tom,
>
> If you added the nativelibraryafter you started the project file

Onur Cinar

unread,
Jul 14, 2010, 7:32:11 PM7/14/10
to andro...@googlegroups.com

Hi,

In the past, I've been told to enable the "Refresh Automatically" (Windows - Preferences - General - Workspace) in order to have the latest libraries to successfully get into the APK files.  You may want to give it a try.

It seems like working OK for me so far. Sometimes I'm still doing an F5 just in case.  But I'm using ADT 0.9.7.v20100507115, but most likely I will be switching to ANT build files.

Regards,

-onur


Doug Schaefer

unread,
Jul 14, 2010, 7:50:08 PM7/14/10
to andro...@googlegroups.com
On Wed, Jul 14, 2010 at 6:47 PM, theactiveactor
<theacti...@gmail.com> wrote:
> I am hitting this problem too with the latest version of APT- my
> shared libraries located under jni/libs/armeabi are not showing up in
> the apk file.

The libs directory needs to be at the root of the project.

David Turner

unread,
Jul 14, 2010, 8:25:42 PM7/14/10
to andro...@googlegroups.com
On Wed, Jul 14, 2010 at 3:47 PM, theactiveactor <theacti...@gmail.com> wrote:
I am hitting this problem too with the latest version of APT- my
shared libraries located under jni/libs/armeabi are not showing up in
the apk file.

it's not jni/libs/armeabi, it's libs/armeabi. Are you manually placing shared libraries under jni/libs/armeabi, or is this a typo ?
 

theactiveactor

unread,
Jul 15, 2010, 12:59:46 PM7/15/10
to android-ndk
That explains why the shared libraries aren't showing up in my APK
file. Moving the libs directory to root fixes that.

However, when I invoke ndk-build in my project root directory, it
still generates the "libs" directory under the "jni" directory. Also,
after manually moving the libs directory to the project root directory
and with the *.so in the APK file, I am still getting an
UnsatisfiedLinkError, which makes me think this could be related to
the "libs" dir not being generated in the right place.


On Jul 14, 8:25 pm, David Turner <di...@android.com> wrote:
> > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>
> > .

Onur Cinar

unread,
Jul 15, 2010, 1:14:59 PM7/15/10
to andro...@googlegroups.com

Hi,

In which directory you are calling the ndk-build? and also could you check the location of AndroidManifest.xml file?

I don't know too much about the internals of NDK4, but it seems like in your case, the NDK_APP_PROJECT_PATH is not calculated correctly by the NDK. When ndk-build is called, it is initially looking for AndroidManifest.xml file to find the project directory. How is your project directory hierarchy?

Regards,

-onur


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.


---
www.zdo.com

theactiveactor

unread,
Jul 15, 2010, 1:30:21 PM7/15/10
to android-ndk
Nevermind found the problem. APP_PROJECT_PATH was incorrectly set in
my Application.mk. Removing this variable fixed the "libs" dir
generation and missing shared lib in APK.

On Jul 15, 12:59 pm, theactiveactor <theactiveac...@gmail.com> wrote:
> That explains why thesharedlibraries aren't showing up in my APK
> file. Moving the libs directory to root fixes that.
>
> However, when I invoke ndk-build in my project root directory, it
> still generates the "libs" directory under the "jni" directory. Also,
> after manually moving the libs directory to the project root directory
> and with the *.so in the APK file, I am still getting an
> UnsatisfiedLinkError, which makes me think this could be related to
> the "libs" dir not being generated in the right place.
>
> On Jul 14, 8:25 pm, David Turner <di...@android.com> wrote:
>
>
>
> > On Wed, Jul 14, 2010 at 3:47 PM, theactiveactor <theactiveac...@gmail.com>wrote:
>
> > > I am hitting this problem too with the latest version of APT- my
> > >sharedlibraries located under jni/libs/armeabi are not showing up in
> > > the apk file.
>
> > > it's not jni/libs/armeabi, it's libs/armeabi. Are you manually placing
>
> >sharedlibraries under jni/libs/armeabi, or is this a typo ?
Reply all
Reply to author
Forward
0 new messages