Update build for Android.

Tool versions:
Qt 5.15.2
QtCreator 4.14.1
Java OpenJDK 11.0.10+9
SDK 28
NDK 21.3.6528147
Gradle 5.6.4
Gradle Plugin 3.6.0
This commit is contained in:
Chad Clark 2021-03-16 23:53:48 -06:00 committed by GitHub
parent 806a539f12
commit e52869554e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 30 deletions

View File

@ -282,6 +282,12 @@ android:{
QMAKE_CXXFLAGS += -fsigned-char
#Android treats char as unsigned by default (why???)
# Building .so files fails with -Wl,--no-undefined
QMAKE_LFLAGS_APP -= -Wl,--no-undefined
QMAKE_LFLAGS_SHLIB -= -Wl,--no-undefined
QMAKE_LFLAGS_PLUGIN -= -Wl,--no-undefined
QMAKE_LFLAGS_NOUNDEF -= -Wl,--no-undefined
QT += androidextras
CONFIG += mobility
MOBILITY =
@ -322,16 +328,10 @@ android:{
build_android/package_source/build.gradle \
build_android/package_source/src/androidInterface.java
equals(ANDROID_TARGET_ARCH, armeabi-v7a){
message("qmake building for Android (ARM) platform")
LIBS += -L$${PWD}/build_android/libusb-242/android/armeabi-v7a -lusb1.0
ANDROID_EXTRA_LIBS += $${PWD}/build_android/libusb-242/android/armeabi-v7a/libusb1.0.so
}
equals(ANDROID_TARGET_ARCH, x86){
message("qmake building for Android (x86) platform")
LIBS += -L$$PWD/build_android/libusb-242/android/x86 -lusb1.0
ANDROID_EXTRA_LIBS += $$PWD/build_android/libusb-242/android/x86/libusb1.0.so
}
# Doing the following inside one equals() failed. qmake bug? https://forum.qt.io/topic/113836/dynamic-libs-on-android-with-qt5-14-2/4
for(abi, ANDROID_ABIS): message("qmake building for Android ($${abi}) platform")
for(abi, ANDROID_ABIS): LIBS += -L$${PWD}/build_android/libusb-242/android/$${abi} -lusb1.0
for(abi, ANDROID_ABIS): ANDROID_EXTRA_LIBS += $${PWD}/build_android/libusb-242/android/$${abi}/libusb1.0.so
}
DISTFILES += \

View File

@ -1,7 +1,8 @@
<?xml version="1.0"?>
<manifest package="org.qtproject.example.Labrador" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.3" android:versionCode="8" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Labrador">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="com.EspoTek.Labrador.Java.androidInterface" android:label="Labrador" android:screenOrientation="unspecified" android:launchMode="singleTop" android:icon="@mipmap/ic_launcher">
<manifest package="org.qtproject.example.Labrador" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.3" android:versionCode="8" android:installLocation="auto">
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Labrador" android:extractNativeLibs="true">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="com.EspoTek.Labrador.Java.androidInterface" android:label="Labrador" android:screenOrientation="unspecified" android:launchMode="singleTop" android:icon="@mipmap/ic_launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
@ -20,21 +21,29 @@
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="plugins/platforms/android/libqtforandroid.so"/>
<meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroid-bundled.jar"/>
<meta-data android:name="android.app.static_init_classes" android:value=""/>
<!-- Used to specify custom system library path to run with local system libs -->
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation,
then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and
use hideSplashScreen() with a fade-out animation from Qt Android Extras to hide the splash screen when you
are done populating your window with content. -->
<!-- meta-data android:name="android.app.splash_screen_drawable_portrait" android:resource="@drawable/logo_portrait" / -->
<!-- meta-data android:name="android.app.splash_screen_drawable_landscape" android:resource="@drawable/logo_landscape" / -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
@ -53,6 +62,7 @@
<!-- extract android style -->
<!-- available android:values :
* default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
@ -65,8 +75,7 @@
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
@ -74,8 +83,6 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->

View File

@ -1,15 +1,17 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:3.6.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<array name="qt_sources">
<item>https://download.qt.io/ministro/android/qt5/qt-5.7</item>
<item>https://download.qt.io/ministro/android/qt5/qt-5.15.2</item>
</array>
<!-- The following is handled automatically by the deployment tool. It should
@ -22,4 +22,8 @@
<!-- %%INSERT_BUNDLED_IN_ASSETS%% -->
</array>
<array name="load_local_libs">
<!-- %%INSERT_LOCAL_LIBS%% -->
</array>
</resources>

View File

@ -213,6 +213,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->pause_LA, SIGNAL(toggled(bool)), this, SLOT(paused(bool)));
connect(ui->multimeterPauseCheckBox, SIGNAL(toggled(bool)), this, SLOT(paused(bool)));
#ifndef PLATFORM_ANDROID
connect(ui->hideCH1Box, SIGNAL(toggled(bool)), ui->controller_iso, SLOT(hideCH1(bool)));
connect(ui->hideCH2Box, SIGNAL(toggled(bool)), ui->controller_iso, SLOT(hideCH2(bool)));
@ -221,7 +222,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->hideCH1Box->setVisible(false);
ui->hideCH2Box->setVisible(false);
#endif
ui->realTimeButton->setVisible(false);
if ((QApplication::desktop()->availableGeometry().width() < 1520) || (QApplication::desktop()->geometry().height() < 800))
@ -236,10 +237,12 @@ MainWindow::MainWindow(QWidget *parent) :
this->resize(1520, 800);
}
#ifndef PLATFORM_ANDROID
connect(ui->offsetSpinBox_CH1, SIGNAL(valueChanged(double)), ui->controller_iso, SLOT(offsetChanged_CH1(double)));
connect(ui->offsetSpinBox_CH2, SIGNAL(valueChanged(double)), ui->controller_iso, SLOT(offsetChanged_CH2(double)));
connect(ui->attenuationComboBox_CH1, SIGNAL(currentIndexChanged(int)), ui->controller_iso, SLOT(attenuationChanged_CH1(int)));
connect(ui->attenuationComboBox_CH2, SIGNAL(currentIndexChanged(int)), ui->controller_iso, SLOT(attenuationChanged_CH2(int)));
#endif
connect(ui->controller_iso, &isoDriver::enableCursorGroup, this, &MainWindow::cursorGroupEnabled);
}
@ -402,8 +405,10 @@ void MainWindow::menuSetup(){
fpsGroup->addAction(ui->action5FPS);
serialProtocolGroup = new QActionGroup(this);
#ifndef PLATFORM_ANDROID
serialProtocolGroup->addAction(ui->actionSerial);
serialProtocolGroup->addAction(ui->actionI2C);
#endif
connect(ui->actionAutoV, SIGNAL(toggled(bool)), ui->controller_iso, SLOT(setAutoMultimeterV(bool)));
@ -452,15 +457,19 @@ void MainWindow::menuSetup(){
uartParityGroup_CH1 = new QActionGroup(this);
uartParityGroup_CH1->addAction(ui->actionNone);
#ifndef PLATFORM_ANDROID
uartParityGroup_CH1->addAction(ui->actionEven);
uartParityGroup_CH1->addAction(ui->actionOdd);
#endif
ui->actionNone->setChecked(true);
uartParityGroup_CH2 = new QActionGroup(this);
uartParityGroup_CH2->addAction(ui->actionNone_2);
#ifndef PLATFORM_ANDROID
uartParityGroup_CH2->addAction(ui->actionEven_2);
uartParityGroup_CH2->addAction(ui->actionOdd_2);
ui->actionNone_2->setChecked(true);
#endif
connectionTypeGroup = new QActionGroup(this);
connectionTypeGroup->addAction(ui->actionLo_bw);
@ -2328,7 +2337,9 @@ void MainWindow::on_actionShow_Range_Dialog_on_Main_Page_triggered(bool checked)
{
scopeRangeSwitch = new scopeRangeEnterDialog(nullptr, false, ui->controller_iso->display.topRange, ui->controller_iso->display.botRange, ui->controller_iso->display.window, ui->controller_iso->display.delay);
scopeRangeSwitch->setWindowFlags(Qt::Widget);
#ifndef PLATFORM_ANDROID
ui->verticalLayout_5->insertWidget(2, scopeRangeSwitch);
#endif
connect(scopeRangeSwitch, SIGNAL(yTopUpdated(double)), ui->controller_iso, SLOT(setTopRange(double)));
connect(scopeRangeSwitch, SIGNAL(yBotUpdated(double)), ui->controller_iso, SLOT(setBotRange(double)));
connect(scopeRangeSwitch, SIGNAL(windowUpdated(double)), ui->controller_iso, SLOT(setTimeWindow(double)));
@ -2348,6 +2359,7 @@ void MainWindow::on_actionShow_Range_Dialog_on_Main_Page_triggered(bool checked)
void MainWindow::paused(bool enabled)
{
#ifndef PLATFORM_ANDROID
qDebug() << "MainWindow::paused(" << enabled << ")";
ui->hideCH1Box->setVisible(enabled);
ui->hideCH2Box->setVisible(enabled);
@ -2357,6 +2369,7 @@ void MainWindow::paused(bool enabled)
ui->hideCH1Box->setChecked(false);
ui->hideCH2Box->setChecked(false);
}
#endif
}
void MainWindow::on_actionNone_triggered()

View File

@ -19,7 +19,7 @@
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="voltageSpinBox" name="vMaxBox">
<widget class="espoSpinBox" name="vMaxBox">
<property name="minimum">
<double>20.000000000000000</double>
</property>
@ -36,7 +36,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="voltageSpinBox" name="vMinBox">
<widget class="espoSpinBox" name="vMinBox">
<property name="minimum">
<double>-20.000000000000000</double>
</property>
@ -53,7 +53,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="voltageSpinBox" name="timeWindowBox">
<widget class="espoSpinBox" name="timeWindowBox">
<property name="decimals">
<number>6</number>
</property>
@ -73,7 +73,7 @@
</widget>
</item>
<item row="3" column="0">
<widget class="voltageSpinBox" name="delayBox">
<widget class="espoSpinBox" name="delayBox">
<property name="decimals">
<number>6</number>
</property>
@ -110,9 +110,9 @@
</widget>
<customwidgets>
<customwidget>
<class>voltageSpinBox</class>
<class>espoSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header location="global">voltagespinbox.h</header>
<header location="global">espospinbox.h</header>
<slots>
<slot>setMin(double)</slot>
<slot>setMax(double)</slot>