Skip to content

Commit

Permalink
CI: modify android.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Dec 4, 2024
1 parent 7b6fc7d commit 15e864b
Show file tree
Hide file tree
Showing 15 changed files with 268 additions and 14 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
BUILD_TYPE: [Release]
qt_arch: [android_arm64_v8a, android_x86_64]
qt_version: [6.6.2]
qt_version: [6.8.1]
include:
- qt_arch: android_arm64_v8a
VCPKG_TARGET_TRIPLET: arm-android
Expand All @@ -32,15 +32,15 @@ jobs:

env:
artifact_name: build_android
STOREPASS: ${{secrets.STOREPASS}}
STOREPASS: ${{secrets.STOREPASS}}
SOURCE_DIR: ${{github.workspace}}/.cache/source
TOOSL_DIR: ${{github.workspace}}/.cache/tools
INSTALL_DIR: ${{github.workspace}}/.cache/install
RabbitCommon_VERSION: v2.2.6
VCPKGGITCOMMITID: 59aeb8fe8fe1c980de6bd5ba634cf21024522d81
ANDROID_ABI: ${{matrix.ANDROID_ABI}}
ANDROID_PLATFORM: android-28
ANDROID_NATIVE_API_LEVEL: 28
ANDROID_PLATFORM: android-35
ANDROID_NATIVE_API_LEVEL: 35
qt_modules: 'qtscxml'

