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?
Related
I'm trying to set javah command in External Tools in Android Studio but I get
IllegalArgumentException: Not a valid class name:
Files\Java\jdk1.8.0_101\jre\lib\charsets.jar;C:\Program
Here are my settings in External Tools in Android Studio:
Program: $JDKPath$\bin\javah.exe
Parameters: -classpath $Classpath$ -v-cpp $FileClass$
Working directory: $ProjectFileDir$\app\src\main\cpp
What am I doing wrong?
Found by myself. Here are the correct parameters:
Parameters: -classpath $ProjectFileDir$\app\src\main\java $FileClass$
I am developing and android application in mac using Eclipse for android-ndk. I have already given NDK path in Eclipse. At the end when I am giving this command to build my application using android-ndk but getting the following errors:
command: ndk-build
ndk-build-bash: ndk-build: command not found
My Terminal Commands:
Muhammads-MacBook-Pro:~ UsmanKhan$ cd downloads
Muhammads-MacBook-Pro:downloads UsmanKhan$ cd 26thMarch2014
Muhammads-MacBook-Pro:26thMarch2014 UsmanKhan$ cd a2zLatest
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls
AndroidManifest.xml gen proguard-project.txt
Thumbs.db ic_launcher-web.png project.properties
assets libs res
bin lint.xml src
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls bin/classes/
com
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls bin/classes/com/testing/ndk
BuildConfig.class R$dimen.class R$string.class
FibLib.class R$drawable.class R$style.class
MainActivity.class R$id.class R.class
R$attr.class R$layout.class
R$color.class R$menu.class
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ mkdir jni
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ javah -jni -classpath bin /classes/ -d jni/ com.testing.ndk.FibLib
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls jni
com_testing_ndk_FibLib.h
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls jni
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ javah -jni -classpath bin/classes/ -d jni/ com.testing.ndk.FibLib
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ javah -jni -classpath bin/classes/ -d jni/ com.testing.ndk.FibLib
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ndk-build
-bash: ndk: command not found
At the end i am getting ndk-build error.
Instead of ndk-build command, simply type ~/Desktop/AndroidNDK/android-ndk-r10d/ndk-build in your terminal.
I didn't give any explicit values for ANDROID_NDK_ROOT and ANDROID_SDK_ROOT, i just give the location of my NDK in my eclipse preferences. Can you please guide me in this thing
According to the Android folks on the Android NDK group (see Recommended NDK Directory?), uou should always provide values for ANDROID_NDK_ROOT, ANDROID_SDK_ROOT and ANDROID_SDK_HOME. Here is what they are used for:
ANDROID_NDK_ROOT → installation dirctory of NDK
ANDROID_SDK_ROOT → installation dirctory of SDK
ANDROID_SDK_HOME → location of SDK-related user files, defaults to ~/.android/ on Unix.
Put the tools on-path and export the env vars. Here's my .bash_profile for OS X.
$ cat ~/.bash_profile
export PS1="\h::\W$ "
# Android
export ANDROID_NDK_ROOT=/opt/android-ndk-r10d
export ANDROID_SDK_ROOT=/opt/android-sdk-macosx
export ANDROID_SDK_HOME=~/.android
export JAVA_HOME=`/usr/libexec/java_home`
export PATH="$ANDROID_SDK_ROOT/tools/":"$ANDROID_SDK_ROOT/platform-tools/":"$PATH"
Then, source your profile changes (or log-off and then log-in).
To build the JNI shared library, you will need to have installed the Android NDK and set up the proper environment variables such as ANDROID_NDK_ROOT.
cd /Platinum
scons target=arm-android-linux build_config=Release
cd /Platinum/Source/Platform/Android/modules/platinum/jni
ndk-build NDK_DEBUG=0
import eclipse Android .project located # /Platinum/Source/Platform/Android/modules/platinum/
This will create the jar file # /Platinum/Source/Platform/Android/modules/platinum/bin/platinum.jar
The readme is above of building the platinum with ndk-build.
First step, command: "scons target=arm-android-linux build_config=Release", already succeeded.
Second step, command: "ndk-build NDK_DEBUG=0", failed. The failed log is below.
wingyip#ubuntu:~/Desktop/PlatinumKit-1-0-3-0_a71192_66de97/Platinum/Source/Platform/Android/module/platinum/jni$ ndk-buildStaticLibrary : libstdc++.aSharedLibrary : libplatinum-jni.so/home/wingyip/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot find -laxTls/home/wingyip/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /home/wingyip/Desktop/PlatinumKit-1-0-3-0_a71192_66de97/Platinum/Source/Platform/Android/module/platinum/jni/../../../../../../Build/Targets/arm-android-linux/Release/libNeptune.a(NptTls.o): in function NPT_TlsContext::~NPT_TlsContext():NptTls.cpp(.text._ZN14NPT_TlsContextD1Ev+0x18): error: undefined reference to 'ssl_ctx_free'
System: ubuntu
NDK version: android-ndk-r8c
I found this problem too. It's just a typo, open Android.mk then change
LOCAL_LDLIBS += -laxTls
to:
LOCAL_LDLIBS += -laxTLS
You can see the lib's name is libaxTLS.a.
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
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