Skip to content

Commit 194f3cf

Browse files
Turn on --use-aapt2 flag when recompiling; closed #160
1 parent dfa6bb5 commit 194f3cf

5 files changed

Lines changed: 14 additions & 4 deletions

File tree

sources/apkrecompileworker.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include "apkrecompileworker.h"
33
#include "processutils.h"
44

5-
ApkRecompileWorker::ApkRecompileWorker(const QString &folder, QObject *parent)
6-
: QObject(parent), m_Folder(folder)
5+
ApkRecompileWorker::ApkRecompileWorker(const QString &folder, bool aapt2, QObject *parent)
6+
: QObject(parent), m_Aapt2(aapt2), m_Folder(folder)
77
{
88
}
99

@@ -24,6 +24,9 @@ void ApkRecompileWorker::recompile()
2424
QStringList args;
2525
args << heap << "-jar" << apktool;
2626
args << "b" << m_Folder;
27+
if (m_Aapt2) {
28+
args << "--use-aapt2";
29+
}
2730
ProcessResult result = ProcessUtils::runCommand(java, args);
2831
#ifdef QT_DEBUG
2932
qDebug() << "Apktool returned code" << result.code;

sources/apkrecompileworker.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ class ApkRecompileWorker : public QObject
77
{
88
Q_OBJECT
99
public:
10-
explicit ApkRecompileWorker(const QString &folder, QObject *parent = nullptr);
10+
explicit ApkRecompileWorker(const QString &folder, bool aapt2, QObject *parent = nullptr);
1111
void recompile();
1212
private:
13+
bool m_Aapt2;
1314
QString m_Folder;
1415
signals:
1516
void finished();

sources/binarysettingswidget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ QLayout *BinarySettingsWidget::buildForm()
4141
label->setTextInteractionFlags(Qt::TextBrowserInteraction);
4242
label->setTextFormat(Qt::RichText);
4343
layout->addRow("", child);
44+
layout->addRow(tr("Use AAPT2?"), m_CheckAapt2 = new QCheckBox(this));
4445
layout->addRow(tr("Jadx"), m_EditJadxExe = new QLineEdit(this));
4546
child = new QHBoxLayout();
4647
child->addWidget(button = new QPushButton(tr("Browse"), this));
@@ -76,6 +77,7 @@ QLayout *BinarySettingsWidget::buildForm()
7677
m_EditAdbExe->setText(adb);
7778
}
7879
m_EditApktoolJar->setText(settings.value("apktool_jar").toString());
80+
m_CheckAapt2->setChecked(settings.value("use_aapt2", true).toBool());
7981
m_EditJadxExe->setText(settings.value("jadx_exe").toString());
8082
auto java = settings.value("java_exe").toString();
8183
if (adb.isEmpty()) {

sources/binarysettingswidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef BINARYSETTINGSWIDGET_H
22
#define BINARYSETTINGSWIDGET_H
33

4+
#include <QCheckBox>
45
#include <QLineEdit>
56
#include <QSpinBox>
67
#include <QWidget>
@@ -11,6 +12,7 @@ class BinarySettingsWidget : public QWidget
1112
public:
1213
explicit BinarySettingsWidget(QWidget *parent = nullptr);
1314
private:
15+
QCheckBox *m_CheckAapt2;
1416
QLineEdit *m_EditAdbExe;
1517
QLineEdit *m_EditApktoolJar;
1618
QLineEdit *m_EditJadxExe;

sources/mainwindow.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,10 @@ void MainWindow::handleActionBuild()
421421
while (active->data(0, Qt::UserRole + 1).toInt() != Project) {
422422
active = active->parent();
423423
}
424+
QSettings settings;
425+
auto appt2 = settings.value("use_aapt2", true).toBool();
424426
auto thread = new QThread();
425-
auto worker = new ApkRecompileWorker(active->data(0, Qt::UserRole + 2).toString());
427+
auto worker = new ApkRecompileWorker(active->data(0, Qt::UserRole + 2).toString(), appt2);
426428
worker->moveToThread(thread);
427429
connect(worker, &ApkRecompileWorker::recompileFailed, this, &MainWindow::handleRecompileFailed);
428430
connect(worker, &ApkRecompileWorker::recompileFinished, this, &MainWindow::handleRecompileFinished);

0 commit comments

Comments
 (0)