Developing a Qt app for Android from the command line - android

I would like to compile and deploy on an Android device a simple helloworld program written using Qt purely using vi/emacs and the OS X command line, without using QtCreator or Android Studio.
This page describes how to fill in values for ANDROID_SDK_ROOT, ANDROID_NDK_ROOT, etc, before compiling Qt5. I have in the past used QtCreator to compile for Android without having to compile Qt itself, and I'm now wondering whether it's possible to use a command-line toolchain to do the same.
The steps I've taken so far are:
Installed the Android SDK.
Installed the Android NDK.
Installed Qt5 by sudo port install qt5-mac.
After this last step, I duly see /opt/local/share/qt5/mkspecs/android-g++, which suggests that the first step ought to be qmake -spec android-g++.
Have you successfully compiled on OS X and deployed to Android a Qt project from the command line without having to compile Qt itself?
Update
Running sudo port install qt5-mac on OS X appears not to install Qt-for-android. Download instead qt-opensource-mac-x64-1.6.0-8-online.dmg. Mount/run. Click until Select Components. Make sure Android armv7 is selected.

What you need:
- Java JDK
- Apache ANT
- Android SDK
- Android NDK
- Qt for Android
Set the environment variables (change accordingly):
export ANDROID_HOME=/Path/To/AndroidSDK
export ANDROID_NDK_HOST=linux-x86
export ANDROID_NDK_PLATFORM=android-12
export ANDROID_NDK_ROOT=/Path/To/AndroidNDK
export ANDROID_NDK_TOOLCHAIN_PREFIX=arm-linux-androideabi
export ANDROID_NDK_TOOLCHAIN_VERSION=4.8
export ANDROID_NDK_TOOLS_PREFIX=arm-linux-androideabi
export ANDROID_SDK_ROOT=/Path/To/AndroidSDK
export ANDROID_API_VERSION=android-12
export JAVA_HOME=/Path/To/JavaJDK
export PATH=$PATH:$ANDROID_HOME/tools:/Path/To/ApacheANT/bin:$JAVA_HOME/bin
If you're on OS X, use the following line instead:
export ANDROID_NDK_HOST=darwin-x86_64
Build for Android:
mkdir build_myproj_android
cd build_myproj_android
/Path/To/QtForAndroid/bin/qmake -r -spec android-g++ /Path/To/MyProject/MyProject.pro
make
make install INSTALL_ROOT=android
/Path/To/QtForAndroid/bin/androiddeployqt --output android --verbose --input android-libMyProject.so-deployment-settings.json
And finally, deploy using:
/Path/to/AndroidSDK/platform-tools/adb install /Path/to/build_myproj_android/android/bin/QtApp-debug.apk

Thanks Marian that has wrote a complete response. just if you are going to sign your package too, say it to androiddeployqt by:
/Path/To/QtForAndroid/bin/androiddeployqt --output android --verbose --input android-libMyProject.so-deployment-settings.json --sign <url/to/keystore> <alias> --storepass <password>

Related

How to use Espeak in my Android app?

I tried to do what the instructions say here: https://github.com/rhdunn/espeak#android But as I am in Win10, and use Android Studio 2.3, don't know how to do these things in Windows? (Isn't there any step-by-step instructions for windows?)
Building with Gradle
Set the location of the Android SDK:
$ export ANDROID_HOME=<path-to-the-android-sdk>
Build the project:
$ ./autogen.sh
$ ./configure --with-gradle=<path-to-gradle>
$ make apk-release
This will create an android/build/outputs/apk/espeak-release-unsigned.apk file.

Unable to run the cocos2dx sample game from android studio

