2

I spent hours and hours on it not moving an inch forward. I have redone the project several times and nothing else is left outside places. Hope someone here can shed some light pointing out some direction.

On Linux Eclipse IDE panel > Run > External Tools > External Tools Configurations:

Name: Dev javah
Tab [main]:
* location: /usr/java/jdk1.6.0_25/bin/javah
* working directory: ${workspace_loc:/Dev/bin}
* Arguments: ??

I have tried:

* Arguments: -d ${workspace_loc:/Dev/jni} com.dev.DevActivity ${project_classpath:Dev} com.pkgpub.DevActivity

which gives me:

1 error
javadoc: error - Illegal package name: "/home/user/dev/Dev/bin/classes"

and also tried:

* Arguments: -d ${workspace_loc:/Dev/jni} com.dev.DevActivity

That gives...

error: cannot access com.dev.DevActivity
class file for com.dev.DevActivity not found
javadoc: error - Class com.dev.DevActivity not found.
Error: No classes were specified on the command line.  Try -help.

similarly to -

* Arguments: -d ${workspace_loc:/Dev/jni} com.pkgpub.DevActivity

That gives me:

error: cannot access com.pkgpub.DevActivity
class file for com.pkgpub.DevActivity not found
javadoc: error - Class com.pkgpub.DevActivity not found.
Error: No classes were specified on the command line.  Try -help.

But when I run:

which javah
/usr/bin/which: no javah in (/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/user/android-sdks/tools:/home/user/android-sdks/platform-tools:/opt/android/android-ndk-r7:/home/user/.local/bin:/home/user/bin:/home/user/android-sdks/tools:/home/user/android-sdks/platform-tools:/opt/android/android-ndk-r7:/home/user/android-sdks/tools:/home/user/android-sdks/platform-tools:/opt/android/android-ndk-r7)

The question is... the project is not compiling because javah is not visible to Eclipse NDK, or due to parameter details that something is missing? And in such case, how to get it fixed?

Thanks.

ThreaderSlash
  • 1,313
  • 3
  • 27
  • 43

3 Answers3

2

try adding

-classpath bin/classes

as parameter to javah

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
  • Thanks.. is it what you mean? ... * Arguments: -d ${workspace_loc:/Dev/jni} com.dev.DevActivity ${project_classpath:Dev/bin/classes} com.pkgpub.DevActivity ..... Because it doesn't work. – ThreaderSlash Feb 16 '12 at 15:01
  • just to be clear, actually I run javah from the linux console. Tipically I specify two different parameters the -classpath and -bootclasspath. The first says to javah where look for your java classes the second where look for java_sdk classes (I pass as argument the path to the android jar). Maybe i misunderstood your question. EDIT: after you changed the argument are errors stills the same? – Blackbelt Feb 16 '12 at 15:04
  • Doing the parameter ... * Arguments: -d ${workspace_loc:/Dev/jni} com.dev.DevActivity ${project_classpath:Dev/bin/classes} com.pkgpub.DevActivity ... The error change to: // -- An internal error occurred during: "Launching Dev javah". Path for project must have only one segment. // – ThreaderSlash Feb 16 '12 at 15:10
  • -d ${workspace_loc:/Dev/jni} com.dev.DevActivity -classpath ${workspace_loc:/Dev/bin/classes/} com.pkgpub.DevActivity – Blackbelt Feb 16 '12 at 15:25
  • Just tried your suggestion.. here is the output: // error: cannot access com.dev.DevActivity class file for com.dev.DevActivity not found javadoc: error - Class com.dev.DevActivity not found. 2 errors // – ThreaderSlash Feb 16 '12 at 15:43
  • do you have bin/classes/com/dev/DevActivity.class ? EDIT: for what class do you need the generated stub? – Blackbelt Feb 16 '12 at 15:45
1

Specially for Android:

use classes right after bin like project_location/bin/classes, this worked for me on Linux Fedora

javah -d /var/www/project/jni/ -classpath /var/www/project/bin/classes/ com.android.TestClass
antyrat
  • 27,479
  • 9
  • 75
  • 76
0

@BlackBelt - thanks man for your suggestion!

Here is the parameter that worked, solving the javah side for the compiling process:

-d ${workspace_loc:/Dev/jni} com.pkgpub.Dev -classpath ${workspace_loc:/Dev/bin/classes/} com.pkgpub.Dev

Where pkgpub is the package name, and Dev is the project name. It is worth to mention that the project has the files: \src\Dev.java; \jni\Dev.c; \jni\Dev.h; \bin...\pkgpub\Dev.class.

Now it generates the file jni/com_pkgpub_Dev.h with the right content. Which is great!

However the ndk-build is still not completely linking, and does not generate the com_pkgpub_Dev.c file. So, from Project > Project Build - comes the message:

**** Build of configuration Build (GNU) for project Dev ****
ndk-build 
make: *** No rule to make target `jni/com_pkgpub_Dev.c', needed by `obj/local/armeabi/objs/dev/com_pkgpub_Dev.o'.  Stop.
**** Build Finished ****

From this message it sounds like some parameter should be missing from the file /jni/Android.mk:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS    := -DHAVE_INTTYPES_H
LOCAL_MODULE    := dev
LOCAL_SRC_FILES := com_pkgpub_Dev.c Dev.c
include $(BUILD_SHARED_LIBRARY) 

To solve it, it is just necessary to create the missing file "jni/com_pkgpub_Dev.c". This file content should be manually made based on the automatic generated code contained in the file "jni/com_pkgpub_Dev.h".

Now, it works!

ThreaderSlash
  • 1,313
  • 3
  • 27
  • 43
  • 1
    Arguments:"-d ${workspace_loc:/MyProject/jni} com.myproject.MyActivity -classpath ${workspace_loc:/MyProject/bin/classes}" Eclipse endups with this exception when I try to add -classpath java.lang.IllegalArgumentException: Not a valid class name: -classpath – Maxim Jun 29 '12 at 21:22
  • Its not working.It is giving me a error. error: cannot access com.NDK.android_example2 class file for com.NDK.android_example2 not found javadoc: error - Class com.NDK.android_example2 not found. – Jagdeep Singh Jun 05 '13 at 06:43