Build an Android project and get a `.apk` file on a Debian 11 command line

You can build an Android project and get a .apk file on a Debian 11 command line without using Android Studio. The process involves using the Android SDK command-line tools (sdkmanager, adb, and gradle).

Here’s a step-by-step guide to building the ??? Android project (or any other Android project) on Debian 11:

1. Install Java Development Kit (JDK)

??? Android requires JDK 8 or newer. You can install the JDK using the following command:

sudo apt update
sudo apt install openjdk-11-jdk

2. Install Android SDK Command-Line Tools

Download the Android SDK command-line tools. You can do this by visiting the Android SDK download page or by running:

wget https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip
ed2k://|file|android-sdk-commandlinetools-linux-9477386_latest.zip|133507477|9B0150B86C257EB841527537951CFDF2|/

Extract the SDK tools and move them to your desired location:

unzip commandlinetools-linux-9477386_latest.zip
sudo mkdir -p /opt/android-sdk/cmdline-tools
sudo mv cmdline-tools /opt/android-sdk/cmdline-tools/latest

Add the Android SDK to your PATH by editing the .bashrc file:

echo "export ANDROID_SDK_ROOT=/opt/android-sdk" >> ~/.bashrc
echo "export PATH=\$PATH:/opt/android-sdk/cmdline-tools/latest/bin:/opt/android-sdk/platform-tools" >> ~/.bashrc
source ~/.bashrc

3. Install Required SDKs and Build Tools

Now, use the SDK manager to install necessary packages like platform-tools, build-tools, and SDK platforms:

sdkmanager --install "platform-tools" "platforms;android-30" "build-tools;30.0.3"

Adjust the SDK and build tools versions according to the project’s requirements (you can check build.gradle for details).

4. Clone the Project

Clone the ??? Android repository:

git clone https://github.com/????????????/????????????-android.git
cd ????????????-android

5. Install Gradle

Debian repositories might not have the latest Gradle version. Install the required version specified in the gradle/wrapper/gradle-wrapper.properties file by running:

sudo apt install gradle

Alternatively, you can use the Gradle wrapper bundled with the project:

./gradlew

6. Build the Project

Run the following Gradle command to build the APK:

./gradlew assembleRelease

This command will generate the APK file in the app/build/outputs/apk/release/ directory.

7. Sign the APK (Optional)

If you want to sign the APK for release, you will need a keystore. You can create one with:

keytool -genkey -v -keystore my-release-key.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias my-key-alias

Sign the APK using apksigner:

apksigner sign --ks my-release-key.keystore --out app-release-signed.apk app/build/outputs/apk/release/app-release-unsigned.apk

8. Run or Install the APK

Once the APK is built, you can install it on your Android device using ADB:

adb install app-release-signed.apk

That’s it! You should now have a .apk file generated without needing Android Studio.

To upgrade from JDK 11 to JDK 17 on your Debian system, you can follow these simple steps to install JDK 17 and set it as the default. Here’s how to do it efficiently:

Step-by-Step Process to Upgrade to JDK 17

1. Install JDK 17

Use the Debian package manager to install OpenJDK 17:

sudo apt update
sudo apt install openjdk-17-jdk

This will install JDK 17 alongside your current JDK 11 version.

2. Check Installed Java Versions

After installation, you can check the installed Java versions by running:

sudo update-alternatives --config java

This will display all installed Java versions.

3. Switch to JDK 17

You’ll see a list of installed JDKs and a prompt to choose which one to use. Select the number corresponding to JDK 17 to set it as the default version.

For example, if the list looks like this:

There are 2 choices for the alternative java (providing /usr/bin/java).Selection    Path                                           Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java     1111      auto mode1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java     1111      manual mode2            /usr/lib/jvm/java-17-openjdk-amd64/bin/java     1112      manual modePress <enter> to keep the current choice[*], or type selection number:

Enter the number corresponding to JDK 17 (in this case, 2).

4. Verify the Java Version

To confirm that JDK 17 is now the active version, run:

java -version

You should see something like:

openjdk version "17.x.x" OpenJDK Runtime Environment (build ...)
5. Update JAVA_HOME Environment Variable (Optional)

If you rely on the JAVA_HOME environment variable in your build, make sure it points to JDK 17. Add the following line to your ~/.bashrc or ~/.profile file:

export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64

Then, reload the shell:

source ~/.bashrc

6. Run the Build Again

Now that you’re using JDK 17, you can re-run your Gradle build:

./gradlew build

This should resolve the issue with the Firebase dependency that requires a Java 17 runtime.

Downgrading to Gradle 8.x is a simpler and effective approach, especially if you just want to avoid dealing with compatibility issues related to future versions like Gradle 9.0.

Here’s how you can downgrade Gradle and switch to a specific version:

