準(zhǔn)備操作 系統(tǒng): win10 orlinux(基礎(chǔ)上都一樣) 軟件: androidStudio , Qt6, java jdk11(用了17版本有提示1.8以上,文中安裝還是寫的jdk1.8,后面編譯實際使用了jdk11) 1. Qt安裝如下圖: 登陸自己賬號 我已經(jīng)安裝過所以這里選擇添加 右過濾只需要跟隨發(fā)布版本 Qt這里我默認(rèn)選擇了最新的選擇中穩(wěn)定下一步等待完成即可,其他的配置按自己的需要選擇中即可。 2.接下來是jdk選擇1.8版本(這里按jdk1.8配置,更換成jdk11以上版本即可) 安裝路徑隨意安裝省略,配置環(huán)境如下: 找到高級系統(tǒng)設(shè)置 選擇右下角的環(huán)境變化量 首先是新建(系統(tǒng))變量名: JAVA_HOME 變量值就是jdk環(huán)境路徑
然后繼續(xù)添加: 變量名 CLASSPATH 變量值 .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar; 注意變量值前面有一個點后面結(jié)尾是分號
然后是添加到路徑里面: %JAVA_HOME%\bin %JAVA_HOME%\jre\bin 測試一下java環(huán)境(由于我用的java17顯示版本號不一樣) 快捷鍵 win+R 輸入cmd 調(diào)出命令行:
3.我們來安裝androidStudio(主要是用來搞定sdk的,以及ndk) 安裝過程略只說明一下載sdk,ndk androidStudio 選中 sdkManage 進(jìn)行配置 自己需要哪個安卓版本就選哪個 這里是ndk配置 然后就是右下角的應(yīng)用一下 然后等到10到30分鐘不等 等到完成后關(guān)閉軟件。 4.Qt配置 輸入配置界面如下: 配置好以后先應(yīng)用然后重新打開QtCreator 再次進(jìn)入本次選擇進(jìn)入套件界面: 可以看到套件中都是正常的。 然后切人一下版本編譯器調(diào)試如下:
然后是新工程 看下面有沒有安卓選項
然后,測試下一個項目(空的直接編譯): 中間會下載工具稍等一會:
根據(jù)警告跟換jdk11后編譯通過 更換jdk操作參考前面jdk安裝過程。 5.現(xiàn)在配置一下安卓項目
進(jìn)入配置 創(chuàng)建簽名密碼:
保存后: 連接配置apk的sdk等信息: apk模型版 后續(xù)配置 然后出來對對話框 確認(rèn)后:
配置以后重新編譯:
添加一個測試彈窗: #ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>#include <QMessageBox>QT_BEGIN_NAMESPACEnamespace Ui {class MainWindow;}QT_END_NAMESPACEclass MainWindow:public QMainWindow {Q_OBJECTpublic:MainWindow(QWidget *parent = nullptr);~MainWindow();私人插槽:void on_pushButton_clicked ();private:Ui::MainWindow *ui;};#endif // MAINWINDOW_H void MainWindow::on_pushButton_clicked() {QMessageBox::information(this, "smaller","this is my first android proaram!");} 程序也簽名了 如果前面配置了圖標(biāo) 程序就帶了圖標(biāo)了。 測試一下app kit懸著armV7: 編譯后的路徑 File: D:/work/build-testAndroid-Android_Qt_6_2_3_Clang_armeabi_v7a-Release/android-build//build/outputs/apk/release/android-build-release-signed.apk 復(fù)制手機安裝可以看下 報錯::\Program_Files\Qt\6.5.0\android_arm64_v8a\include\QtCore\qnamespace.:24:1: error: error: Parse error at "__attribute__" 原因是環(huán)境變量E:\Program_Files\Qt\6.5.0\mingw_64\bin,跟C:\MinGW\bin,導(dǎo)致兩人沖突,因此將你的編譯選項的C:\MinGW\bin去掉即可。 https://blog.csdn.net/u012534831/article/details/125151143 QT新建的工程出現(xiàn)以下報錯: I t.example.test: 后期啟用 -Xcheck:jni E t.example.test:runtime_flags 中設(shè)置的未知位:0x8000 I Perf:連接到 perf 服務(wù)。 我 FeatureParser: 在 assets/device_features/ 中找不到 dipper.xml,它可能在 /system/etc/device_features E libc:拒絕訪問查找屬性“ro.vendor.df.effect.conflict” E Perf:無法獲取文件列表 org.qtproject.example.test8 E Perf:getFolderSize():Exception_1 = java.lang.NullPointerException:嘗試獲取空數(shù)組的長度 E Perf:無法獲取文件列表 org.qtproject.example.test8 E Perf:getFolderSize():Exception_1 = java.lang.NullPointerException:嘗試獲取空數(shù)組的長度 W 系統(tǒng):ClassLoader 引用了未知路徑: W t.example.test: Accessing hidden method Landroid/view/Window;->getInsetsController()Landroid/view/WindowInsetsController; (blacklist, linking, denied) W t.example.test: Accessing hidden method Landroid/content/ContextWrapper;->getDisplay()Landroid/view/Display; (greylist, linking, allowed) W t.example.test: Accessing hidden method Lmiui/contentcatcher/sdk/Token;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V (greylist, linking, allowed) W t.example.test: Accessing hidden method Lmiui/contentcatcher/InterceptorProxy;->getWorkThread()Landroid/os/HandlerThread; (greylist, linking, allowed) W t.example.test: Accessing hidden method Lmiui/contentcatcher/sdk/ContentCatcherManager;->getInstance()Lmiui/contentcatcher/sdk/ContentCatcherManager; (greylist, linking, allowed) W t.example.test: 訪問隱藏方法 Lmiui/contentcatcher/sdk/ContentCatcherManager;->getPageConfig(Lmiui/contentcatcher/sdk/Token;)Lmiui/contentcatcher/sdk/data/PageConfig; (灰名單、鏈接、允許) W t.example.test: 訪問隱藏方法 Lmiui/contentcatcher/sdk/data/PageConfig;->getFeatures()Ljava/util/ArrayList; (灰名單、鏈接、允許) W t.example.test: 訪問隱藏方法 Lmiui/contentcatcher/sdk/data/PageConfig;->getCatchers()Ljava/util/ArrayList; (灰名單、鏈接、允許) W t.example.test: 訪問隱藏方法 Lcom/miui/internal/viewcontentfetcher/IViewContentFetcher;->fetchViewContent(Landroid/view/View;I)Landroid/os/Bundle; (灰名單、鏈接、允許) W t.example.test: 訪問隱藏字段 Lmiui/contentcatcher/sdk/data/CatcherInfo;->name:Ljava/lang/String; (灰名單、鏈接、允許) W t.example.test: Accessing hidden method Lcom/miui/internal/viewcontentfetcher/IViewContentFetcher;->fetchWebViewBitmap(Landroid/view/View;I)Landroid/os/Bundle; (greylist, linking, allowed) W t.example.test: Accessing hidden field Lmiui/contentcatcher/sdk/data/FeatureInfo;->name:Ljava/lang/String; (greylist, linking, allowed) W t.example.test: Accessing hidden field Lmiui/contentcatcher/sdk/data/FeatureInfo;->enable:Z (greylist, linking, allowed) W t.example.test: Accessing hidden method Lmiui/contentcatcher/sdk/data/FeatureInfo;->getCatcherNameList()Ljava/util/List; (greylist, linking, allowed) W t.example.test: Accessing hidden field Lmiui/contentcatcher/sdk/data/FeatureInfo;->mParams:Ljava/util/HashMap; (greylist, linking, allowed) W t.example.test: 訪問隱藏方法 Lcom/miui/internal/viewcontentfetcher/IViewContentFetcher;->createFetcher(Lmiui/contentcatcher/sdk/Token;Ljava/util/Map;)V (greylist, linking, allowed) W t.example.test: 訪問隱藏字段 Lmiui/contentcatcher/sdk/Content;->TARGET:Ljava/lang/String; (灰名單、鏈接、允許) W t.example.test: 訪問隱藏字段 Lmiui/contentcatcher/sdk/Content;->JOB:Ljava/lang/String; (灰名單、鏈接、允許) W t.example.test: 訪問隱藏字段 Lmiui/contentcatcher/sdk/Content;->TOKEN_KEY:Ljava/lang/String; (灰名單、鏈接、允許) W t.example.test: 訪問隱藏方法 Lmiui/contentcatcher/sdk/ContentCatcherManager;->registerContentInjector(Lmiui/contentcatcher/sdk/Token;Lmiui/contentcatcher/sdk/injector/IContentDecorateCallback;)V(灰名單,鏈接,允許) W t.example.test: 訪問隱藏方法 Lmiui/contentcatcher/sdk/ContentCatcherManager;->unregisterContentInjector(Lmiui/contentcatcher/sdk/Token;)V (greylist, linking, allowed) W t.example.test: 訪問隱藏方法 Lmiui/contentcatcher/sdk/Content;-><init>(ILjava/lang/String;Lmiui/contentcatcher/sdk/Token;Ljava/util/Map;)V (greylist, linking , 允許) W t.example.test: 訪問隱藏方法 Lmiui/contentcatcher/sdk/ContentCatcherManager;->onContentCatched(Lmiui/contentcatcher/sdk/Content;)V (greylist, linking, allowed) W t.example.test: 訪問隱藏方法 Lmiui/contentcatcher/sdk/Content;-><init>(Landroid/content/Intent;Landroid/os/Bundle;)V (greylist, linking, allowed) W t.example.test: 訪問隱藏方法 Lmiui/contentcatcher/sdk/Token;->getActivityName()Ljava/lang/String; (灰名單、鏈接、允許) W t.example.test: Accessing hidden method Landroid/app/AppGlobals;->getInitialApplication()Landroid/app/Application; (greylist, linking, allowed) D ViewContentFactory: initViewContentFetcherClass D ViewContentFactory: getInterceptorPackageInfo D ViewContentFactory: getInitialApplication took 0ms D ViewContentFactory: packageInfo.packageName: com.miui.catcherpatch E AndroidRuntime: FATAL EXCEPTION: qtMainLoopThread E AndroidRuntime: Process: org.qtproject.example.test8, PID: 21600 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__emutls_get_address" referenced by "/data/app/org.qtproject.example.test8-d3e2FryTRoFLMap740FWWA==/lib/arm/libQt6Core_armeabi-v7a.so"... E AndroidRuntime: at java.lang.Runtime.load0(Runtime.java:938) E AndroidRuntime: at java.lang.System.load(System.java:1631) E AndroidRuntime: at org.qtproject.qt.android.QtNative$2.run(QtNative.java:229) E AndroidRuntime: at org.qtproject.qt.android.QtThread$2.run(QtThread.java:51) E AndroidRuntime: at org.qtproject.qt.android.QtThread$1.run(QtThread.java:25) E AndroidRuntime: at java.lang.Thread.run(Thread.java:919) W t.example.test: Accessing hidden method Lmiui/util/ObjectReference;->get()Ljava/lang/Object; (greylist, linking, allowed) W t.example.test: Accessing hidden method Lmiui/contentcatcher/sdk/Token;->getPkgName()Ljava/lang/String; (greylist, linking, allowed) W t.example.test: Accessing hidden method Lmiui/contentcatcher/sdk/Token;->getVersionCode()I (greylist, linking, allowed) D ViewContentFactory: initViewContentFetcherClass took 7ms I ContentCatcher: ViewContentFetcher : ViewContentFetcher D ViewContentFactory: createInterceptor took 7ms 我處理:發(fā)送信號。PID:21600 SIG:9 |
|