I try to run the cocos2dx sample program but I get the following error Is there something wrong with the path or the setting ? I would love to hear from you!
Mic-no-MacBook-Pro:CocoFolder mic$ cocos run -s ~/Desktop/CocoFolder/NewGame -p android --android-studio
/Users/mic/.bash_profile: line 8: export: `PATH:/Users/mic/Downloads/adt-bundle-mac-x86_64-20140702/sdk:/usr/local/lib/node_modules/ant/ant/bin:/usr/local/lib/node_modules/ant/ant:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/mic/Desktop/CocoFolder/cocos2d-x-3.14.1/tools/cocos2d-console/bin:/Users/mic/Desktop/CocoFolder/android-ndk-r14b:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home:/usr/local/lib/node_modules/ant/ant:/usr/local/lib/node_modules/ant/ant/bin': not a valid identifier
/Users/mic/.bash_profile: line 11: export: `PATH:/Users/mic/Downloads/adt-bundle-mac-x86_64-20140702/sdk:/usr/local/lib/node_modules/ant/ant/bin:/usr/local/lib/node_modules/ant/ant:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/mic/Desktop/CocoFolder/cocos2d-x-3.14.1/tools/cocos2d-console/bin:/Users/mic/Desktop/CocoFolder/android-ndk-r14b:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home:/usr/local/lib/node_modules/ant/ant:/usr/local/lib/node_modules/ant/ant/bin': not a valid identifier
Building mode: debug
Using Android Studio project : /Users/mic/Desktop/CocoFolder/NewGame/proj.android-studio
running: '/Users/mic/Downloads/adt-bundle-mac-x86_64-20140702/sdk/tools/android update project -t android-13 -p /Users/mic/Desktop/CocoFolder/NewGame/proj.android-studio/app'
*************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
Invalid or unsupported command "update project -t android-13 -p /Users/mic/Desktop/CocoFolder/NewGame/proj.android-studio/app"
This is inside the bash profile
export ANT_HOME=/usr/local/lib/node_modules/ant/ant
export PATH=$ANT_HOME:$PATH
export ANT_ROOT=/usr/local/lib/node_modules/ant/ant/bin
export PATH=$ANT_ROOT:$PATH
export ANDROID_HOME=/Users/mic/Downloads/adt-bundle-mac-x86_64-20140702/sdk
export PATH:$ANDROID_HOME:$PATH
export ANDROID_SDK_ROOT=/Users/mic/Downloads/adt-bundle-mac-x86_64-20140702/sdk
export PATH:$ANDROID_SDK_ROOT:$PATH
export ANT_HOME=/usr/local/lib/node_modules/ant/ant
export PATH=$ANT_HOME:$PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
export PATH=$JAVA_HOME:$PATH
export NDK_ROOT=/Users/mic/Desktop/CocoFolder/android-ndk-r14b
export PATH=$NDK_ROOT:$PATH
export COCOS2D_CONSOLE_ROOT=/Users/mic/Desktop/CocoFolder/cocos2d-x-3.14.1/tools/cocos2d-console/bin
export PATH=$COCOS2D_CONSOLE_ROOT:$PATH
compile run -p android --android-studio doesn't work because it also depends on android.bat utility.
You're using Android SDK tools build 25.3.X version and now, the android command is gone.
Android SDK tools release note here. The android command & ant scripts are removed.
One solution is downgrade to previous version (25.2.3) of SDK tools from this page:
https://developer.android.com/studio/index.html (see the bottom of the page)
and then replaced tools folder in the Android sdk with the previous one.
Another solution download cocos2d-console from GitHub repo (v3 branch) and extract all files and put into /cocos2d-x/tools/cocos2d-console folder after deleting old files of cocos2d-console folder.

Can i build Linphone in Android Studio on Mac?