# Map the job outputs to step outputs
Expand Down Expand Up @@ -74,9 +74,9 @@ jobs:
with:
dir: '${{env.TOOSL_DIR}}' # optional
version: '${{matrix.qt_version}}'
#host: 'linux'
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
arch: 'linux_gcc_64'
set-env: false
cache: true
cache-key-prefix: cached_qt
Expand Down Expand Up @@ -131,13 +131,19 @@ jobs:
-DQT_HOST_PATH=${Qt6_DIR}/../gcc_64 \
-DQt6LinguistTools_DIR=${Qt6_DIR}/../gcc_64/lib/cmake/Qt6LinguistTools \
-DCMAKE_INSTALL_PREFIX=`pwd`/install \
-DANDROID_PLATFORM=${{env.ANDROID_PLATFORM}} \
-DBUILD_TEST=OFF \
-DBUILD_APP=OFF
cmake --build . --config ${{matrix.BUILD_TYPE}} --target all
echo "cmake --build . --config ${{matrix.BUILD_TYPE}} --target install"
cmake --build . --config ${{matrix.BUILD_TYPE}} --target install
7z a RabbitCommon_${{env.RabbitCommon_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.zip ./install/*
APK_FILE=`find . -name "android-*.apk"`
cp $APK_FILE RabbitCommon_${{env.RabbitCommon_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.apk
cd build/FileBrowser
APK_FILE=`find . -name "android-*.apk"
cp $APK_FILE ${{github.workspace}}/FileBrowser_${{env.RabbitCommon_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.apk
cd ${{github.workspace}}/build/MimeTypeBrowser
APK_FILE=`find . -name "android-*.apk"
cp $APK_FILE ${{github.workspace}}/MimeTypeBrowser_${{env.RabbitCommon_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.apk
- name: Update artifact
if: ${{ matrix.BUILD_TYPE == 'Release' }}
Expand All @@ -146,4 +152,4 @@ jobs:
name: ${{ env.artifact_name }}_${{matrix.qt_version}}_${{matrix.qt_arch}}
path: |
${{github.workspace}}/build/RabbitCommon_${{env.RabbitCommon_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.zip
${{github.workspace}}/build/RabbitCommon_${{env.RabbitCommon_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.apk
${{github.workspace}}/build/*.apk
8 changes: 3 additions & 5 deletions FileBrowser/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
android:installLocation="auto"
android:versionCode="0"
android:versionName="2.2.6">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<supports-screens
android:anyDensity="true"
Expand All @@ -25,7 +24,6 @@
android:name="org.qtproject.qt.android.bindings.QtActivity"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
android:launchMode="singleTop"
android:label="@string/app_name"
android:screenOrientation="unspecified"
android:exported="true">
<intent-filter>
Expand Down
83 changes: 83 additions & 0 deletions FileBrowser/android/build.gradle.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
// https://developer.android.google.cn/build/releases/gradle-plugin?hl=zh-cn
classpath 'com.android.tools.build:gradle:8.2.2'
}
}

repositories {
google()
mavenCentral()
}

apply plugin: 'com.android.application'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'androidx.core:core:1.10.1'
}

android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qtAndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/

compileSdkVersion androidCompileSdkVersion
buildToolsVersion androidBuildToolsVersion
ndkVersion androidNdkVersion

// Extract native libraries from the APK
packagingOptions.jniLibs.useLegacyPackaging true

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qtAndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qtAndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qtAndroidDir + '/res', 'res']
resources.srcDirs = ['resources']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}

tasks.withType(JavaCompile) {
options.incremental = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
abortOnError false
}

// Do not compress Qt binary resources file
aaptOptions {
noCompress 'rcc'
}

defaultConfig {
resConfig "en"
minSdkVersion qtMinSdkVersion
targetSdkVersion qtTargetSdkVersion
ndk.abiFilters = qtTargetAbiList.split(",")
}
}
53 changes: 53 additions & 0 deletions MimeTypeBrowser/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.KangLinStudio.MimeTypeBrowser"
android:installLocation="auto"
android:versionCode="0"
android:versionName="2.2.6">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<application
android:name="org.qtproject.qt.android.bindings.QtApplication"
android:hardwareAccelerated="true"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:allowBackup="true"
android:fullBackupOnly="false">
<activity
android:name="org.qtproject.qt.android.bindings.QtActivity"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
android:launchMode="singleTop"
android:screenOrientation="unspecified"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data
android:name="android.app.lib_name"
android:value="MimeTypeBrowser" />

<meta-data
android:name="android.app.arguments"
android:value="" />
</activity>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.qtprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/qtprovider_paths"/>
</provider>
</application>
</manifest>
83 changes: 83 additions & 0 deletions MimeTypeBrowser/android/build.gradle.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
// https://developer.android.google.cn/build/releases/gradle-plugin?hl=zh-cn
classpath 'com.android.tools.build:gradle:8.2.2'
}
}

repositories {
google()
mavenCentral()
}

apply plugin: 'com.android.application'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'androidx.core:core:1.10.1'
}

android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qtAndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/

compileSdkVersion androidCompileSdkVersion
buildToolsVersion androidBuildToolsVersion
ndkVersion androidNdkVersion

// Extract native libraries from the APK
packagingOptions.jniLibs.useLegacyPackaging true

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qtAndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qtAndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qtAndroidDir + '/res', 'res']
resources.srcDirs = ['resources']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}

tasks.withType(JavaCompile) {
options.incremental = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
abortOnError false
}

// Do not compress Qt binary resources file
aaptOptions {
noCompress 'rcc'
}

defaultConfig {
resConfig "en"
minSdkVersion qtMinSdkVersion
targetSdkVersion qtTargetSdkVersion
ndk.abiFilters = qtTargetAbiList.split(",")
}
}
Binary file added MimeTypeBrowser/android/res/drawable-hdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MimeTypeBrowser/android/res/drawable-ldpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MimeTypeBrowser/android/res/drawable-mdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MimeTypeBrowser/android/res/drawable-xhdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions MimeTypeBrowser/android/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">Mime类型浏览器</string>

</resources>
6 changes: 6 additions & 0 deletions MimeTypeBrowser/android/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">Mime Type Browser</string>

</resources>
18 changes: 18 additions & 0 deletions build_android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if [ -n $1 ]; then
Qt6_ROOT=$1
fi

mkdir -p build_android
cd build_android
${Qt6_ROOT}/bin/qt-cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DQT_HOST_PATH=${Qt6_ROOT}/../gcc_64 \
-DQt6LinguistTools_DIR=${Qt6_ROOT}/../gcc_64/lib/cmake/Qt6LinguistTools \
-DCMAKE_INSTALL_PREFIX=`pwd`/install \
-DANDROID_PLATFORM=android-35 \
-DBUILD_TEST=OFF \
-DBUILD_APP=OFF

cmake --build . -j $(nproc)
1 change: 1 addition & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ sed -i "s/rabbitcommon (.*)/rabbitcommon (${DEBIAN_VERSION})/g" ${SOURCE_DIR}/de
sed -i "s/Version=.*/Version=${DEBIAN_VERSION}/g" ${SOURCE_DIR}/share/org.Rabbit.RabbitCommon.desktop
sed -i "s/[0-9]\+\.[0-9]\+\.[0-9]\+/${DEBIAN_VERSION}/g" ${SOURCE_DIR}/README*.md
sed -i "s/versionName=\"[0-9]\+\.[0-9]\+\.[0-9]\+\"/versionName=\"${DEBIAN_VERSION}\"/g" ${SOURCE_DIR}/FileBrowser/android/AndroidManifest.xml
sed -i "s/versionName=\"[0-9]\+\.[0-9]\+\.[0-9]\+\"/versionName=\"${DEBIAN_VERSION}\"/g" ${SOURCE_DIR}/MimeTypeBrowser/android/AndroidManifest.xml
sed -i "s/RabbitCommon_VERSION:.*/RabbitCommon_VERSION: ${DEBIAN_VERSION}/g" ${SOURCE_DIR}/.github/workflows/ubuntu.yml
sed -i "s/RabbitCommon_VERSION:.*/RabbitCommon_VERSION: ${DEBIAN_VERSION}/g" ${SOURCE_DIR}/.github/workflows/qmake.yml
if [ -f ${SOURCE_DIR}/vcpkg.json ]; then
Expand Down

0 comments on commit 15e864b

Please sign in to comment.