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!