Android NDK: cannot launch javah - android

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$

Related

Android Error: Failed to find 'ANDROID_HOME' environment variable

I just started Android development with ionic framework on Linux (Ubuntu).
I successfully created my ionic project using the command:
sudo ionic start demo blank
Now to add the android platform to the project, I ran the command:
sudo ionic platform add android
And this is the result it gave me:
function bold() { [native code] } https://github.com/driftyco/ionic-default-resources/archive/master.zip
[=============================] 100% 0.0s
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.ionicframework.demo504884
Name: demo
Activity: MainActivity
Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android#6.0.0
ls: no such file or directory: /home/awa/Desktop/mobile/demo/res/mipmap-*
Installing "cordova-plugin-console" for android
Failed to install 'cordova-plugin-console':CordovaError: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
at /home/awa/Desktop/mobile/demo/platforms/android/cordova/lib/check_reqs.js:222:19
at _fulfilled (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:796:13)
at /home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:857:14
at runSingle (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:137:13)
at flush (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
At first I doubted if it had successfully added the android platform so I ran the same command again (sudo platform add android) and it said platform already existed.
Now seeing the last section of the error, I set the ANDROID_HOME environment variable by putting this code at the end of my .bashrc file located my home directory.
export ANDROID_HOME=/home/awa/Android/Sdk
export PATH=$PATH:/home/awa/Android/Sdk/tools
export PATH=$PATH:/home/awa/Android/Sdk/platform-tools
I saved the file. In order to build my project, I ran the command:
sudo ionic build android
and it gave the error:
add to body class: platform-android
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
I verified again to make sure I had succeeded in setting the ANDROID_HOME environment variable correctly. So in the Command line I ran the command echo $ANDROID_HOME and it gave as output:
/home/awa/Android/Sdk
...which is the right directory for my SDK.
I have tried other solutions like setting the environment variables in the .profile file but nothing changed.
Now I am suspecting the problem may have something to do with my sdk version though I'm not entirely sure.
What am I doing wrong, or what I'm I missing?

Ar toolkit nftBook with android studio

How to solve artoolkit nftBook issues in android studio
When I run the command ndk-build in android studio terminal for nft book it shows the error like:
clang++.exe: error: linker command failed with exit code 1 (use -v to
see invocation) make: *** [obj/local/armeabi/libnftBookNative.so]
Error 1
How can I solve this?
You should not run it in the android studio terminal but in the Git-Bash.
Read the documentation more closely :).
You look like you are working from Windows so you need to use Git-Bash for compilation.
See: http://artoolkit.org/community/forums/viewtopic.php?f=26&t=17092
===========
EDIT:
Make sure you have these environment variables set:
- Set ANDROID_HOME to indicate the path to root folder of the downloaded Android SDK.
Set ANDROID_NDK_ROOT to indicate the path to root folder (most likely, “ndk-bundle”) of the downloaded NDK. The ANDROID_HOME environment variable can be used to help define NDK.
ANDROID_NDK_ROOT=$ANDROID_HOME/ndk-bundle
Set NDK to the same path as ANDROID_NDK_ROOT. NDK=$ANDROID_NDK_ROOT
Set PATH to include a path to the ndk-build[.cmd] script file, that is, the path to the root folder of the NDK. The NDK environment variable can be used to help define the added path.
Now start gitBash and navigate to your ARToolKit5_ROOT directory.
cd android
./build.sh
if successful
./build_native_examples.sh

Android NDK with Linux: "ndk-build" command not found

I'm new to Linux (Ubuntu) and I had a problem building the libraries in my project.
I added the android ndk to the PATH like this:
export PATH=$PATH:/android-ndk-r9b
and to Eclipse
but when I try to use the
ndk-build
command, I get this output:
ndk-build: command not found
Any help?
Your PATH should include the root directory of your NDK:
export PATH=$PATH:/home/.../android-ndk-xxx

How to build apk using commandline

I Want to build apk using commandline, I am using ant server by using it I am building apk with commandline but when I give this command ant debug it shows error BUILD FAILED Unable to locate tools.jar and then it gives error source resource doesnt exist
This might be because your JAVA_HOME is not set to your C:\Program Files\Java\jdk folder.
instead it might be set to C:\Program Files\Java\jre so it's not getting tools.jar.
just check out this.
You can do this in this way:
C:\>set JAVA_HOME=C:\Program Files\Java\jdk
C:\>ant debug
You need tools.jar file from your jdk/lib/ folder.

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

Categories

Resources