ndk-build not working with Android.mk in Eclipse

1,124 views
Skip to first unread message

robscure

unread,
Nov 10, 2010, 5:04:40 AM11/10/10
to android-ndk
Hi,

I am developing with the android sdk for a while and now getting my
feets wet with the ndk. in my attempt to do the tutorial I found at
http://mobile.tutsplus.com/tutorials/android/ndk-tutorial/ I do not
come past the error "no rule to make target.."

I will give a description of what I did and what my setup is and I
hope you don't mind that the logs are partly in german, which is my
default locale

setup:

OS: debian squeeze
make -v: GNU Make 3.81
latest android sdk installed under <userhome>work/android/android-sdk-
linux_x86/
latest android ndk installed under <userhome>work/android/android-ndk-
r4b/ containing the autogenereated GNUMakefile

I set the path to the ndk in /etc/profile and <userhome>/.profile and
the command "ndk-build" is available system-wide.

in eclipse (helios) a have installed the android adt plugin and the
CDT plugin

I created a project HelloNDK, android target 8, package is
de.robscure.learn, activity is HelloNDKActivity,java. it looks like
this:

package de.robscure.learn;

import ...;

public class HelloNDKActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

final Button button = (Button) findViewById(R.id.button_id);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
helloLog("This will log to LogCat via the native
call.");
}
});
}
static {
System.loadLibrary("mynative");
}
private native void helloLog(String logThis);
}

I created the according string resources in res/values/strings.xml and
the layout containing the button layout in res/layout/main.xml

Under the project root I also created the jni folder containing
Android.mk and mynative.c

here is Android.mk's content:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_LDLIBS := -llog

LOCAL_MODULE := mynative
LOCAL_SRC_FILES := mynative.c

include $(BUILD_SHARED_LIBRARY)

and this is what's in mynative.c:

#include <jni.h>
#include <string.h>
#include <android/log.h>

#define DEBUG_TAG "NDK_HelloNDKActivity"

void Java_de_robscure_learn_HelloNDKActivity_helloLog(JNIEnv * env,
jobject this, jstring logThis)
{
jboolean isCopy;
const char * szLogThis = (*env)->GetStringUTFChars(env, logThis,
&isCopy);

__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:LC: [%s]",
szLogThis);

(*env)->ReleaseStringUTFChars(env, logThis, szLogThis);
}


when I cd into the project root folder in a shell as root, then doing
"ndk-build" I get the following error (I changed my user name to
<userhome>):

# ndk-build
Gdbserver : [arm-eabi-4.4.0] <userhome>/work/android/npapi/
workspace/HelloNDK/libs/armeabi/gdbserver
Gdbsetup : <userhome>/work/android/npapi/workspace/HelloNDK/libs/
armeabi/gdb.setup
Gdbsetup : + source directory <userhome>/work/android/npapi/
workspace/HelloNDK/jni
make: *** Keine Regel vorhanden, um das Target »/mynative.c«,
benötigt von »<userhome>/work/android/npapi/workspace/HelloNDK/obj/
local/armeabi/objs/mynative/mynative.o«, zu erstellen. Schluss.

So I thought this "no rule to make target.." error would mean
something's wrong with Android.mk, but I cannot figure out what it is.
It is found, because, when I for example move it one folder up (to the
project root folder) I get the error:

# mv jni/Android.mk Android.mk
# ls
AndroidManifest.xml Android.mk assets bin default.properties gen
jni libs res src
# ndk-build
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file:
<userhome>/work/android/npapi/workspace/HelloNDK/jni/Android.mk
<userhome>/work/android/android-ndk-r4b/build/core/add-application.mk:
98: *** Android NDK: Aborting... . Schluss.

In the Android.mk I have the module name, which I use in the
activities call to System.loadLibrary("mynative"); and the name of
the source file mynative.c which you can see above is correct.

I'd like to know, what could be the reason for this no-target-found
error. Does target refer to something else than the Android.mk?? I
tried to use an Application.mk file also placed in /jni but with the
same result.

What can I check next to get further??

Or is there still something wrong within the Android.mk??

I also made another try in a new project setup as recommended here:
http://codemaemo.appforce.org/2010/07/tutorial-using-eclipse-for-ndk-projects/

but it lead to the same error in the eclipse console!

in the txt's under <ndk>/docs i didn't find further hints to my
problem, after how I understood what I read there I should be good to
go with my setup.

