I'm using Qt 'qmake' from the command line (no use of QtCreator) am building for an Android target. No matter what I do it seems to use Android API level 9 in the Makefile it generates. Is there a command-line option, environment variable, or other method I can use to tell qmake to use a specific Android API level. I've been searching for a long time and cannot find anything.
Change environment to ANDROID_NDK_PLATFORM=android- the api-level you want or in QtCreator->Project->Build Environment->Add/update the above variable.
To choose a specific minimum API level, you need to provide your own Android manifest file.
I know you're not using Qt Creator, but it supports this by being able to generate a new manifest file from a template.
More details available from the Qt Docs on deploying to Android:
http://doc.qt.io/qtcreator/creator-deploying-android.html
You can specify settings for the androiddeployqt tool in Qt Creator and in the project .pro file. To specify settings in Qt Creator, select Projects > Build Android APK > Details.
...
You can use the qmake variables to specify all the settings you need for the androiddeployqt tool and you do not need an Android manifest file until you want to publish the package in an application store. To specify additional settings for APK packages, you can create an Android manifest file and edit it in Qt Creator. Select Create Templates to create the file and to open it in the Android Manifest Editor.
If you're not using Qt Creator you'll presumably need to generate an Android manifest file manually and place it in your source directory. androiddeployqt should pick it up.
ANDROID_PACKAGE_SOURCE_DIR: This variable can be used to specify a directory where additions and modifications can be made to the default Android package template. The androiddeployqt tool will copy the application template from Qt into the build directory, and then it will copy the contents of the ANDROID_PACKAGE_SOURCE_DIR on top of this, overwriting any existing files.
...
If you, for instance, want to make a custom AndroidManifest.xml for your application, then place this directly into the folder specified in this variable.
...
Note: When adding custom versions of the build files (like strings.xml, libs.xml, AndroidManifest.xml, etc.) to your project, make sure you copy them from the package template, which is located in $QT/src/android/java. You should never copy any files from the build directory, as these files have been altered to match the current build settings.
Related
I am compiling a ROM from source (say CM12.1)
I have obtained the source code and am ready to build.
However I wish to add an app (say ES file explorer) as a user app and another app(say Titanium) as a system app. Also I need to copy a file to one of the system folders.
How is this done?
I dont have the source code of those apps and hence cant compile from
source.
You will have to add the source code of the app the the packages/apps folder. Remove any precompiled files that exist.
Add the android.mk file. You can copy from it from the already available apps in the packages/apps folder and customize it for your app.
Add the app name to core.mk file in build/target/product
Build the ROM and it should have your file.
I'm using a 3rd party library that is for an Android app, but I need to use it in a Cordova plugin (Phonegap) and after I build/run debug running on the device, the logger is throwing an error about not being able to find the .so file. They use this file with JNI. How can I ensure that the files are being added to apk? Their documentation states that the files need to go in the libs directory like:
/libs/armeabi-v7a/<filename>.so
I've added them to this directory and it seems that only jar files are being added to the plugin. How can I get this file to load onto the device when building the plugin? I'm using Android Studio 0.3.6 with Android API level 19. ( I can't change the versions because that's what we currently support in our app)
Android studio opens by default in "Android view" wich can be quite confusing.
To change the view you click on the down arrow at the right of the word android just above your project content. If you switch to the project view, you will see something that will be less confusing for you and where what's displayed matches the file system structure.
Then you can copy your .so files in the libs/something folder (something being the name of the processor architecture).
If you switch back to the android view, you will see the file inside jniLibs.
Please pay attention to that topic How to include *.so library in Android Studio?. You need put the files into "app\src\main\jniLibs". In plugin.xml that looks like
<source-file src="src/android/armeabi-v7a/some_file.so" target-dir="app\src\main\jniLibs\armeabi-v7a" />
I have Delphi XE5 without updates.
I might have missunderstood the way I should use the BAT file.
In the build.bat template plus the install.txt, my understanding leads me to think than I should use test_classes.dex to be merged with the original classes.dex that embarcadero provides, in order to run the demos correctly.
However, I am not intereseted in testing the demos. I would like just to use the components inside my own project.
Which files should I merge?
Thanks in advance for your guidance and help.
I found the solution here http://blog.blong.com/2013/11/delphi-and-android-services-part-2.html.
It says:
1) Review the build.bat file and ensure the environment variables are set
correctly:
2) ANDROID needs to point to your Android SDK base directory, e.g.
C:\Users\Public\Documents\RAD Studio\12.0
\PlatformSDKs\adt-bundle-windows-x86-20130522\sdk or
C:\Android\android-sdk-windows
3) ANDROID_PLATFORM needs to point at an installed SDK platform
installation, e.g. %ANDROID%\platforms\android-15 or %
ANDROID%\platforms\android-17. Check for one that is installed.
4) DX_LIB needs to point to the lib subdirectory under the Android SDK
build-tools directory, e.g. %ANDROID%\build- tools\18.0.1\lib or
%ANDROID%\build-tools\android-4.2.2\lib
5) EMBO_DEX needs to point to the Delphi-supplied Android classes.dex
file, wrapped in quotes to take care of any spaces in the path, e.g.
"C:\Program Files (x86)\Embarcadero\RAD
Studio\12.0\lib\android\debug\classes.dex"
6) Run build.bat
7) You should now have a new file in the project directory tree called
java\output\dex\classes.dex
This file replaces the supplied classes.dex and has the Java service
and broadcast receiver compiled classes included in it.
8) Set the new classes.dex for deployment
I need to lock the screen to a specific orientation for an android app that I'm making.
is there a way to do that in QML? Google didn't get me any answers.
I am using Qt 5.2.
You can basically use the Screen.orientation property for reading only. See the following example for details:
http://qt-project.org/doc/qt-5/qtquick-window-screeninfo-qml.html
The proper way as of today is to use the Android manifest file for this as done by the Qt Android developer at Digia for his QtHangMan game which is:
<activity android:screenOrientation="portrait" ...
The way to do this is-
Create an out-of-source directory - let's call it "templates" (can be anything)
Copy the AndroidManifest.xml into "templates" from -
<path to qt installation>/android_armv7/src/android/templates/AndroidManifest.xml
Edit the copied AndroidManifext.xml with your favorite editor and change the orientation from "unspecified" to "sensorLandscape" (or anything else you prefer) and save the file.
In the qmake file (*.pro) of your project, add the following line -
ANDROID_PACKAGE_SOURCE_DIR = <path to your templates directory> #in case you added the directory one above the source directory, path to your templates directory = "../templates"
Build and Run. You should now see that the Orientation is fixed to whatever you have specified in the custom AndroidManifest.xml file
To understand what really is happening - here's the qt reference, look for ANDROID_PACKAGE_SOURCE_DIR
In case the link doesn't work in future, here's the relevant bits -
"ANDROID_PACKAGE_SOURCE_DIR: This variable can be used to specify a
directory where additions and modifications can be made to the default
Android package template. The androiddeployqt tool will copy the
application template from Qt into the build directory, and then it
will copy the contents of the ANDROID_PACKAGE_SOURCE_DIR on top of
this, overwriting any existing files. The update step where parts of
the source files are modified automatically to reflect your other
settings is then run on the resulting merged package. If you, for
instance, want to make a custom AndroidManifest.xml for your
application, then place this directly into the folder specified in
this variable. You can also add custom Java files in
ANDROID_PACKAGE_SOURCE_DIR/src."
QtCreator - 4.2.1, Qt - 5.8
I want to use the ${sdk.dir} variable in my project.properties file, so I can check this into version control and use the same file on different setup machines.
My working setup looks like this:
My project.properties:
target=android-18
android.library.reference.1=..\\..\\..\\sdk\\extras\\android\\support\\v7\\appcompat
android.library.reference.2=..\\..\\..\\sdk\\extras\\google\\google_play_services\\libproject\\google-play-services_lib
My local.properties:
sdk.dir=C:\\adt-bundle-windows-x86_64-20130917\\sdk
this setup compiles with ant from the command line. but when I replace the ..\\..\\..\\with ${sdk.dir} I get the error:
project.properties how I want it to use:
target=android-18
android.library.reference.1=${sdk.dir}\\extras\\android\\support\\v7\\appcompat
android.library.reference.2=${sdk.dir}\\extras\\google\\google_play_services\\libproject\\google-play-services_lib
results in:
BUILD FAILED
C:\adt-bundle-windows-x86_64-20130917\sdk\tools\ant\build.xml:460:
Failed to resolve library path:
C:\adt-bundle-windows-x86_64-20130917\sdk\extras\android\support\v7\appcompat
so the variable ${sdk.dir} is replaced correctly but somehow it cannot be resolved. Any ideas?
update Edit
Using the Variable for the proGuard setup in the same file (project.properties) is working fine what so ever:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
This doesn't solve your issue, per se, but I hope it will help you.
My issue was that I needed to reference the Google Play Services SDK as a library in my project. However, our app is built automatically on a separate box using Ant.
I found that library projects cannot be referenced using absolute paths; they must be relative to your project, as explained here:
Library project storage location
There are no specific requirements on where you should store a library project, relative to a dependent application project, as long as the application project can reference the library project by a relative link. What is important is that the main project can reference the library project through a relative link.
I used the ant.properties file to set the android.library.reference.1=../../../../Program Files/Android/android-sdk/Android/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib library. This reference is solely for the build server and this path is relative to the library location on the build server.
For development, I use Eclipse. So, the library's relative path is referenced using the project.properties file and is relative to my development box. This means that whenever I trigger a build on the server (which uses Ant), the reference in the ant.properties is used as opposed to the project.properties file.
The ant.properties file is lower level and therefore will override anything written in the project.properties/local.properties files.
As you can see this is not the answer I am sure you're looking for, but it is a limitation of Ant. My final bit of advice is that you move away from Ant and use Gradle.