NullPointerException in Android JNI HelloJni Application - android

When I'm trying to execute
javah -classpath NDK1_29jan/bin/classes;/home/XXXXX/Android_Eclipse_9sept/android-sdk-linux/platforms/android-15/android.jar -o HelloJNI.h com.example.hellojni.HelloJni
Then, it is showing exception in console
Error: no classes specified
Exception in thread "main" java.lang.NullPointerException
at sun.launcher.LauncherHelper.getMainClassFromJar(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Where NDK1_29jan is my project name. I already set path in .bashrc file like this:
$export NDK=~/home/XXXXX/Android/ndk/android-ndk-r9d

Related

How to create a dex with D8.bat

I used to create dex file with dx.bat like this :
"c:\SDKs\android\build-tools\32.0.0\dx.bat" --dex
--output=C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp\classes.dex
C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp\obj.zip
How to do the same with d8.bat?
Creating DEX file using d8 can be achieved using:
d8 --output <output-folder> <input-files>
In your case, the following is an equivalent:
c:\SDKs\android\build-tools\32.0.0\d8.bat --output C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp\obj.zip
To anyone who is using d8.bat with OpenJDK-11, if you encounter the error when running d8.bat:
-Djava.ext.dirs=${PathToAndroidSDK}\build-tools${BuildToolVersion}\lib is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
You can edit d8.bat with a text editor, replacing the code -Djava.ext.dirs="%frameworkdir%" in last line to -classpath "%frameworkdir%" to fix the error.

Error while running dx or d8 tool for Android

I am trying to build Android apps manually from the command line.
But, whenever I am running dx.bat command which is located inside the Android SDK build-tools directory, I am always getting an error. Whichever option I give, I always get the same error. While running dx --help, I got this error :
-Djava.ext.dirs=E:\.android\SDK\build-tools\29.0.2\lib is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
When I had Android Studio, I didn't get any such problems. What mistake am I doing and how to get the dx.bat file to work right?
I had solved this issue by editing the dx.bat file.
As mentioned in the error
-Djava.ext.dirs=E:\.android\SDK\build-tools\29.0.2\lib is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I had just changed this line of the dx.bat file (last line) :
call "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%
to this :
call "%java_exe%" %javaOpts% -classpath "%frameworkdir%" -jar "%jarpath%" %params%

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 make ROM pack tool in Android?

Pack ROM
https://android.googlesource.com/platform/system/extras/+/lollipop-wear-release/ext4_utils/
I just make it by the following command. (reference from Google searched)
gcc -o make_ext4fs -Icore/libsparse/include -lz extras/ext4_utils/make_ext4fs_main.c extras/ext4_utils/make_ext4fs.c extras/ext4_utils/ext4fixup.c extras/ext4_utils/ext4_utils.c extras/ext4_utils/allocate.c extras/ext4_utils/contents.c extras/ext4_utils/extent.c extras/ext4_utils/indirect.c extras/ext4_utils/uuid.c extras/ext4_utils/sha1.c extras/ext4_utils/wipe.c core/libsparse/backed_block.c core/libsparse/output_file.c core/libsparse/sparse.c core/libsparse/sparse_crc32.c core/libsparse/sparse_err.c core/libsparse/sparse_read.c
But encountered the following error.
extras/ext4_utils/make_ext4fs_main.c:33:29: fatal error:
selinux/selinux.h: No such file or directory compilation terminated.
extras/ext4_utils/make_ext4fs.c:63:29: fatal error: selinux/selinux.h:
No such file or directory

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.

Categories

Resources