If you need further information to help me, plz let me know!
I do appreciate any hint very much, thx!

David Turner

unread,
Nov 10, 2010, 12:33:06 PM11/10/10
to andro...@googlegroups.com
There is nothing wrong in your Android.mk or source file. From the error message, it looks like the build script is looking for a source file named "/mynative.c" instead of "<userhome>/work/android/npapi/workspace/HelloNDK/jni/mynative.c", which is weird.

Can I ask you if <userhome> contains any special characters (e.g. dollar sign, comma, umlauts etc...)?

What is the output of running "ndk-build NDK_LOG=1" ? It should print debug information that may help understand what is wrong.


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


Nick (ntg)

unread,
Nov 10, 2010, 5:17:28 PM11/10/10
to android-ndk, David Turner
One way to solve this:
# LOCAL_PATH := $(call my-dir)
LOCAL_PATH := ./jni

include $(CLEAR_VARS)

LOCAL_LDLIBS := -llog
LOCAL_MODULE := ndk1
LOCAL_SRC_FILES := native.c
include $(BUILD_SHARED_LIBRARY)

one could possibly find a better way ( $(call pwd) or something???)

Nick


On Nov 10, 12:33 pm, David Turner <di...@android.com> wrote:
> There is nothing wrong in your Android.mk or source file. From the error
> message, it looks like the build script is looking for a source file named
> "/mynative.c" instead of
> "<userhome>/work/android/npapi/workspace/HelloNDK/jni/mynative.c", which is
> weird.
>
> Can I ask you if <userhome> contains any special characters (e.g. dollar
> sign, comma, umlauts etc...)?
>
> What is the output of running "ndk-build NDK_LOG=1" ? It should print debug
> information that may help understand what is wrong.
>
> On Wed, Nov 10, 2010 at 11:04 AM, robscure <robwi...@googlemail.com>wrote:
>
> > Hi,
>
> > I am developing with the android sdk for a while and now getting my
> > feets wet with the ndk. in my attempt to do the tutorial I found at
> >http://mobile.tutsplus.com/tutorials/android/ndk-tutorial/I do not
> >http://codemaemo.appforce.org/2010/07/tutorial-using-eclipse-for-ndk-...
>
> > but it lead to the same error in the eclipse console!
>
> > in the txt's under <ndk>/docs i didn't find further hints to my
> > problem, after how I understood what I read there I should be good to
> > go with my setup.
>
> > If you need further information to help me, plz let me know!
> > I do appreciate any hint very much, thx!
>
> > --
> > 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<android-ndk%2Bunsu...@googlegroups.com>
> > .

Nick (ntg)

unread,
Nov 10, 2010, 5:19:49 PM11/10/10
to android-ndk, robscure
one way to solve this:

# LOCAL_PATH := $(call my-dir)
LOCAL_PATH := ./jni

include $(CLEAR_VARS)

LOCAL_LDLIBS := -llog
LOCAL_MODULE := ndk1
LOCAL_SRC_FILES := native.c
include $(BUILD_SHARED_LIBRARY)


On Nov 10, 5:04 am, robscure <robwi...@googlemail.com> wrote:
> Hi,
>
> I am developing with the android sdk for a while and now getting my
> feets wet with the ndk. in my attempt to do the tutorial I found athttp://mobile.tutsplus.com/tutorials/android/ndk-tutorial/I do not
> I also made another try in a new project setup as recommended here:http://codemaemo.appforce.org/2010/07/tutorial-using-eclipse-for-ndk-...

robscure

unread,
Nov 11, 2010, 1:09:36 AM11/11/10
to android-ndk
Hello David,

thx for your reply!

<username> contained no special chars, but I changed te username to
rob so that i can provide full printout of ndk-build NDK_LOG=1:

