NativeActivity sample fails

1,654 views
Skip to first unread message

Eric

unread,
Oct 29, 2011, 8:37:12 PM10/29/11
to android-ndk
I did a ndk-build on the NativeActivity sample, then opened it in
eclipse and tried to run it.

It complained that the project was missing a "src" directory, so I
added an empty "src" directory.

That made the compiler happy and it deployed to my device, but then I
get this error message:

10-29 17:21:06.068: E/AndroidRuntime(12191):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.native_activity/android.app.NativeActivity}:
java.lang.IllegalArgumentException: Unable to find native library:
native-activity

I looked inside the .apk, and I see lib\armeabi\libnative-activity.so.

Any idea why it would be unable to find it?

I already tried purging my phone of any previous versions of my
project and redeploying, that doesn't fix it.

I guess I will use the san-angeles way till I can figure out what's
wrong.

using windows x64, eclipse indigo, latest android sdk and ndk

wolftag

unread,
Oct 31, 2011, 8:31:04 PM10/31/11
to android-ndk
On Oct 29, 5:37 pm, Eric <erics...@gmail.com> wrote:
> using windows x64, eclipse indigo, latest android sdk and ndk

Latest eclipse plug-in, too?

Eric

unread,
Nov 1, 2011, 7:44:55 PM11/1/11
to android-ndk
Yes latest adt too.
Downloaded and installed the whole suite on Saturday.

Eric

unread,
Nov 6, 2011, 8:41:05 PM11/6/11
to android-ndk
So, I have opened several samples and they all work except for
NativeActivity.
I uninstalled and reinstalled everything

I do ndk-build of NativeActivity sample jni directory

ericstob@ericvaio /cygdrive/c/Android/android-ndk-r6b/samples/native-
activity/jni
$ ndk-build
Compile thumb : native-activity <= main.c
Compile thumb : android_native_app_glue <= android_native_app_glue.c
StaticLibrary : libandroid_native_app_glue.a
SharedLibrary : libnative-activity.so
Install : libnative-activity.so => libs/armeabi/libnative-
activity.so

ericstob@ericvaio /cygdrive/c/Android/android-ndk-r6b/samples/native-
activity/jni
$

I go to eclipse and click New -> Project -> From Existing Source, C:
\Android\android-ndk-r6b\samples\native-activity

I click run as android app and select my device, and I get this:

11-06 17:06:57.328: E/AndroidRuntime(18418):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.native_activity/android.app.NativeActivity}:
java.lang.IllegalArgumentException: Unable to find native library:
native-activity

but when I open my .apk I see libnative-activity.so there:
ericstob@ericvaio /cygdrive/c/Android/android-ndk-r6b/samples/native-
activity/bin
$ unzip NativeActivity.apk -d temp
Archive: NativeActivity.apk
inflating: temp/AndroidManifest.xml
extracting: temp/resources.arsc
inflating: temp/classes.dex
inflating: temp/lib/armeabi/libnative-activity.so
inflating: temp/META-INF/MANIFEST.MF
inflating: temp/META-INF/CERT.SF
inflating: temp/META-INF/CERT.RSA

Would appreciate some help, I can't understand why it would not work
if the .so is there in the .apk

tora

unread,
Nov 7, 2011, 2:35:36 AM11/7/11
to android-ndk
hello

Maybe, you have to check AndroidManifest.xml,

Min SDK version -> 9 or later
Target SDK version -> 9 or later

$ndk-build clean
$ndk-build

because NativeActivity is only support from Gingerbread.

mikelong

unread,
Nov 11, 2011, 12:11:27 PM11/11/11
to android-ndk

Eric

unread,
Dec 8, 2011, 10:42:51 PM12/8/11
to android-ndk
ANSWER! :-)

set android:hasCode="true" in AndroidManifest.xml

On Nov 11, 9:11 am, mikelong <mikelong1...@gmail.com> wrote:
> See this thread...
>
> http://groups.google.com/group/android-ndk/browse_thread/thread/1590a...


>
> On Nov 6, 7:41 pm, Eric <erics...@gmail.com> wrote:
>
>
>
>
>
>
>
> > So, I have opened several samples and they all work except for
> >NativeActivity.
> > I uninstalled and reinstalled everything
>

> > I do ndk-build ofNativeActivitysample jni directory


>
> > ericstob@ericvaio /cygdrive/c/Android/android-ndk-r6b/samples/native-
> > activity/jni
> > $ ndk-build
> > Compile thumb  : native-activity <= main.c
> > Compile thumb  : android_native_app_glue <= android_native_app_glue.c
> > StaticLibrary  : libandroid_native_app_glue.a
> > SharedLibrary  : libnative-activity.so
> > Install        : libnative-activity.so => libs/armeabi/libnative-
> > activity.so
>
> > ericstob@ericvaio /cygdrive/c/Android/android-ndk-r6b/samples/native-
> > activity/jni
> > $
>
> > I go to eclipse and click New -> Project -> From Existing Source, C:
> > \Android\android-ndk-r6b\samples\native-activity
>
> > I click run as android app and select my device, and I get this:
>
> > 11-06 17:06:57.328: E/AndroidRuntime(18418):
> > java.lang.RuntimeException: Unable to start activity
> > ComponentInfo{com.example.native_activity/android.app.NativeActivity}:
> > java.lang.IllegalArgumentException: Unable to find native library:
> > native-activity
>
> > but when I open my .apk I see libnative-activity.so there:
> > ericstob@ericvaio /cygdrive/c/Android/android-ndk-r6b/samples/native-
> > activity/bin

> > $ unzipNativeActivity.apk -d temp

Reply all
Reply to author
Forward
0 new messages