Can Eclipse use .so files from NDK compilation on another platform? - android

On a mac OS X I run ndk which generates some .so libraries which in theory should be reusable on windows. However, when I eclipse recompile my Android project on windows I get different apk size and it runs differently than when the whole eclipse build is done on Mac. Only building on the mac works. Not taking the .so files from the mac ndk build, and reusing them in the windows build. Its either that or something different about how macs and windows builds apk files that I don't understand. The problem with the windows generated apk is that it has memory over consumption not seen on the apk generated solely on osx.
So to clarify this (ON MAC OS X) works:
1) run ndk on osX generate .so files
2) OS X eclipse compile android app and deploy on device.
3) OS X eclipse run apk on device.
the generated apk of course runs on all devices.
This (ON WINDOWS) does NOT work:
1) on windows use .so generated on osx ndk build.
2) windows eclipse compile android app using the .so files generated by ndk on OS X.
3) eclipse run apk on device. The apk is of a different byte count and although it loads, it now generates memory errors unlike the apk developed solely on the OS X.
Thanks!

You can compile cross platform code (aka NDK) on OSx (MAC) and get *.so, *.a files.
After build Android project (a.e create APK) with Eclipse on Windows.
It should work.
(I did it for Linphone Android with core written on pure C)

Related

Android studio - Call to function from dll file or lib file

I have a lib and dll files (I can choose which file I want to use)
I want to call to functions that are inside the file.
The code that complied in dll/lib wrote at c
dll files (unless the dll is a dot.net dll and you are in a Xamarin app) are not usable in Android.
Furthermore DLL files typically are compiled for x86 (32bit) or x86_64 (64bit) CPUs. The number of Andorid devices with an x86 CPU is next to zero, for Android you need the library compiled for ARMv7 (32bit) and ARMv8 (64bit). As Android is Linux based you need .so files in stead of .dll files.
To make development easier you should install Android Studio + Android NDK (Native Development Kit). Then you have everything for compiling c code in a way that you can make use of it within an Android app.
Google provides multiple sample projects that show how to use NDK: https://developer.android.com/ndk/samples

Is Android SDK version relevant when compiling libraries using NDK?

First step: I use QtCreator to compile a bunch of libraries (.so files) + a GUI test program to test those libraries on an Android device.
Second step: After I tested them, I re-compile the libraries without the GUI test program and send them to a client who's going to integrate those .so file in its own Andoid application (generating and apk), not using QtCreator anymore. I do this step using QtCreator (because it's setup, very easy for me to just remove the GUI test program and hit compile), but I'm pretty sure they could also be compiled directly using ndk-build if I work on writting the correct make files for that.
When I re-compile the libraries, there's still a "Android build SDK" option under "Build Android APK" set to "android-22" in QtCreator. However, my client generates its final app for "android-19". And we are wondering if this could be a problem.
My understanding is that my .so files generated in "second step" are built using the NDK only (SDK is not used, so android API version "android-22" is irrelevant as I do not generate any APK...). So there should be no compatibility issue when those .so files are integrated in an application, as far as the same NDK version is used.
Am I right?

cordova project generates apk in wrong path

I have switched to a mac from a windows. Now when I run 'cordova build android' it is building successfully and generating an apk in /platforms/android/build/outputs/apk/android-debug.apk but this apk isnt working properly.
On my windows machine I go through the exact same steps and it builds a working apk in a different directory - /platforms/android/ant-build/MainActivity-debug.apk.
You can see the the apks are named differently - the one generated from windows machine is right.
I thought it may have something to do with ant but I have the exact same version and it is running on the machine fine. I thought it could have something to do with the ant environment variable as well but I don't think thats it either. This is what I have
/Users/myMachine/apache-ant-1.9.4/bin
Does anyone have any ideas?

How to compile cordova project from visual studio (Hybrid App) to android / ios apk

I try to compile my Cordova Hybrid App from visual studio to apk file
After I deploy the project to Android / iOS the project bin folder still empty.
I try to upload the "www" folder to build.phonegap.com but I get error.
What is the best and correct way to compile the project (HTML, CSS, and JS) to APK for Android and IOS?
Thanks,
Tom
Update:
I try to build from the visual studio
this is my Project folder
When I try to build project from the visual studio on "Device" mode I get this error
1- If you have used Ripple simulator as the target, nothing will be generated in the bin folder. You need to switch the build configuration to "device" in order for the binaries to be generated
2 - The www folder that is generated by the Visual Studio template has nothing special and you shouldn't have issues with PhoneGap Build. If you have errors they are coming from your JS code itself
3 - To build the binaries for Android using the Multi-Device Hybrid extension for Visual Studio, you should be good by simply switching the build configuration to "device" instead of Ripple simulator. For iOS you need to use the Remote Build and Simulation Agent for iOS (which require have a Mac as the iOS tools are NOT available for Windows and you cannot generate the iOS binary directly on your Windows machine. Otherwise, you can consider using PhoneGap Build service
From the image the error looks to be similar to the one I was getting about my device not being recognized/found.
This answer explains how to get the APK directly just by setting the solution to Release, and only Building the project rather trying to do a full deploy to a device. It pretty much is the same answer as mentioned in point 3 above, just tested on a PhoneGap App solution.

Compile native c binaries for Android - Eg: dosfsck

I am trying to compile the binary dosfsck and mkdosfs for Android, using Linux and Android NDK and SDK. I've setup NDK and SDK properly, the path to the NDK gcc is in my path. I've also downloaded the correct SDK for my device (HTC Desire).
I first tried compiling the file with a simple make:
make
CROSS_COMPILE=/home/droidzone/android/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
I need to be able to run the binary from my device. As it is, the app compiles and runs on Ubuntu, but not my device. I get the error message from sh: Cannot run binary
Could someone please explain how I can link libraries, where I should get them from (within the SDK) and what changes if any to make to the Makefile, and the final syntax to compile this properly for Android
I found this was easiest to do using the agcc script script which you can use by exporting CC=agcc. Lots of projects will not properly support CROSS_COMPILE as you have tried. The agcc script is oriented around using the Android build tree files so I modified it to use the NDK tools. With this you should be able to build most things using make CC=agcc or CC=agcc ./configure

Categories

Resources