root@fuji:/home/rob/work/android/npapi/workspace/HelloNDK# ndk-build
NDK_LOG=1
Android NDK: NDK installation path auto-detected: '/home/rob/work/
android/android-ndk-r4b'
Android NDK: GNU Make version 3.81 detected
Android NDK: Host OS was auto-detected: linux
Android NDK: Host CPU was auto-detected: x86
Android NDK: HOST_TAG set to linux-x86
Android NDK: Host awk tool was auto-detected: awk
Android NDK: Host awk test returned: Pass
Android NDK: This NDK supports the following toolchains and target
ABIs:
Android NDK: arm-eabi-4.2.1: armeabi
Android NDK: arm-eabi-4.4.0: armeabi armeabi-v7a
Android NDK: x86-4.2.1: x86
Android NDK: Found supported platforms: android-3 android-4 android-5
android-8
Android NDK: PLATFORM android-3 supports: arm
Android NDK: ABI arm sysroot is: /home/rob/work/android/android-ndk-
r4b/build/platforms/android-3/arch-arm
Android NDK: PLATFORM android-4 supports: arm
Android NDK: ABI arm sysroot is: /home/rob/work/android/android-ndk-
r4b/build/platforms/android-4/arch-arm
Android NDK: PLATFORM android-5 supports: arm x86
Android NDK: ABI arm sysroot is: /home/rob/work/android/android-ndk-
r4b/build/platforms/android-5/arch-arm
Android NDK: ABI x86 sysroot is: /home/rob/work/android/android-ndk-
r4b/build/platforms/android-5/arch-x86
Android NDK: PLATFORM android-8 supports: arm x86
Android NDK: ABI arm sysroot is: /home/rob/work/android/android-ndk-
r4b/build/platforms/android-8/arch-arm
Android NDK: ABI x86 sysroot is: /home/rob/work/android/android-ndk-
r4b/build/platforms/android-8/arch-x86
Android NDK: Found stable platform levels: 3 4 5 8
Android NDK: Found max platform level: 8
Android NDK: Looking for AndroidManifest.xml in /home/rob/work/android/
npapi/workspace/HelloNDK
Android NDK: Found it !
Android NDK: Found project path: /home/rob/work/android/npapi/
workspace/HelloNDK
Android NDK: Parsing /home/rob/work/android/android-ndk-r4b/build/core/
default-application.mk
Android NDK: Found APP_PLATFORM=android-8 in /home/rob/work/android/
npapi/workspace/HelloNDK/default.properties
Android NDK: Using build script /home/rob/work/android/npapi/
workspace/HelloNDK/jni/Android.mk
Android NDK: Application 'local' *is* debuggable
Android NDK: Selecting debug optimization mode (app is debuggable)
Android NDK: Building application 'local' for ABI 'armeabi'
Android NDK: Using target toolchain 'arm-eabi-4.4.0' for 'armeabi' ABI
Gdbserver : [arm-eabi-4.4.0] /home/rob/work/android/npapi/
workspace/HelloNDK/libs/armeabi/gdbserver
Gdbsetup : /home/rob/work/android/npapi/workspace/HelloNDK/libs/
armeabi/gdb.setup
Gdbsetup : + source directory /home/rob/work/android/npapi/
workspace/HelloNDK/jni
make: *** Keine Regel vorhanden, um das Target »/mynativesrc.c«,
benötigt von »/home/rob/work/android/npapi/workspace/HelloNDK/obj/
local/armeabi/objs/ndk1/mynativesrc.o«, zu erstellen. Schluss.

IMO even these debug messages look all ok except from the error.

note: before ndk-build fails attempting to create mynativesrc.o it
succesfully creates the folder /libs/armeabi/ containing gdb.setup and
gdbserver. geb.setup looks correct:

set solib-search-path /home/rob/work/android/npapi/workspace/HelloNDK/
obj/local/armeabi
directory /home/rob/work/android/android-ndk-r4b/build/platforms/
android-8/arch-arm/usr/include
directory /home/rob/work/android/npapi/workspace/HelloNDK/jni

anything else I can check?

On 10 Nov., 18:33, David Turner <di...@android.com> wrote:
> There is nothing wrong in your Android.mk or source file. From the error
> message, it looks like the build script is looking for a source file named
> "/mynative.c" instead of
> "<userhome>/work/android/npapi/workspace/HelloNDK/jni/mynative.c", which is
> weird.
>
> Can I ask you if <userhome> contains any special characters (e.g. dollar
> sign, comma, umlauts etc...)?
>
> What is the output of running "ndk-build NDK_LOG=1" ? It should print debug
> information that may help understand what is wrong.
>
> On Wed, Nov 10, 2010 at 11:04 AM, robscure <robwiene...@googlemail.com>wrote:
>
> > Hi,
>
> > I am developing with the android sdk for a while and now getting my
> > feets wet with the ndk. in my attempt to do the tutorial I found at
> >http://mobile.tutsplus.com/tutorials/android/ndk-tutorial/I do not
> >http://codemaemo.appforce.org/2010/07/tutorial-using-eclipse-for-ndk-...
>
> > but it lead to the same error in the eclipse console!
>
> > in the txt's under <ndk>/docs i didn't find further hints to my
> > problem, after how I understood what I read there I should be good to
> > go with my setup.
>
> > If you need further information to help me, plz let me know!
> > I do appreciate any hint very much, thx!
>
> > --
> > 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<android-ndk%2Bunsu...@googlegroups.com>
> > .