I think we can build it. But I am getting error to build it on Android Studio. First I download the Android Studio and NDK. Then add the PATH of Android Studio and NDK to the PATH Variable. When I run
./check_tools.sh
I get the output
Could not find automake. Please install it.
Could not find autoconf. Please install it.
Could not find pkg-config. Please install it.
Could not find ant. Please install it.
Could not find yasm. Please install it.
Could not find wget. Please install it.
Could not find libtoolize. Please install libtool.
Invalid version of nasm: your version does not support elf32 output format. If you have installed nasm, please check that your PATH env variable is set correctly.
Failed to detect required tools, aborting.
But i doubt whether i need these tool on Android Studio or not. When I run the project i get the error
java.lang.UnsatisfiedLinkError: Couldn't load linphone-armeabi-v7a: findLibrary returned null.
Can anybody tell me the solution for that.
Yes you can do this
follow the step by step guide at this blog
How to build culinphone on Android Studio using Mac OS X?
http://culinphone.wordpress.com
Here is a step to step guide.
Setup Linphone Sdk on Mac OS X
How to build Linphone in Android Studio on Mac?
Step by step guide :-
Required Knowledge :-
Android Tools
Android Studio
A little bit about mac-terminal(shell)
S/W Requirements:-
Mac OS-X with these tools (You definetely need these tools to build linphone) :-
coreutils, automake, autoconf, libtool, intltool, wget, pkgconfig ,cmake,
gmake, yasm, grep, doxygen, ImageMagick, optipng, antlr3
STEP 1:-
Concerning these useful tools you can install the tools with this command
$sudo port install coreutils automake autoconf libtool intltool wget pkgconfig cmake gmake yasm grep doxygen ImageMagick optipng antlr3
STEP 2:-
Check out these Instructions how to upgrade nasm
STEP 3:-
Then install ant by typing
brew update #update if already installed
brew install ant
If you haven’t installed brew just type command give below
its a medium size download which takes 5 mins to download
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Just follow the process which involves installing various components. If you already have brew installed, make sure it’s up to date by executing:
brew update
Once installed you can simply type:
brew install ant
STEP 4:-
Now its time to install libtool. To install libtool run the command given below
curl -OL http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz
tar -xzf libtool-2.4.2.tar.gz
cd libtool-2.4.2
./configure && make && sudo make install
STEP 5:-
if you have not installed these programmes download and install
Download Android Studio & SDK
Download Android NDK
STEP 6:-
Download git repository of LInphone Android by running command
$ sudo git clone git://git.linphone.org/linphone-android.git –recursive
Now everything is configured perfectly
STEP 7:-
Open terminal and cd into linphone-android
Now when you get into the directory on terminal then check your PATH of SDK & NDK installed on your Mac run
$ echo $PATH
if you see the path with SDK and NDK location then it’s ok to proceed skip the below part and if not then you need to setup the PATH before you execute the make and make install script in
To setup path use:-
$export PATH=/Users/<yourusername>/android-sdks/platform-tools/:/Users//android-sdks/tools/:/Users//Documents/ndk/:/nobackup/local/prog/nasm/bin/:$PATH
it’s like export PATH=(Path of your SDK platform tools folder):(Path of your SDK tools folder):(Path of your NDK folder):$PATH
This will set up the path and to confirm again run
$ echo $PATH
Now if the Path is already setup you can simply run
$ make
Now connect your Device to you Mac and see if eclipse has detected it. After the device is connected run:
$ make install
Now if everythink is OK:-
After you have made your build then now you can import it into your Android Studio.
Open Android Studio
Import Project (Eclipse,ADT,Gradle,etc.) > select linphone-android > OK
I am able to build the limphone on mac by follow the steps describe here :-
Linphone for android is not working/missing libraries
You definetely need these tools to build linphone.
Concerning nasm I had the same problem. You can use this site that instructs you how to upgrade to a newer nasm:
Instructions how to upgrade nasm
Concerning other useful tools you can install the tools below with this command:
$sudo port install coreutils automake autoconf libtool intltool wget pkgconfig cmake gmake yasm grep doxygen ImageMagick optipng antlr3
All these are found in the linphone build instructions README.md file.

Cannot build Phonegap project from command line

I have built a Phonegap app and am now trying to integrate it with Phonegap Build. I'm following the very simple guide here.
So I am doing:
sudo npm install -g phonegap
sudo phonegap create hello com.example.hello HelloWorld
cd hello
sudo phonegap local build android
The last command results in the error:
The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: /bin/sh: 1: android: not found
I then did:
which android
with the result:
/home/mark/Development/adt-bundle-linux-x86_64-20130522/sdk/tools/android
which is the corrent path.
The phonegap version is 3.1.0-0.15.0.
Any ideas why I am getting this error?
Edit
If I run:
sudo phonegap local build /home/mark/Development/adt-bundle-linux-x86_64-20130522/sdk/tools/android
I get yet another error:
/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:141
platformPath = path.join('.', 'platforms', platform.local);
^
TypeError: Cannot read property 'local' of undefined
at LocalBuildCommand.module.exports.addPlatform (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:141:60)
at LocalBuildCommand.execute (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:95:32)
at LocalBuildCommand.run (/usr/local/lib/node_modules/phonegap/lib/phonegap/local.build.js:70:10)
at Object.build (/usr/local/lib/node_modules/phonegap/lib/phonegap/util/command.js:28:25)
at CLI.module.exports (/usr/local/lib/node_modules/phonegap/lib/cli/local.build.js:34:20)
at CLI.module.exports [as argv] (/usr/local/lib/node_modules/phonegap/lib/cli/argv.js:66:17)
at Object.<anonymous> (/usr/local/lib/node_modules/phonegap/bin/phonegap.js:24:21)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
Laters version of android sdk moved adb to platform-tools. Try to include both tools and platform-tools in your path. see
~/Tools/adt-bundle-linux-x86_64-20131030/sdk $ cat tools/adb_has_moved.txt
The adb tool has moved to platform-tools/
If you don't see this directory in your SDK, launch the SDK and AVD
Manager (execute the android tool) and install "Android SDK
Platform-tools"
Please also update your PATH environment variable to include the
platform-tools/ directory, so you can execute adb from any location.
I use following export commands.
export ANDROID_BUNDLE_HOME="$ATILLA_TOOLS/adt-bundle-linux-x86_64-20131030"
export ANDROID_SDK_HOME="$ANDROID_BUNDLE_HOME/sdk"
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
export PATH=$PATH:$ANDROID_SDK_HOME/tools
export PATH=$PATH:$ANDROID_SDK_HOME/platform-tools
both adb and android should work in command line. Also try to use
phonegap local build android
without sudo.
see following example
$phonegap create deneme1
[phonegap] created project at /home/atilla/Projects/Denemeler/a/deneme1
$cd deneme1/
$phonegap local build android
[phonegap] adding the Android platform...
[phonegap] compiling
Android... [phonegap] successfully compiled Android app
After this successful message try to find your platform and apk file.
$ls -al platforms/
$ls -al platforms/android/
$ls -al platforms/android/bin
you should see HelloWorld-debug.apk in this directory.
-rw-r--r-- 1 atilla atilla 1542462 Ara 5 14:31 HelloWorld-debug.apk
install the phonegap npm global package with sudo, it's ok.
But then you should run phonegap with your own user
sudo npm install -g phonegap
phonegap create hello com.example.hello HelloWorld
phonegap local build android
executing with sudo you are switching to root user therefore environment variables as $PATH are not necessarily the same.
Try to Add your Android Path to your PATH Enviroment Variables.
if you use Linux, first try:
echo $PATH
This command display your PATH variable, search the Android path on this.
If you don't see the android path, you need to add that path on your enviroment variable.
Try this:
echo 'export PATH=$PATH:/home/user/mis_prog' >> /home/user/.bashrc
You must edit the configuration file of your login shell.
As usually the BASH shell is the most used, you must edit your /home/user/.bashrc.
For this you will use a text editor or just a command to make the task easier.
If you use some Windows Version, you can edith the enviroment variable PATH from system propertyes, something like this: http://www.computerhope.com/issues/ch000549.htm

