Android NDK APP_BUILD_SCRIPT Error - java

I'm new to Android NDK and i've faced this error that
"APP_BUILD_SCRIPT points to C:\abc\xyz/jni/Android.mk"
I searched all the questions wasn't able to find the answer. However by just goofing around i was able to generate the jni library.
I did the following changes
1) I added a user variable APP_BUILD_SCRIPT which points to my project's Android.mk. eg.
C:\abc\src\jni\Android.mk
2) I added another user variable NDK_PROJECT_PATH to the src folder of my project. eg.
C:\abc\src
This src folder will have a folder named jni which contains my Native.c file and Android.mk.
And when I compiled, I saw a libs folder containing armeabi\lib_filename.so
However now when I run the program it throws an error "UnsatisfiedLinkError"
How do I tackle this?
Also for each project I have to change my user variables can anyone tell me a way to solve these issues.
Information:
I followed this example: How to use NDK in android project?
Just add my steps to it and you should be able to generate .so file.

Related

Android - failed to generate Javadoc with Android Studio Bumblebee

I'm trying to generate Javadoc using latest Android Studio via built in tool:
Tools=>Generate Javadoc...
Whatever I choose from a tool's parameters window there are a lot of errors thrown, regarding to the scope I choose it varies from 50 to 100 and all of them related to Android OS or Dalvik VM. Here are some of them:
error: package android.util does not exist
error: cannot find symbol ... symbol:class Context
error: package android.app does not exist
error: package dalvik.system does not exist
Target Android SDK is 31. Latest Java release installed. Did someone experienced the same issue? What am I doing wrong?
Thanks in advance.
First of all, sorry for my English (I use Google translation).
I just spent 5 days on this error and found a solution that works (for me...).
The latest versions of Android Studio (including Bumblebee) do not generate technical documentation correctly. Here is the procedure to generate it correctly.
In Android Studio, open the project.
First of all, identify all R imports and just replace R with * (example: import com.example.coah.*).
Start by following the classic javadoc generation process:
Tools > Generate JavaDoc
scope : Module
uncheck "Include JDK and library sources in -sourcepath"
Output directory : give the path to the folder that will receive the doc (create this folder beforehand outside the project folder)
Other command line arguments : -encoding utf8 -docencoding utf8 -charset utf8
Make OK. Normally documentation generation failed with "exit code 4".
In the output window, at the very top and on the very right (drag the horizontal scrollbar), click on
"#C:\Users\xxx\AppData\Local\Temp\javadoc_args" :
You get a preview of the contents of the file.
Copy the content and paste it into a text file.
Open the file.
It starts with "-classpath" followed by quotes and a list of file paths. The problem comes from the fact that in this list, the android.jar file is missing, which is normally found in:
C:\Users\xxx\AppData\Local\Android\Sdk\platforms\android-32\android.jar
Check the presence of this file in the user folder (replace xxx by the name of the user) : it may not be android-32 but android-30, or other. Once the right path has been found, it must be added to the classpath, in the first position, just after the quotes and without forgetting to add a ";" at the end to separate it from the next path. Please note that the "" must also be replaced by "/".
Save file.
Open a command window in admin mode and go to the project folder, src\app\main\java folder.
Still in the javadoc output window in Android Studio, copy the first complete command line (which generates the doc) and paste it into the command window, replacing just what is after # with the path to the file text that has just been created (which contains, among other things, the classpath).
It is possible that there are errors and warnings, but the doc is still generated.
Emds
Emds solution helped a lot over here, using it we can solve this problem more easily.
As they said here, main problem is android.jar file is not being included in classpath somehow. So to resolve this we can simply copy path of android.jar (with name too) and then generate a dependency in project for it.
To do this go to File -> Project Structure -> Dependencies
There click on + sign in "All Dependencies" section and select "Jar/AAR Dependency".
Then select "app" for module and in next screen enter android.jar path (path you copied before) and click OK.
Build gradle again and generate Javadoc. It should do the trick.

how to include sqlite4java in android project