robscure

unread,
Nov 11, 2010, 1:16:20 AM11/11/10
to android-ndk
hey nick,

thx a lot for your suggestion! as I pointed out in myinitial post, the
path to the jni folder is found correctly. the debug output in my
second post confims that Android.mk was found in /jni.

I still tried your suggestion, but it does not change anything

On 10 Nov., 23:19, "Nick (ntg)" <frangiada...@gmail.com> wrote:
> one way to solve this:
>
>  # LOCAL_PATH := $(call my-dir)
>  LOCAL_PATH :=   ./jni
>
>  include $(CLEAR_VARS)
>
>  LOCAL_LDLIBS := -llog
>  LOCAL_MODULE    := ndk1
>  LOCAL_SRC_FILES := native.c
>  include $(BUILD_SHARED_LIBRARY)
>
> On Nov 10, 5:04 am, robscure <robwiene...@googlemail.com> wrote:
>
> > Hi,
>
> > I am developing with the android sdk for a while and now getting my
> > feets wet with the ndk. in my attempt to do the tutorial I found athttp://mobile.tutsplus.com/tutorials/android/ndk-tutorial/Ido not

robscure

unread,
Nov 11, 2010, 3:37:47 AM11/11/10
to android-ndk
I forgot to mention that my debian squeeze actually is a 64 bit
installation (amd64). I supposed it would make no difference here, but
according to the ndk-build NDK_LOG=1 log the cpu was detected as x86:
"Android NDK: Host CPU was auto-detected: x86 " I was wondering if
this is correct?! should be as the ndk buld tools are under build/
prebuild/linux_x86 not under linux_x86_64!

I do also have the full android source tree as git repository on this
computer, but I kept it clearly separated from the ndk, not to mix up
the build tools. It resides under /home/rob/work/android/source and
the log from ndk-build NDK_LOG=1 showed that only the ndk build tools
are used. Or is there a possibility that the platform toolchain
influences what I am doing with the ndk?? The platform toolchain is
not in my Path, only the ndk tools, here's echo $PATH:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/rob/
work/android/android-sdk-linux_x86/tools:/home/rob/work/android/
android-sdk-linux_x86:~/bin:/home/rob/work/android/android-ndk-r4b

the only thing here related to the git repository is the path to ~/
bin, but there's only repo installed.

As I said, I suppose the above information has nothing to do with the
problem, but to go sure, I wanted to add them.

thx again

David Turner

unread,
Nov 11, 2010, 3:54:45 PM11/11/10
to andro...@googlegroups.com
On Thu, Nov 11, 2010 at 9:37 AM, robscure <robwi...@googlemail.com> wrote:
I forgot to mention that my debian squeeze actually is a 64 bit
installation (amd64). I supposed it would make no difference here, but
according to the ndk-build NDK_LOG=1 log the cpu was detected as x86:
"Android NDK: Host CPU was auto-detected: x86 " I was wondering if
this is correct?! should be as the ndk buld tools are under build/
prebuild/linux_x86 not under linux_x86_64!

This is correct, this means it will use the x86 prebuilt toolchain binaries.
We don't distribute 64-bit Linux binaries for the NDK. They are not noticeably faster, and the less platforms we have, the better for us.
 
I do also have the full android source tree as git repository on this
computer, but I kept it clearly separated from the ndk, not to mix up
the build tools.

Yes, good idea.
 
It resides under /home/rob/work/android/source and
the log from ndk-build NDK_LOG=1 showed that only the ndk build tools
are used. Or is there a possibility that the platform toolchain
influences what I am doing with the ndk?? The platform toolchain is
not in my Path, only the ndk tools, here's echo $PATH:

Not in this case.
 
--
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.
Reply all
Reply to author
Forward
0 new messages