I have added few native methods to my android Activity class.Now I want to create the header file for that class.
I get the following error while creating the header file from command line.
C:\AndroidProjects\JniTest\bin\classes>javah -classpath .;
C:\adt-bundle-windows-x86\sdk\platforms\android.jar com.example.jnitest.JniTest
Error: cannot access android.app.Activity
class file for android.app.Activity not found
Basically unable to access the activity class form the jar.
Please advice.
Try the following in Eclipse,
Go to > Run | External Tools| External Tool Configurations Under Program create new configuration by clicking small icon.
Name it.
Location would be : C:\Program Files\Java\jdk1.7.0_04\bin\javah.exe
Working Directory would be: ${workspace_loc:/My_First_NDK/bin/classes} and
Arguments would be: -classpath ${workspace_loc:/My_First_NDK/bin/classes} -bootclasspath "C:\adt-bundle-windows-x86-20140624\sdk\platforms\android-19\android.jar" -v -d ${workspace_loc:/My_First_NDK/jni} com.mypackage.ndk.HelloNDK

The command would be (use backslashes (\), instead of forward slashes (/) while using Windows cmd):
javah -bootclasspath $ANDROID_SDK_ROOT/platforms/android-17/android.jar -classpath bin/classes com.example.jnitest.JniTest
You should use -bootclasspath instead of -classpath, since android.jar re-implements Java Class Library.
Assumptions:
C:\AndroidProjects\JniTest;$ANDROID_SDK_ROOT (%ANDROID_SDK_ROOT% for Windows);android-17.Please modify your command accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With