I know there are similar questions here already, but none of them seem to help. I'm using Ubuntu 16.04
I'm trying to create a JNI file and folder in Android Studio, following this tutorial: https://www.youtube.com/watch?v=kFtxo7rr2HQ but no matter what I do I keep getting errors. I've got it to a point where it says:
Error: cannot access android.support.v7.app.AppCompatActivity
class file for android.support.v7.app.AppCompatActivity not found
Here is the command I am giving it:
javah -d jni -classpath ~/Android/Sdk/platforms/android-21/android.jar:../../build/intermediates/classes/debug com.example.ndktest.MainActivity
I have tried adding these two libraries, figuring that this would resolve my issue, but no luck:
javah -d jni -classpath ~/Android/Sdk/platforms/android-21/android.jar:~/android-support-v7-appcompat-master/libs/android-support-v7-appcompat.jar:~/android-support-v7-appcompat-master/libs/android-support-v4.jar:../../build/intermediates/classes/debug com.example.ndktest.MainActivity
This gives me the same error. I'm at a loss for what I can try next to make this work. Eventually my task is to integrate an application into an android build rom, but I need to understand Android.mk files first, and for that I need to understand how to use the NDK to use preexisting C++ code. Can anyone help?
The simplest way to solve this problem is change the AppCompatActivity to Activity, then you are good to go.
You are quit careful, since you change the semicolon to colon already. I make a mistake for that.
Related
Basically, it starts with me making some refactoring like moving the extension to another file, then I get an exception of this type in some place of code at runtime and I have to find the right module and delete manually the build folder.
If any has some more insights or a better solution would be nice.
I use gradle.properties:
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.unsafe.configuration-cache=false
Setting configuration-cache=true makes this issue frequent.
So after more struggle I have found THE Solution :
#!/bin/sh
find . -name 'build' -exec rm -fr {} +
This will delete all build sub folders, something one would expect from running gradle clean.
Now I can even use org.gradle.unsafe.configuration-cache=true to speed up builds, I had issues anyway and now I can run this custom clean.sh that works as clean should.
EDIT:
So this doesn't work mostly, what I do lately is that I comment out code that is failing run app and the add it back again run and it works. Really bad issue that slows me, I would like to find real solution and somehow don't see anyone reporting this.
I need help. I'm trying to install and configure OpenCV 2.4.7 library in my computer (Ubuntu 12.04). After run OpenCV samples appears those errors in my Console:
Cannot run program "/NDK-build": Unknown reason
Error: Program "/NDK-build" not found in PATH=[/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games]
I've seen numerous tutorials and nothing worked. I ask you to be very specific since I am "new" programming and also because my mother tongue is not English (I have some difficulties). Thank you!
Easiest Method which worked for me is.
Goto the Project Properties
Click on C/C++ Build (An other list will open)
Click on the Environment from the list
Now click on Add
Here you have to Put 2 values
Put Name as NDKROOT
In Value put PATH TO THE NDK FOLDER
You are done :)
Same case happened with me (when my NDK location was already set), so changing to original Android Builder removed my problem for doing so simply go to project properties, C/C++ Build | Tool Chain Editor and select Android Builder as current builder.
Do you have android-ndk installed? If yes, add path to ndk-build to your path.
e.g:
export PATH=$PATH:~/android-ndk/bin
Add the ndk-build to your path
Follow this guide
http://my.safaribooksonline.com/book/programming/android/9781849691529/setting-up-your-environment/ch01lvl1sec18
this is a frequent issue with openCV for Android. It stems from having the incorrect build target, which creates an error within the library for the Video.java file. After getting that patched up, you can import sample projects. Although, after fixing that, you may not be able to see the C/C++ Build node under project preferences. There's a fix for that on the second link. However, if under project preferences you can see C/C++ Build, make sure the path reads: "${NDKROOT}/ndk-build" Finally, it will be looking for NDKROOT,which is undeclared. The third link will direct you on how to do this, it's very simple. ALSO, make sure if your on MAC or LINUX to remove the .cmd from the end of NDK-BUILD. Good Luck!
Video.java issue:
http://answers.opencv.org/question/8266/opencv-library-244-on-eclipse-gives-error/
C++ Build/General Missing from Project Preferences:
http://stackoverflow.com/questions/16953548/eclipse-missing-c-c-build-and-general-from-project-properties
Now, make sure you add NDK root to the build varialbles so you can find it:
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_add_build_var.htm`
That's it, actually. I prefer not to use Eclipse, and want to use the command line.
I've tried to just build it without doing anything special, but it gave me errors like:
package com.giderosmobile.android.player does not exist
cannot find symbol AudioDevice
etc.
Also, if it's possible, I'd like to use another IDE and use the command line for the entire process. Is this possible? If yes, how?
This is my first question here on SO, so please correct me if I'm asking it wrong.
Well first, I noticed that there was no included ant build file, and it was missing several other things. So first things first...
{sdkdir}/tools/android update project --path [locationToProject]
Will generate your build files and everything else.
But it looks like from trying to build this failed because it wants to import location
com.giderosmobile.android.player.*
You might be missing that dependency or the package is named incorrectly...
[Edit]
I swapped this line:
import com.giderosmobile.android.player.*;
with
import com.giderosmobile.android.player.AudioDevice;
import com.giderosmobile.android.player.JavaNativeBridge;
And it built just fine using 'ant debug'. Hope that helps!
[Edit 2]
Move "gideros.jar" into the libs folder
So, I have tried everything that I know of possible. I ran an export CLASSPATH=/path/to/bin/classes, and it still isn't able to find the output. I've tried running the command from $PWD/bin/classes, the project's root, and STILL am having troubles getting this to work properly. I have the latest version of the ndk (r8-1 at the time of this writing) and the sdk as well. Generating header files via command line, etc.
So far, I've seen Javah error while using Jni, as well as another question which specified the same problem and received the same answers.
I'm running Arch Linux (Archbang, specifically) in x86_64.
Here's my invocation and output (executed from $PROJECT_ROOT/bin/classes):
javah -d ../../jni com.example.fibonnacinative.libfib
Error: Could not find class file for 'com.example.fibonnacinative.libfib'
I've tried with the -classpath, -verbose, etc. flags and neither appear to help. -classpath just spits out the same error, and -verbose does not give me any information apart from the output I've posted.
Halp?
Yup! It was based on my stupidity.
I should have followed casing conventions for LibFib by typing com.example.fibonnacinative.LibFib as opposed to libfib.
Note: the class itself is typically camel case, whereas the rest of the package directive is lowercase. These are just conventions, mind you.
Sorry folks.
There are similar questions addressed here, such as this one, but I've already checked their answers and, after implementing them, javah is still unable to find the javax.microedition.khronos.opengles.*; configuration.
I have my classpath (in eclipse) edited to include the Android SDK API 10 .jar file, so this should work. Is there an external environment variable I need to edit? I've already tried echoing out $CLASSPATH, which appears to be blank, so I have no idea what the issue is here,
and after exporting it to the location of my android.jar file, it still doesn't work.
Thus, I'm at a loss here as of what to do.
What could be done to solve for this? It appears the only issue really is this library, and nothing else.
For android-ndk-r8b and windows 7( 64 bit ) you must write -bootclasspath and point exactly to android.jar file and optionally -classpath. for example:
javah -classpath bin/classes -bootclasspath "C:\android-sdk\platforms\android-8\android.jar" com.example.SanAngeles.DemoRenderer