1. Install a Specific Version of Gradle (e.g., 8.x)

You can manually install a specific version of Gradle (like 8.x) by following these steps:

  1. Download the Gradle 8.x distribution:
    Go to the Gradle releases page and download the ZIP for the desired 8.x version. For example, download Gradle 8.10 if you want to use that.

    wget https://services.gradle.org/distributions/gradle-8.10-bin.zip
    
  2. Unzip the downloaded Gradle:
    Unzip the downloaded file in a directory of your choice (for example, /opt/gradle).

    sudo mkdir /opt/gradle
    sudo unzip gradle-8.10-bin.zip -d /opt/gradle
    
  3. Set up the environment variable:
    Point your system to use this specific version of Gradle by updating your PATH environment variable.

    Add the following line to your ~/.bashrc (or ~/.profile):

    export PATH=/opt/gradle/gradle-8.10/bin:$PATH
    

    Then reload your shell:

    source ~/.bashrc
    
2. Verify the Installed Gradle Version

To make sure the correct version of Gradle is now active, run:

gradle -v

This should show you that Gradle 8.x is being used.

3. Switch Between Gradle Versions

If you later need to switch between Gradle 9.0 and 8.x, you can:

  • Update the PATH environment variable to point to the version you need.
  • Use Gradle Wrapper (gradlew) to specify a particular version for your project.

For example, to use Gradle 8.x for your project via the Gradle Wrapper, you can update the wrapper configuration:

./gradlew wrapper --gradle-version 8.x

This way, your project will always use Gradle 8.x regardless of the system-wide version installed.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/57545.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Redis --- 第六讲 --- 关于持久化

前言 持久化&#xff1a;MySQL的事务&#xff0c;有四大比较核心的特性 1、原子性 2、一致性 3、持久性 》 把数据存储到硬盘上 》持久&#xff0c;把数据存储在内存上》持久化。重启进程/重启主机之后&#xff0c;数据是否存在。 4、隔离性 Redis是一个内存数据库&#…

消息队列(仿RabbitMQ)—— 生产消费模型

本篇将实现一个3000多行的一个小项目&#xff0c;基于AMQP&#xff08;高级消息队列协议&#xff09;的消息队列&#xff0c;主要仿照 RabbitMQ 实现该代码&#xff0c;其本质也是生产消费模型的一个升级版本。实现的功能为&#xff1a;消息发布端将消息发送到服务器端&#xf…

如何开启华为交换机 http

系列文章目录 提示&#xff1a;这里可以添加系列文章的所有文章的目录&#xff0c;目录需要自己手动添加 例如&#xff1a;第一章 Python 机器学习入门之pandas的使用 提示&#xff1a;写完文章后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目…

腾讯 C++ 客户端一面,居然遇见了一道简单题。它怎么用go、C++解决

腾讯是目前全国最强的互联网公司之一&#xff0c;它有很好的福利尤其是能给应届生不错的工资待遇。 也正因如此&#xff0c;想进入腾讯工作的难度和竞争的激烈程度非常之大。 虽然感觉腾讯像是更看重个人综合能力的一家公司&#xff0c;算法题的好坏占面评比相对小些 但是竞争…

二、Linux 系统命令

一、系统命令 # 清屏 (Ctrl L) $ clear# 退出登录 $ exit # 历史命令 $ history $ history | grep java -jar 1. 系统信息 # 查看版本&#xff0c;当前操作系统发行版信息 $ cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) # 查看操作系统位数 $ getco…

【2022工业3D异常检测文献】Patch+FPFH: 结合3D手工点云描述符和颜色特征的异常检测方法

AN EMPIRICAL INVESTIGATION OF 3D ANOMALY DETECTION AND SEGMENTATION 1、Background PatchCore 方法&#xff1a; PatchCore是一种基于2D图像的异常检测方法&#xff0c;它使用预训练的深度学习模型&#xff08;如在ImageNet上预训练的模型&#xff09;来提取图像的局部特…

Memory Bus in SOC

在 SoC架构设计中&#xff0c;Memory Bus 是一个关键的组成部分&#xff0c;它负责连接 SoC 中的各个模块&#xff08;如 CPU、GPU、DMA、外设等&#xff09;与外部存储器&#xff08;如 DDR、NAND、Flash 等&#xff09;&#xff0c;起到连接处理器和存储器之间的桥梁作用&…

Qt优秀开源项目之二十四:EXCEL读写利器QXlsx

QXlsx是基于Qt5/Qt6的Excel文件&#xff08;*.xlsx&#xff09;的读写库。 github地址&#xff1a;https://github.com/QtExcel/QXlsx QXlsx既可以编译成库&#xff0c;也可以直接引用源码QXlsx-master\QXlsx\QXlsx.pri QXls提供了非常丰富的Examples&#xff0c;比如&#xff…