Error executing command 'ant' on Mac OS X 10.9 Mavericks when building for Android with PhoneGap/Cordova

Today I tried PhoneGap/Cordova with Mac OS X Mavericks. Building for iOS went just fine, but building for Android wasn't without some guesswork.
I installed Android 4.2.2 via the Android SDK Manager (I had to use the older API v17 since it wasn't compatible with a newer one), added the PATH environment variables for the SDK's platform-tools and tools and thought I was ready to take off by running the command:
phonegap run android
Nevertheless, I got the following error:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project. ERROR : executing command 'ant', make sure you have ant installed and added to your path.
The error message proved to be true as Apache Ant isn't in the path of Mac OS X Mavericks anymore.
Bulletproof solution:
Download and install Homebrew by executing following command in terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install Apache Ant via Homebrew by executing
brew install ant
Run the PhoneGap build again and it should successfully compile and install your Android app.
You can install ANT through macports or homebrew.
But if you want to do without 3rd party package managers, the problem can simply be fixed by downloading the binary release from the apache ANT web site and adding the binary to your system PATH.
For example, on Mountain Lion, in ~/.bash_profile and ~/.bashrc my path was setup like this:
export ANT_HOME="/usr/share/ant"
export PATH=$PATH:$ANT_HOME/bin
So after uncompressing apache-ant-1.9.2-bin.tar.bz2 I moved the resulting directory to /usr/share/ and renamed it ant.
Simple as that, the issue is fixed.
Note Don't forget to sudo chown -R root:wheel /usr/share/ant
As an alternative to homebrew, you could download and install macports. Once you have macports, you can use:
sudo port install apache-ant
it don't needed port and brew!
because you have android sdk package.
.1 edit your .bash_profile
export ANT_HOME="[your android_sdk_path/eclipse/plugins/org.apache.ant_1.8.3.v201301120609]"
// its only my org.apache.ant version, check your org.apache.ant version
export PATH=$PATH:$ANT_HOME/bin
.2 make ant command that can executed
chmod 770 [your ANT_HOME/bin/ant]
.3 test if you see below message. that's success!
command line execute: ant
Buildfile: build.xml does not exist!
Build failed
I encountered the same issue when trying to use Cordova. Turns out I already had brew, try which brew, but it was outdated. So, I had to update it first:
Update brew: brew update
Install Apache Ant: brew install ant
In my case, I have macport installed already. I simply updated my macport:
sudo port selfupdate
sudo port upgrade outdated
Then install apache-ant:
sudo port install apache-ant
Finally, I add ant to my alias list in my .bash_profile:
alias ant='/opt/local/bin/ant'
Then you are all set.
For OSX your path needs to include /Users/yourusername
their example: /Development/adt-bundle/sdk/platform-tools
needs to be: /Users/yourusername/Development/adt-bundle/sdk/platform-tools

Categories

Resources