0

I have a problem with Android NDK to Make the following command ... I have installed NDK and complimented ...

C:\Users\Eduu\AndroidStudioProjects\ndk>javah -jni -classpath C:\Users\Eduu\AppData\Local\Android\sdk\platforms\android-19\android.jar;bin\classes\ -d jni\ com.example.eduu.ndk.MainActivity
Error: Could not find class file for 'com.example.eduu.ndk.MainActivity'.

Link Tutorial: Step 3.3 https://geekytheory.com/hola-mundo-con-android-ndk-parte-4/

Thanks.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
Eduardo B
  • 23
  • 6
  • When you work with NDK, keep using direct slashes **`/`**, not back slashes **`\\`** – Alex Cohn Oct 22 '15 at 17:35
  • I tried but still the same error – Eduardo B Oct 22 '15 at 19:59
  • This could be a spelling error, or you are looking at the wrong directory. Please check `dir /s bin\classes\*.class`… Wait a second… Are you working in Android Studio? – Alex Cohn Oct 22 '15 at 20:18
  • Yes (?) And Windows 7 – Eduardo B Oct 22 '15 at 20:25
  • possible duplicate of *[Android Studio & NDK: I got an error when “javah -d jni -classpath…”](http://stackoverflow.com/questions/27252712/android-studio-ndk-i-got-an-error-when-javah-d-jni-classpath)* and *[Javah still won't find class files in OSX / Android Studio](http://stackoverflow.com/questions/26274155/javah-still-wont-find-class-files-in-osx-android-studio)* – Alex Cohn Oct 23 '15 at 04:38

2 Answers2

1

The path bin\classes\ is specific for Eclipse project structure. With the default structure of Android Studio project, your command line should look like

C:\Users\Eduu\AndroidStudioProjects\ndk>javah -jni -classpath C:/Users/Eduu/AppData/Local/Android/sdk/platforms/android-19/android.jar;app/build/intermediates/classes/debug -d app/src/main/jni com.example.eduu.ndk.MainActivity

Note that I use forward slash everywhere, to avoid glitches. Also, both paths to jni directory and to the classes directory that I use above, are default paths for Android Studio. These may change per project. You should manually look for the directory where your .cpp files are an where the compiler puts the .class files, whenever you have suspicion that the paths may be different.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
0

Another Simple solution for build class in android studio is

In terminal,

cd app/src/main

then,

javah -d jni -classpath ../../build/intermediates/classes/debug location of class file

Gowthaman
  • 137
  • 1
  • 10