LED电子看板减少人工记录的错误

在当今快节奏的生产和管理环境中&#xff0c;准确性和效率是企业追求的关键目标。而传统的人工记录方式&#xff0c;常常因人为因素而出现各种错误&#xff0c;影响着企业的决策和运营。然而&#xff0c;随着科技的不断进步&#xff0c;LED 电子看板的出现为解决这一难题提供了…

无法获得下列许可 SOLIDWORKS Standard。 无法从使用许可服务器内读取数据,(-16,10009,10054)

无法获得下列许可 SOLIDWORKS Standard。 无法从使用许可服务器内读取数据&#xff0c;(-16,10009,10054) 错误如图 打开xxclean 扩展功能 服务无法启动

10.23Python_matplotlib_乱码问题

中英文问题解决方案 在使用 Matplotlib 绘图时&#xff0c;经常会出现中文字体显示问题。以下是一些解决方案&#xff1a; Windows 系统解决方案 在代码开始处添加以下代码&#xff0c;以支持中文显示&#xff1a; import matplotlib.pyplot as plt plt.rcParams[font.sans…

联想与Meta合作基于Llama大模型推出面向PC的个人AI智能体——AI Now | LeetTalk Daily...

“LeetTalk Daily”&#xff0c;每日科技前沿&#xff0c;由LeetTools AI精心筛选&#xff0c;为您带来最新鲜、最具洞察力的科技新闻。 联想集团昨日在美国西雅图召开年度Tech World大会。联想CEO杨元庆在主题演讲中&#xff0c;与Meta创始人兼CEO马克扎克伯格一道宣布&#x…

《15分钟轻松学Go》教程目录

在AI快速发展的时代&#xff0c;学习Go语言依然很有用。Go语言擅长处理高并发任务&#xff0c;也就是说可以同时处理很多请求&#xff0c;这对于需要快速响应的AI服务非常重要。另外&#xff0c;Go适合用来处理和传输大量数据&#xff0c;非常适合机器学习模型的数据预处理。 …

C++笔记---哈希表

1. 哈希的概念 哈希(hash)又称散列&#xff0c;是一种组织数据的方式。从译名来看&#xff0c;有散乱排列的意思。 本质就是通过哈希函数把关键字Key跟存储位置建立一个映射关系&#xff0c;查找时通过这个哈希函数计算出Key存储的位置&#xff0c;进行快速查找。 STL中的un…

【Python数据库操作】使用SQLite和MySQL进行数据存储和查询!

【Python数据库操作】使用SQLite和MySQL进行数据存储和查询&#xff01; 在现代应用程序中&#xff0c;数据存储与管理是至关重要的。Python为开发者提供了多种与数据库进行交互的方式&#xff0c;其中SQLite和MySQL是最常用的两种数据库。本文将深入探讨如何使用Python进行SQ…

No.20 笔记 | WEB安全 - 任意文件操作详解 part 2

一、文件后缀名验证 &#xff08;一&#xff09;验证方式分类 基于白名单验证&#xff1a;只允许上传白名单中指定后缀名的文件。基于黑名单验证&#xff1a;只允许上传黑名单中未包含后缀名的文件。 &#xff08;二&#xff09;实验准备 修改 Apache 的 httpd - conf 文件…

uni-app写的微信小程序如何体积太大如何处理

方法一&#xff1a;对主包进行分包处理&#xff0c;将使用url: /pages/components/equipment/equipment跳转页面的全部拆分为分包&#xff0c;如url: /pagesS/components/equipment/equipment 在pages.json中添加 "subPackages": [{ "root"…

2024年五一杯数学建模C题煤矿深部开采冲击地压危险预测求解全过程论文及程序

2024年五一杯数学建模 C题 煤矿深部开采冲击地压危险预测 原题再现&#xff1a; “煤炭是中国的主要能源和重要的工业原料。然而&#xff0c;随着开采深度的增加&#xff0c;地应力增大&#xff0c;井下煤岩动力灾害风险越来越大&#xff0c;严重影响着煤矿的安全高效开采。在…

transient关键字详解

今天没打算写blog&#xff0c;在看一篇关于多线程环境下SimpleDateFormat线程不安全的问题&#xff0c;一般我们都知道多线程下这个是不安全&#xff0c;但是为什么不安全不太清楚&#xff0c;我在看的这篇文章讲的比较透彻&#xff0c;我根据文章中讲结合SimpleDateFormat源码…

[Unity Demo]从零开始制作空洞骑士Hollow Knight第十五集:制作更多地图,更多敌人,更多可交互对象

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、第一个代表性场景 1.制作更多敌人2.制作更多可交互对象二、第二个代表性场景 1.制作更多敌人2.制作更多可交互对象三、第三个代表性场景 1.制作更多敌人2.制…