qmake install ignores android /res folder - android

I found out that I can use INSTALLS to replace ANDROID_PACKAGE_SOURCE_DIR. But for some reason it ignores /res folder.
My project has 2 android related folders. /android and /android_extra.
At first it was all one folder that was included in the build with ANDROID_PACKAGE_SOURCE_DIR, but that's not the best solution, since some files, depending on the build, shouldn't be included.
So I put the optional files inside android_extra.
If I use the ANDROID_PACKAGE_SOURCE_DIR for the mandatory /android folder and INSTALLS for the optional /andorid_extra it doesn't include the /android_extra/src files.
If however I use INSTALLS instead of ANDROID_PACKAGE_SOURCE_DIR it doesn't include the android/res files, but the /android_extra/src will be included...
I don't know what else to try, mainly I'm just looking at how the build system is making fun of me...
Any solution to this, or how to force it to include files?
I also noticed that if I put the INSTALLS path to /res2 it will copy the files, so I assume it can't copy to /res. Probably the same case is for /src with ANDROID_PACKAGE_SOURCE_DIR. Is there some "write protection"?
This is the code part in my .pro file:
# ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
# can be repalced by
ANDROID_SOURCES.path = /
ANDROID_SOURCES.files = $$PWD/android/*
INSTALLS += ANDROID_SOURCES
vmxBuild {
VMX_SOURCES.path = /
VMX_SOURCES.files = $$files($$PWD/android_extra/VmxPlayer/*)
INSTALLS += VMX_SOURCES
}
The compile output seems normal:
qmake -install qinstall /home/user/Projects/myProject/android/res /home/user/Projects/build-myProject-Android_for_arm64_v8a_Clang_Qt_5_12_5_for_Android_ARM64_v8a-Debug/android-build/res
The process "/home/user/Android/android-ndk-r19c/prebuilt/linux-x86_64/bin/make" exited normally.

Related

Cordova Build - ignore files

When compiling a cordova application every single file in my /www folder gets copied to the assets/www folder(android) but I'd like to customize what files are copied. I use several pseudo languages like CoffeeScript, Jade or Stylus which are auto-compiled by my IDE and they shouldn't be shipped into the final application.
With the help of this article, I found that you can create/edit the platform/android/ant.properties, and add the following line to it:
aapt.ignore.assets=!*.map:!thumbs.db:!.git:.*:*~
With this line, any file or directory that matches one of these patterns will not be included in the .apk file:
*.map
thumbs.db
.git
.*
*~
I found that editing the platforms/android/build.xml won't work because it's overwritten each time the build is invoked; also, creating a build.xml file in the root of the project didn't work.
The rules for this property are the following, taken from $ANDROID_HOME/tools/ant/build.xml:
<!-- 'aapt.ignore.assets' is the list of file patterns to ignore under /res and /assets.
Default is "!.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
Overall patterns syntax is:
[!][<dir>|<file>][*suffix-match|prefix-match*|full-match]:more:patterns...
- The first character flag ! avoids printing a warning.
- Pattern can have the flag "<dir>" to match only directories
or "<file>" to match only files. Default is to match both.
- Match is not case-sensitive.
-->
<property name="aapt.ignore.assets" value="" />
Hidden (.*) folder & files will be ignored by default
All hidden files and folders will be ignored while build for example .git/ & .gitignore
To hide : Rename the folder by a . (dot) prepended to the folder/file name.
Use Terminal in Linux/Mac to rename the folder.
mv dev .dev
Use cmd in Windows
ren dev .dev
I do not know any way how to filter files for cordova, but I can describe you approach that we use in our projects.
We are using gruntjs with phonegap plugin. We configure it to use prebuilt folder (which contains only necessary files and folders) and it:
creates cordova/phonegap project
adds plugins,platforms
builds native applicaiton
launches native application on emulator
Main thing in this approach is that cordova/phonegap project (directory with .cordova, platforms and www folders) is just a build artefact.
Here is relevant part of our Gruntfile.js as an example:
phonegap : {
config : {
root : './out/dist',
config : {
template : './config.tpl.xml',
data: {
id: pkg.id,
version: pkg.version,
name: pkg.name,
author : pkg.author
}
},
path : 'out/phonegap',
plugins : [
// PHONEGAP OFFICIAL PLUGINS
'org.apache.cordova.globalization',
'org.apache.cordova.network-information',
'org.apache.cordova.splashscreen',
//THIRD-PARTY PLUGINS
'de.appplant.cordova.plugin.local-notification'
],
platforms : [
'android'
],
maxBuffer : 200, // You may need to raise this for iOS.
verbose : false,
releases : 'out/releases',
releaseName : function() {
return pkg.name + '-v' + pkg.version;
},
// Android-only integer version to increase with each release.
// See http://developer.android.com/tools/publishing/versioning.html
versionCode : function() {
return 1;
}
}
}
Note, out/dist is generated by previous build step and contains concatenated and minified version of code.
I've created a custom script to ignore files/folders which works not just for android:
Add this to your config.xml:
<ignore entries="lang,foo/bar,ignore/asdf.html" />
And you need two more files located in hooks/before_build and hooks/after_build folders.
I highly recommend cordova-plugin-exclude-files. You simply specify files to exclude as pattern attributes of exclude-files tags in your config.xml file.
For example, to exclude all .scss files:
<exclude-files pattern="**/*.scss" />
And to exclude all files with the string "ios-only" on the Android platform only:
<platform name="android">
<exclude-files pattern="ios-only" /> </platform>
This is what I'm doing. I've moved the src files for the app that was in www folder to another folder created in root - web-app. Next, the following script was added in package.json :
This surely needs to be refined, but am working with it as makeshift arrangement.
Good Luck...

