Javah missing android.os.Parcelable - android

When I'm trying to create a headerfile with javah I get an error that he can't find the Parcelable class.
Before I created the header with:
From %PROJECTDIR%/bin/classes/
javah -classpath com.my.project
But now I added the Parcelable to the native calls I include the android.jar to the commandline call:
From %PROJECTDIR%/bin/classes/
javah -classpath :~/shared/android.jar:~/shared/MyProject/bin/classes com.my.project
I will get this error:
Error: Class android.os.Parcelable could not be found.
What am I doing wrong?

I had the same error message but a different problem (under Windoze). For some reason i had to quote the classpath although there was no whitespace in the path:
C:\myProjectPath>javah -jni -classpath "C:\Users\myUserName\android-sdks\platforms\android-15\android.jar";bin\classes -d jni package1.package2.myInterestingClass
And this didn't work:
C:\myProjectPath>javah -jni -classpath C:\Users\myUserName\android-sdks\platforms\android-15\android.jar;bin\classes -d jni package1.package2.myInterestingClass
And it worked when using a relative path:
C:\myProjectPath>javah -jni -classpath ..\..\..\..\..\Users\myUserName\android-sdks\platforms\android-15\android.jar;bin\classes -d jni package1.package2.myInterestingClass
Spent a few hours on this, windows is really weird most of the time. Maybe this helps someone else.

Found the problem... I had one colon to many.
javah -classpath ~/shared/android.jar:. com.my.project

Related

ERROR: javah is not working in android studio

to create header files i am using javah but its not working for me.
using javah like this.
Javah -d ${ D:\finalYearProjectAPP\WorkingCam\app\src\main\jni} -classpath ${ D:\finalYearProjectAPP\WorkingCam\app\build\intermediates\classes\debug } com.example.ahmedarif.workingcam.OpenCvClass
and it gives this error.
Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name
: D:\finalYearProjectAPP\WorkingCam\app\src\main\jni}
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:129)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:107)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:64)
at com.sun.tools.javah.JavahTask.run(JavahTask.java:503)
at com.sun.tools.javah.JavahTask.run(JavahTask.java:329)
at com.sun.tools.javah.Main.main(Main.java:46)

How to use Javah in Ubuntu14.04 for HelloNDK?

I am using Ubuntu14.04, Eclipse Luna.
I am referring Hello World Example given link
http://www.ntu.edu.sg/home/ehchua/programming/android/Android_NDK.html
My project name is HelloNDK.
My project path is /home/androiddev/workspace_luna/HelloNDK
In AndroidManifest.xml
I can see package which I use is named as: com.delta.hellondk
Android.jar which automatically added in project which is under Android 5.0.1 & its location shown as
/home/androiddev/Applications/Android_sdk/sdk/platforms/android-21/android.jar
When I use javah command, I got error.
I use following line in terminal.
javah -jni -classpath /home/androiddev/workspace_luna/HelloNDK/bin/classes/;/home/androiddev/Applications/Android_sdk/sdk/platforms/android-21/android.jar -o HelloJNI.h com.delta.hellondk
&
javah -jni -classpath /home/androiddev/workspace_luna/HelloNDK/bin/classes/JNIActivity.class;/home/androiddev/Applications/Android_sdk/sdk/platforms/android-21/android.jar -o HelloJNI.h com.delta.hellondk
when I use following command, I got error as follows:
Error: No classes were specified on the command line. Try -help.
bash: /home/androiddev/Applications/Android_sdk/sdk/platforms/android-21/android.jar: cannot execute binary file: Exec format error
Now I search lots of keywords in google, stackoverflow regarding how to generate HelloJNI.h automatically.
But i failed.
Please guide me!
I know its repeate question should be get negative vote, should be 'On Hold'. But then also i doesn’t get any clue so i asked without hesitate.

How to integrate mupdf library?

