I know that if a C++ project has CMakeLists.txt, I can create a new project and use Android studio to compile the executable to run on Android via console.
However, some projects don't have CMakeList.txt and need to run . /configure and then make. e.g. https://github.com/strukturag/libheif
Is there a easy tool that can compile it for Android on Windows?
The following assumes that you have mingw installed and also a cross-compiler compatible with your platform. Also, I'm not a big fan of Windows for this type of development. So my explanation is for Linux. But I believe you can easily adapt it to your case.
First of all, you need to install a cross-compiler. For the sake of explanation, I'm going to use gcc-linaro here.
If you open the repo, you'll see that there is a file called autogen.sh.
You will need to run it. This file will create the configuration tool.
Once it finishes, a file called configure will appear.
This is the tool you want to use for configuring the library to be compiled, customized for your specific needs.
The next command you want to run is
./configure --help
The above command will show you all the options that you can set. You can play with them but, typically, you want to set the following, at least:
CC
--prefix
--includedir
--libdir
--host
These options are explained in the configure tool. To give you an idea on how to use them, the following is the generic command that you might want to run:
CC="<path to your gcc compiler>" ./configure --prefix="<path_to_the_folder_where_you_want_to_install>" --includedir="<path_to_the_include_dir>" --libdir="<path_to_the_lib_dir>" --host=arm
In my situation, I have installed the cross compiler at the following path
/home/alexis/gcc-linaro/bin/arm-linux-gnueabi-gcc
Therefore, I would need to run the command:
CC="/home/alexis/gcc-linaro/bin/arm-linux-gnueabi-gcc" ./configure --prefix=/home/alexis/gcc-linaro --includedir=/home/alexis/gcc-linaro/include --libdir=/home/alexis/gcc-linaro/lib --host=arm
Hope this helps.
Related
I do not use any Android features of Qt, my only purpose is to program some little softwares for Windows with minGW and QMake, no other project configurations is relevant for my needs. I'm simply curious if I missed a part, it does not affect the fonctionnality.
Project ERROR: You need to set the ANDROID_NDK_ROOT environment variable
to point to your Android NDK
And a bunch of other errors like that. Its my 4th clean install of 4 different version of Qt bundle, (now I carefully unselect everything except minGW32 and it still showing up!) God's sake why?
Did I missed a part on How to use Qt? Do I need extra-steps to remove it manually on a project creation?
If you want to code for Windows: just setting up your project with default setting (without Android/IOS setting).
If you want to code for Android: The problem was that the file wasn't the correct NDK file. Make sure you get the correct NDK from the website. Other than that it is pretty easy just unzip it and that directory is the root directory.
So if I understand, I can't remove "Android options" from Qt as it is pre-installed for all platforms.
Then yes, even if I don't use it, I must install Android NDK. Then continue to unselect the kit. Then these Error messages will disapear.
Is there a way to build AOSP's /platform/frameworks/base package source or support library source separately in Android Studio.
I wanted to read the framework (base and support) code in Android Studio and since I didn't want to be bothered about the rest of the packages in AOSP, I only imported the mirrored repo of these two packages as two separate projects in Android Studio. I want to browse through the code by using "jump to source" shortcut (cmd/ctrl+click) of the IDE. But this handy feature won't simply work properly in Android Studio. When I try to jump to the method definition which belongs to a different java source file (It says - "Cannot find declaration to go to"). This limitation of source editor is due to gradle build failure. The project just won't build and throws the following error.
Error:You need a symlink in prebuilts/sdk/99 that points to
prebuilts/sdk/current.Without it, studio cannot understand current
SDK. ln -s ../../prebuilts/sdk/current ../../prebuilts/sdk/99
Is there a way to fix this. I know I can simply browse the source code on http://androidxref.com/ too, but it's not as convenient and powerful as your IDE.
This is possible (having Android Studio be able to show you the framework code and let you use the usual IDE tools), though compiling won't work.
But the detail in your question seems to indicate you don't actually care about compiling, just about viewing/editing.
The first steps listed here:
http://ronubo.blogspot.com/2016/01/debugging-aosp-platform-code-with.html
might work for you. Basically:
Build your AOSP platform
( . build/envsetup.sh && lunch - && make ...)
Create the Android Studio project for importing to
( mmm development/tools/idegen && development/tools/idegen/idegen.sh )
Import the project
( open android.ipr from Android Studio)
Not without a huge effort.
For very many reasons.Ex:
1.the framework depends on different HALs and libraries from system/bionic/external
2.Compiling the framework uses specific tools from linux(flex,bison,libgl etc..)
3.Framework is built using the Android.mk system and needs a lot of flags and compilation macros from build/
I also can't imagine a motivation to do what you are trying to do. If it's going to run on any device, bare in mind device manufacturers modify the framework heavily, even the small ones. Actually the chipset manufacturers modify it and give it to manufacturers that modify it even more.
Error:You need a symlink in prebuilts/sdk/99 that points to prebuilts/sdk/current.Without it, studio cannot understand current SDK. ln -s ../../prebuilts/sdk/current ../../prebuilts/sdk/99
This notice already tell you should run the command:
ln -s ../../prebuilts/sdk/current ../../prebuilts/sdk/99
To tell build system use 'current version sdk' in prebuilts/sdk/current directory replace the temp sdk version 99.
could you try it?
Since there are a few commands missing on Android, I want to build them by myself.
Take one as an example:
There is no dig command on Android.
I've got the source code from ftp://ftp.isc.org/isc/bind9/9.2.3/bind-9.2.3.tar.gz and then I want to build it. But I got stuck.
How can I build the executable on my linux machine?
You can do it in two ways.
To build any C Source code for Android Platform you can use Android NDK Toolchian, It lets you build Native code for another platform.
It can be used as a stand-alone compiler without an Android APK.
Documentation and Sample Code.
To build it as an executable (without APK) and not shared object, replace include $(BUILD_SHARED_LIBRARY) with include $(BUILD_EXECUTABLE) in Android.mk.
For Linux commands on Android you can use Busybox.
It supports most of the commands.
However dig is not supported in busybox, you can add it by following this article.
Hopefully this gives you a start.
Hello there is one question which comes in my mind from last 2 days. Can we compile our android project without Eclipse? If yes then what is alternatives? Please share it.
one option is ant, and an extremely reduced tutorial goes like this:
first update your project with a proper build script and all the files that ant needs, you can do that with just one command, for example
android update project -p . -t android-10
this command has many options, feel free to browse for those options.
after that just do
ant debug
or
ant release
depending on what you want to produce, again, ant has other variations and you can easily discover them with the Android docs.
If you are developing in a non-Eclipse environment, you can build your
project with the generated build.xml Ant file that is in the project
directory. The Ant file calls targets that automatically call the
build tools for you.
Look at Here for more details.
cd /path/to/my/app
ant release
it will ask you every time for your private key to sign the app, it can be configured to auto-sign by editing "build.properties" file:
key.store=release.keystore
key.alias=release
key.store.password=my_key_password
key.alias.password=my_key_password
you can also investigate Android SDK, find the ANT build scripts it actually uses, and insert your custom obfuscator/optimizer call in middle of build process.
For people that are not used to coding in java and want to use HTML/JavaScript and CSS to build native apps for android -- you can use PhoneGap -- you can upload your code in a zip and get an APK. Currently its in beta, and thats why free.
https://build.phonegap.com/
Other Phone OSes are also supported. Its pretty interesting.
You can use maven with the maven android plugin http://code.google.com/p/maven-android-plugin/. Afterwards you can use any IDE that supports maven (NetBeans, Eclipse, IntelliJ IDEA).
If you just do not want to use Eclipse IDE you can choose other IDE like IntelliJ IDEA.
I want to use some unix tools on my rooted android arm6 based phone. I will be using cross compiler tools provided here. If I want to compile gnu netcat, how can I set the cross compiler prefix to arm-none-linux-gnueabi- and how to enable static linking (no shared library).
I managed to cross-compile rsync for Android using Ubuntu's arm-linux-gnueabi toolchain. See this related question.
Unless you particularly need to build against a more standard libc than bionic, you can just use the ndk's toolchain, either by copying the hello-jni example and changing BUILD_SHARED_LIBRARY to BUILD_EXECUTABLE in the jni/Android.mk or using the script to generate a stand alone toolchain. You may want to use the V=1 option to the ndk-build script to see the commands it's issuing to its gcc.
Otherwise you may need to pass the prefix to the configure script or manually edit it into the Makefile for the project. This often has not gone well as many projects have make systems not really set up for cross compiling, I've had to resort to editing the configure script to set prefixes and skip tests where it tries to execute a test program.
An option that sometimes works when the build system is more complicated than the project requires is to do a configure for your host (let's hope that's linux). Then manually edit the generated Makefile to change anything needed to build for android instead. Might not be a bad idea to do a clean just in case (especially if you did a test host build). And then do the build which will pick up the arm compiler from your Makefile modifications.
Lastly, if you can be content with the original netcat by Hobbit rather than the gnu version, you hardly need to port it to android yourself as that's already been done. There's already an android version in the google tree at https://android.googlesource.com/platform/external/netcat
which may be on your device already (as 'nc'), and is definitely included in alternate ROMs such as Cyanogenmod.