I am trying to use sqlite4java in my android project. the following screenshot shows my project's setup:
As you can see i have copied the jar-file into my libs folder and included it in the build path. I have also copied the docs and the src-file as per the docs for sqlite4java. The zip-file i downloaded also contains a library-file called libsqlite4java-android-i686.sothat i included in the libs directory. what i get when i try to run my project (it will compile without complaining) is the follwing error message:
03-04 07:37:13.251: W/System.err(2419):
com.almworks.sqlite4java.SQLiteException: [-91] cannot load library:
java.lang.UnsatisfiedLinkError: Couldn't load sqlite4java-android-i686
from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data
/app/de.redhouse24.android-2.apk"],nativeLibraryDirectories=[/data
/app-lib/de.redhouse24.android-2, /system/lib]]]: findLibrary returned
null
As you can see the file sqlite4java-android-i686.socannot be found. Being wiley, i renamed the libsqlite4java-andriod-i686.so file to sqlite4java-android-i686.so, which is why my project structure shows that name for the file. TBH, i renamed it because i found the suggestion in this discussion:
https://code.google.com/p/sqlite4java/issues/detail?id=42
I also tried to include the so-file in the build path, but that just stopped my project from compiling.
My question: What do i need to do to use sqlite4java in my android project?
Im using a mac and eclipse with adt, if that makes any difference.
First of all, renaming the library will not help you. Do not rename the library, leave the name as it was.
Second, you only have the 686-lib there.
If you intent to run your app on something other than an atom-based device, you will have to add the so-files for the other architectures as well.
Each architecture's so-files resides in a sub-directory under the libs directory, like this:
libs/x86
libs/armeabi
libs/armeabi-v7a
Put your libsqlite4java-android-i686.so file there, and also possible other .so files it might need as a dependency, and it should work.
Including the sources and docs into the libs-folder somewhat eludes me. That will only bloat your final apk file, which should be avoided.
Your users will be thankful.

IInAppBillingService.aidl cannot generate Java file in Android Studio

I am trying to use in app product purchase in Android App, I tried to put IInAppBillingService.aidl in many places but no one generates the Java file , here is my structure of App:
Could someone help me to find where I am wrong ?
Note: I am use using Android Studio.
There is some misplacement of directories in your project as shown in attached screenshot.
Your main directory should be inside the src directory and IInAppBillingService.aidl must be on the below mentioned path
/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl
so create a directory inside your main and then create the package as mentioned and put your .aidl file inside.
Make the necessary changes and sync Your project with gradle.
I was looking for it on the aidl folder which was wrong assumption.The java file will generate on the build, source, aidl folder.. hope this helps

where should i place bluecove-2.1.0 folder

I am trying to write a project that communicates with a Bluetooth device and receives information from it. I googled it and from what I understood I had to get a package named 'bluecove' which will contain all I need. I downloaded the jar file, and (in Eclipse) by right-clicking on 'my project>build path>jar file>bluecove', I added the jar file into my project. When I try to run some lines of code, it gives me an error that says that some content is unavailable:
Native Library intelbth_x64 not available
Native Library bluecove_x64 not available
Then I went back to the bluecove website and i saw there another Windows file for download called 'bluecove-2.1.0-sources.tar.gz'
here is a link:
http://code.google.com/p/bluecove/downloads/list
When I downloaded it, there was a folder inside named 'bluecove-2.1.0' which I think I have to copy into one of the system's folders. What should I be doing here?
Thanks
p.s i will need the answer as soon as possible - in the next 9 hours at most, please help me
and again thanks
As stated here (commented by oxc), you need to download the .jar specified: http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/2.1.1-SNAPSHOT.62/

How do I use APV PDF Viewer

So I want to view PDFs in my app and I've come across APV PDF, but I just can't understand the instructions on how to use it
http://code.google.com/p/apv/wiki/Building
Why isn't it a jar library to download?
Why do I have to compile some .so files, why can't I download them?
I browsed the source and there is a demo application here:
http://code.google.com/p/apv/source/browse/#hg%2Fpdfview
I copied that into eclipse as an Android project and it compiles but I get an error when I run and select a PDF in the compiled app
java.lang.UnsatisfiedLinkError: parseFile
I understand this has something to do with what I've asked above, so hopefully I'll get some answers.
This probably has something to do with the NDK which I have no experience with.
My mind has been expanded!
1) You can't have a Jar as this is C code, so it is going to run in the NDK therefore the equivalent is a .so file.
2) I don't know why they don't let you just download an .so file (as well as having the source), but it seems this project is just a starter project i.e. you are expected to take the source and modify it. Therefore if you just had a .so file you could not do this. Each time you change the source code in /jni/pdfview2 you have to rerun the script build-native.sh and that will recreate your library (.so) files for you!
I was getting the UnsatisfiedLinkError as the .so library I was using was built against a different version of the code than that which the Java file was trying to reference. Therefore my link was un-satisfied!
Hazar!

Categories