I try to build the library mupdf, using the following sequence
https://stackoverflow.com/a/12279638/680267
I can not run command:
javah -jni -classpath bin/classes/ -d jni/ com.artifex.mupdf.MuPDFActivity
Error: cannot access android.app.Activity class file for
android.app.Activity not found
I tried to specify the path to the folder with the android-sdk:
'/cygdrive/c/Program Files/Java/JDK7/bin/javah.exe' -jni -classpath /cygdrive/c/Android/platforms/android-8/android.jar;/cygdrive/c/Users/Alexey/Documents/GitHub/mupdf/android/bin/classes -d jni/ com.artifex.mupdf.MuPDFActivit
Error: no classes specified
-bash: /cygdrive/c/Users/Alexey/Documents/GitHub/mupdf/android/bin/classes: a directory
How to run this command?

Javah Error android.app.Activity not found

I'm trying to create a .h header file for a simple NDK project. Using cygwin I browse to myprojectDIR\jni directory, then execute this command:
javah -o com_myproject_MyActivity.h -classpath myprojectDIR\bin\classes com.myproject.MyActivity
then this error message appears:
Error: cannot access android.app.Activity
class file for android.app.Activity not found
I have a native method inside MyActivity class, so I tried to create a new class called NativeAccess (does not extend any class from the android SDK) and it worked fine, the .h file was created, ndk-build and test on device where successful!
So my problem is that I need my native methods inside android activities and services that I create, but I cant do that because the Javah command cannot access classes from inside the android-sdk itself. Please notice that I'm using (Windows-7 x64) and I have these environment variables:
ANDROID_NDK : C:\Android\android-ndk-r7b
ANDROID_SDK : C:\Android\android-sdk
ANT_HOME : C:\ANT\apache-ant-1.8.3
JAVA_HOME : C:\Program Files\Java\jdk1.7.0_02
PATH : %JAVA_HOME%\bin;%ANDROID_SDK%\tools;%ANDROID_SDK%\platform-tools;%ANDROID_NDK%;%ANT_HOME%\bin; (other unrelated stuff)
Thanks in advance
Try adding to your classpath:
-classpath <android-sdk-location>/platforms/android-8.jar
I found it, this is how it goes:
javah -o com_myproject_MyActivity.h -classpath <android-sdk-location>/platforms/android-8.jar;myprojectDIR\bin\classes com.myproject.MyActivity
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
In order to generate native header files javah needs:
your classes (usually under build/intermediates/classes)
Android classes (usually under $ANDROID_HOME/platforms/android-%ver%/android.jar)
So you simply pass them in -classpath argument
The main challenge for me was basically passing both of them - you have to use : as a separator and paths must be absolute.
See Oracle docs
Thus you may end up with something like this: javah -classpath <full path to app>build/intermediates/classes/debug:<full path to sdk>/platforms/android-26/android.jar com.myproject.MyActivity
I found it, this is how it goes:
E:\workspeaceResearch\DAMMADARJNI\src>javah -classpath "E:\Software\sdk\platform
s\android-19/platforms/android-8.jar"; -jni com.dammadar.jni.Home_Screen

javah multiple classpath

I think I'm doing the classpath wrong on the command line, and I get the following error:
My android program uses Bitmap from the package android.graphics.Bitmap
thomas#THOMASDESKLINUX:~$ javah -verbose -classpath :/home/thomas/Documents/LinuxProgramming/AndroidSDKs/android-sdk-linux_x86/platforms/android-8.jar;/home/thomas/Documents/LinuxProgramming/EclipseWorkspace/RenderScene/bin org.me.renderscene.Billboard
Error: No classes were specified on the command line. Try -help.
bash: /home/thomas/Documents/LinuxProgramming/EclipseWorkspace/RenderScene/bin: is a directory
and javah cant find the class
thanks!
The problem with your command is that you are using the Windows Path Separator ; on the command line, rather than the Linux Path Separator :. I also recommend to add the current directory to javah: ., the correct command to generate header in your case is:
javah .:/home/thomas/Documents/LinuxProgramming/AndroidSDKs/android-sdk-linux_x86/platforms/android-8.jar:/home/thomas/Documents/LinuxProgramming/EclipseWorkspace/RenderScene/bin org.me.renderscene.Billboard
Tip: javah doesn't need all dependency libraries to generate the headers, it will output warnings but thats OK. So using this tip, we can generate the headers with:
javah .:/home/thomas/Documents/LinuxProgramming/EclipseWorkspace/RenderScene/bin org.me.renderscene.Billboard

Categories

Resources