Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalArgumentException: Not a valid class name: ANDROID NDK javah

Im learning to code Android in NDK on WINDOWS Eclipse.... been following a Tutorial Book by Sylvain Ratabouil. So im in Run | External Tools | External Tools Configurations… creating a new program configuration.

Name: MyProject javah

Location : ${env_var:JAVA_HOME}\bin\javah.exe

Working directory: ${workspace_loc:/MyProject/bin}

The problem comes In arguments... when i try Arguments: –d ${workspace_loc:/MyProject/jni} com.myproject.MyActivity as it says in the book

i get when i click run

Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: –d

when i try ${workspace_loc:/MyProject/jni} com.myproject.MyActivity}

i get

Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: C:\Paul\Workspace\MyProject\jni

UPDATE: i put -classpath first and it's running but can not find the class file for com.myproject

like image 820
Asiimwe Avatar asked Jul 13 '13 14:07

Asiimwe


3 Answers

after further research.... i did it.

i set arguments to

-d ${workspace_loc:/MyProject/jni} -classpath C:\Paul\android-sdk-windows\platforms\android-17\android.jar;${workspace_loc:/MyProject/bin/classes} com.myproject.MainActivity

like image 152
Asiimwe Avatar answered Nov 16 '22 17:11

Asiimwe


I also spend some long time on this problem when working with the the mentioned book about Android NDK.

Please note the following: The java classname is NOT written in { }, just write something like com.myproject.MyActivity

The -classpath parameter can receive several paths devided by semicolon.

In my case this parameters worked:

Location:

${env_var:JAVA_HOME}\bin\javah.exe

Working Directory:

${workspace_loc:/myproject/bin}

Arguments:

-d ${workspace_loc:/myproject/jni} -classpath ${workspace_loc:/myproject/bin/classes};"C:\Eclipse\sdk\platforms\android-18\android.jar" com.myproject.MyActivity

(BTW.: The correct Adroid.jar file is referenced inside the Eclipse project.)

like image 26
Julian Avatar answered Nov 16 '22 17:11

Julian


Me also facing the same problem tonight, i found a less tedious way as following...

  1. as "Location" set the javah from your system
  2. as "Working directory" set the project's bin/classes directory (${workspace_loc:/HelloWorld/bin/classes})
  3. as "Argument" set the jni folder as the output directory and point out the class on which you want to run the javah (-d "${workspace_loc:/HelloWorld/jni}" com.example.helloworld.MainActivity)

NB :: Dont forget the double qoute (") around the output in the third step ("${workspace_loc:/HelloWorld/jni}")

A full picture is also attached following

All 3 steps in a single picture

like image 1
Ratul Sharker Avatar answered Nov 16 '22 18:11

Ratul Sharker