android NDK. libzip stopped to sub folder

I use libzip to read APK content in native code.
assets/sounds/voice folder "disappeared" for libzip functions only.
libzip still see other files.
I still can see it in assets/sounds/voice in project folder.
I did clean many times.
I still can unzip APK file from bin folder and I see all required files. (including files from assets/sounds/voice folder)
I added small logging command and it does not print files from assets/sounds/voice folder. All other files are present.
int inum = zip_get_num_files(apkzip);
for(int i = 0; i < inum; i++){
const char * name = zip_get_name(apkzip, i, 0);
__android_log_print(ANDROID_LOG_INFO,"FILEZIP", "zip: %s", name);
}
I have no idea what at what step it is wrong. Had eclipse compressed ZPK with new format that my libzip does not able to read? or what could be a reason.
This is not an answer for libzip, but why you have to use libzip to read apk file in NDK application? In Android NDK, you can use AAsset APIs to get file from the apk. Take a look at "How To Get File In Assets From Android NDK".
EDITED
It is not available in android-5 that I still use
Ok. So how about Cocos2d-x's ZipFile? It is based on Minizip.
How to use ZipFile from cocos2dx/platform/android/CCFileUtilsAndroid.cpp
s_pZipFile = new ZipFile(resourcePath, "assets/");
pData = s_pZipFile->getFileData(fullPath.c_str(), pSize);

How to add add custom assets into .apk file?

I need to have some files in android assets folder, how can I add them using QtCreator/QMake?
Assuming you have the following structure in your source directory:
foo.pro
extra_data/file1
extra_data/file2
…
Adding the following to foo.pro should deploy the extra_data folder to assets://extra_data (exact path might differ, cannot verify right now) in the APK:
folder_01.source = extra_data
folder_01.target = extra_data
DEPLOYMENTFOLDERS += folder_01
If you are developing the application, then simply copy/paste the files in assets folder.
But if your application is already built and available as .apk file then you cannot modify any of its content.
Copying files to /5.2.0/android_armv7/src/android/java/assets did the trick

How to load different jni libs according to CPU abilities in android?

I have several jni dynamic libs (*.so), which related to cpu abilities, for example, some libs support armv7+neon cpu, some libs support armv7+vfpv3 cpu, some libs support non-armv7 cpus.
How to load them dynamically according to the CPU abilities?
I tried the following code, but not work.
In this solution, I put 3 libs version in the install package with different names below:
(Original name is libavcodec.so)
libavcodec_neon.so and libavutil_neon.so
libavcodec_vfpv3.so and libavutil_vfpv3.so
libavcodec_basic.so and libavutil_basic.so
But libavcodec.so depends on libavutil.so, so the loadLibrary function will fail because its name has been changed.
Maybe I can rename the libs to the original name before load them, how to do it?
String cpu_ability = getCpuAbility();
if (cpu_ability.equals("cpuinfo_armv7_neon")) {
System.loadLibrary("avutil_neon");
System.loadLibrary("avcodec_neon");
}
else if (cpu_ability.equals("cpuinfo_armv7_vfpv3")) {
System.loadLibrary("avutil_vfpv3");
System.loadLibrary("avcodec_vfpv3");
}
else {
System.loadLibrary("avutil_basic");
System.loadLibrary("avcodec_basic");
}
I found a way to solve this question.
Because the directory /data/data/<appname>/lib can't be modified, I copied the library to the /data/data/<appname>/files directory, and renamed it.
For example, in armv7+neon situation, I copied libavcodec_neon.so to the files directory, and rename it to libavcodec.so. So does other libs. Then load them from the files directory.

Queries regarding 'backport-android-bluetooth'

I have started working on android just 1 month back (so please consider my question even if it looks simple). I have my Bluetooth code running on Android 2.2. So I am working on using backport-android-bluetooth to migrate it to Android 1.6 (as I have some old pads with 1.6).
I came across foll. link: http://code.google.com/p/backport-android-bluetooth/
I have queries regarding point no. 1 and 2 under 'Install' which are as follows:
1. download backport-android-bluetooth2.jar, and put into your projects's reference libraries. - Where is exactly 'projects' reference library'? How to put .jar file in that 'reference library
2. put backport_android_bluetooth.properties in to your src directory. -Is this file to be put in 'src' folder or '*Project_Name*' folder like project.properties file?
Thanks in advance.
Put a new file into your src dir,named backport_android_bluetooth.properties
and then put the code below in it:
#permission_name = ${your package name).PERMISSION_BLUETOOTH
permission_name = com.example.bluetooth.PERMISSION_BLUETOOTH
#request_enable = ${your package name}.action.REQUEST_ENABLE
request_enable = com.example.bluetooth.action.REQUEST_ENABLE
#request_discoverable = ${your package name}.action.REQUEST_DISCOVERABLE
request_discoverable = com.example.bluetooth.action.REQUEST_DISCOVERABLE
if u r using eclipse than right click on ur project New/Folder,
give folder name as libs and copy & paste android-bluetooth2.jar in libs folder.
than right click on libs folder go to Build Path/ Configure Build Path
Click on Add Jar, select your project/libs/android-bluetooth2.jar
press ok

Categories

Resources