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:
-
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
-
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
-
Set up the environment variable:
Point your system to use this specific version of Gradle by updating yourPATH
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.
相关文章:

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 ???…...

解读 Java 经典巨著《Effective Java》90条编程法则,第4条:通过私有构造器强化不可实例化的能力
文章目录 【前言】欢迎订阅【解读《Effective Java》】系列专栏java.lang.Math 类的设计经验总结 【前言】欢迎订阅【解读《Effective Java》】系列专栏 《Effective Java》是 Java 开发领域的经典著作,作者 Joshua Bloch 以丰富的经验和深入的知识,全面…...

Vivado HLS学习
视频链接: 6课:数据类型的转换_哔哩哔哩_bilibilihttps://www.bilibili.com/video/BV1bt41187RW?spm_id_from333.788.videopod.episodes&vd_sourcea75d5585c5297210add71187236ec90b&p6 目录 1.数据类型的转换 2.自动类型转换 2.1隐式数据转换 2.2…...

一款AutoXJS现代化美观的日志模块AxpLogger
简介 Axp Logger是一款基于autox.js的现代化日志模块,具备窗口事件穿透、拖拽和缩放功能。 Axp Logger文档 特性现代化的UI设计支持点击穿透模式(不影响脚本运行)监听音量-键切换模式支持窗口操作模式窗口拖拽移动窗口自由缩放清空日志关闭日…...

成都睿明智科技有限公司共创抖音电商新篇章
在当今这个数字化浪潮汹涌的时代,抖音电商以其独特的魅力迅速崛起,成为众多商家竞相追逐的新蓝海。在这片充满机遇与挑战的领域中,成都睿明智科技有限公司凭借其专业的服务、创新的策略和敏锐的市场洞察力,成为了众多商家信赖的合…...

Spark的安装配置及集群搭建
Spark的本地安装配置: 我们用scala语言编写和操作spark,所以先要完成scala的环境配置 1、先完成Scala的环境搭建 下载Scala插件,创建一个Maven项目,导入Scala依赖和插件 scala依赖 <dependency><groupId>org.scal…...

网络编程基础-IO模型深入理解
一、IO的基本概念 什么是IO? I/O就是计算机内存与外部设备之间拷贝数据的过程 什么是网络IO? 网络IO是指在计算机网络环境中进行的输入和输出操作,涉及数据在网络设备之间的传输。 网络IO操作可以是发送请求、接收响应、下载文件、传输数…...

go 语言学习路线图(一)
1. Go语言简介 Go语言的历史背景和设计理念Go的优势:简洁、高效、并发支持强Go的应用场景:微服务、云计算、系统编程 2. 开发环境设置 安装Go语言开发环境 在Windows、macOS、Linux系统上的安装方法 配置环境变量:GOROOT 和 GOPATH验证安装…...

前端自动化部署,Netlify免费满足你
1 Netlify 介绍 为什么推荐 Netliy , 主要还是穷,Netlify 免费太香了 Netlify you优势100GB 内免费 ,满足个人日常 需求,操作,兼容性绑定代码仓库,提交代码自动部署 支持 github , gitlab 等 大多常用代码仓库易操作只…...

Linux的开发工具gcc Makefile gdb的学习
一:gcc/g 1. 1 背景知识 1. 预处理(进行宏替换) 预处理 ( 进行宏替换 ) 预处理功能主要包括宏定义,文件包含,条件编译,去注释等。 预处理指令是以#号开头的代码行。 实例: gcc –E hello.c –o hello.i 选项“-E”,该选项的作用是让 gcc 在预处理结…...

基于SSM出租车管理系统的设计
管理员账户功能包括:系统首页,个人中心,车辆管理,驾驶员管理,基础数据管理,公告管理 驾驶员账号功能包括:系统首页,学生管理,车辆管理,公告管理 开发系统&a…...

iPhone照片内存怎么清理,参考这些方法
随着拍摄数量的增加,许多iPhone用户常常发现自己的手机存储空间不足,而照片无疑是占用空间的罪魁祸首之一。清理这些照片不仅能释放存储空间,还能提升设备的运行速度。小编将分享一些iPhone照片内存怎么清理的高效策略,助你告别冗…...

【Triton教程】向量相加
Triton 是一种用于并行编程的语言和编译器。它旨在提供一个基于 Python 的编程环境,以高效编写自定义 DNN 计算内核,并能够在现代 GPU 硬件上以最大吞吐量运行。 更多 Triton 中文文档可访问 →https://triton.hyper.ai/ 在本教程中,你将使…...

关于CSS中毛玻璃和滤镜使用总结
【1】毛玻璃 毛玻璃效果(也称为磨砂玻璃效果)可以通过 CSS 的 backdrop-filter 属性来实现。这个属性允许你在背景上应用各种滤镜效果,从而创建出类似磨砂玻璃的效果。这种效果通常用于创建半透明背景下的模糊效果,使得背景图像或…...

陷入产出危机的我聊聊近况
文章目录 前言我的多重身份作为IT网管作为运维人员作为Web开发人员作为游戏开发人员 总结 前言 在总结文章时,我把自己当做一个内容产出者,当这样一个身份进入每天按部就班的平稳状态时会陷入一种焦虑,产生一种居然没有什么可写的感觉&#…...

HarmonyOS 开发知识总结
1. HarmonyOS 开发知识总结 1.1. resources->base->media中不可以新建文件夹? 项目图片路径resources->base->media中不可以新建文件夹,图片全平级放里面,查找图片不方便,有没有什么其他的办法解决这个难点ÿ…...

[WPF初学到大神] 1. 什么是WPF, MVVM框架, XAML?
什么是WPF? WPF(Windows Presentation Foundation) 包含XAML标记语言和后端代码来开发桌面应用程序的. 用VS新建项目有WPF(.Net Framework和.Net应用程序), 该怎么选? 首选 .NET 应用程序(.NET Core 或 .NET 5/6/7/8新版本)拥有更好的性能、跨平台Windows, Linux, Mac支…...

matlab怎样自动搜索文件夹中的所有txt文件,并将每个txt文件中的数据存放到一个cell数组中——MATLAB批量处理数据
在使用MATLAB批量处理数据时,有时候需要自动搜索文件夹中的所有txt文件,并将每个txt文件中的数据存放到一个以一定规律命名的变量中,以便于后续通过循环处理每个变量数据。 然而,MATLAB并不支持在变量名中直接使用i来动态生成变量…...

LabVIEW智能可变温循环PCT测试系统
随着全球能源危机的加剧和环境保护需求的提升,开发和利用清洁能源已成为全球必然趋势。氢能作为一种高效的替代能源,正逐步受到关注。然而,储氢技术的研究至关重要,尤其是储氢材料的PCT(Pressure-Composition-Temperat…...

SparkSQL整合Hive
spark-sql可以直接使用hive的元数据 1、环境搭建如下: ## 1、启动hive的元数据服务shell # 1、修改hive的配置文件 cd /usr/local/soft/hive-3.1.3/conf# 2、增加配置 vim hive-site.xml<property> <name>hive.metastore.uris</name> <value…...

Vue 3 和 Vue 2区别
Vue 3 是 Vue 2 的全新升级版本,引入了诸多新的特性,并在性能、开发体验、响应式系统等多个方面进行了改进。以下是 Vue 2 和 Vue 3 的详细对比: 1. 生命周期钩子差异 Vue 3 保留了大部分 Vue 2 的生命周期钩子,但部分名称有所调…...

React.memo和useMemo
React.memo和usememo React.memo React.memo是一个高阶组件,对组件进行性能优化,主要用于优化函数组件的性能,如果一个组件在相同的props下渲染出相同的结果,但是又不需要在组件更新的时候重新渲染,就可以使用react.…...

Android中实现网络请求的方式有哪些?
在Android开发中,实现网络请求是开发过程中不可避免的一部分。随着技术的不断发展,Android中出现了多种实现网络请求的方式,每种方式都有其独特的优缺点。 一、HttpURLConnection HttpURLConnection是Java提供的用于发送HTTP请求的标准类&a…...

安卓13usb触摸唤醒系统 android13触摸唤醒
总纲 android13 rom 开发总纲说明 文章目录 1.前言2.问题分析3.代码分析4.代码修改5.编译6.彩蛋1.前言 android13在待机后,需要能够使用触摸屏去唤醒我们的系统,这就需要我们修改系统的相关配置了。 2.问题分析 对于这个问题,我们需要知道安卓的事件分发,通过事件分发,…...

c++常用库函数
一.sort排序 快排的改进算法,评价复杂度为(nlogn). 1.用法 sort(起始地址,结束地址下一位,*比较函数) [起始地址,结束地址) (左开右闭) #include<bits/stdc.h> using namespace std; int main() {//sortvector<int&g…...

CSS 网格布局
网格布局是一个二维布局系统,允许开发者以行和列的形式创建灵活的网络,并将内容放置在网络的单元格中。有些元素可能只占据网络的一个单元,另一些元素则可能占据多行或多列。 网格的大小既可以精确定义,也可以根据自身内容自动计…...

python实现屏幕录制,录音录制工具
python实现屏幕录制,录音录制工具 一,介绍 Python 实现的屏幕录制和录音录制工具是一个便捷的应用程序,旨在帮助用户同时捕捉计算机屏幕上的活动以及与之相关的音频输出。这个工具尤其针对教育工作者、内容创作者、技术支持人员以及任何需要…...

elementui 的 table 组件回显已选数据时候使用toggleRowSelection 方法的坑点
elementui 的 table 组件回显问题 "vue": "^2.7.16", "element-ui": "^2.15.14", 问题描述: 场景:首先我们是通过接口获取到数据之后 然后将返回的数据回显到表格上面 问题:直接将后端返回的数据…...

MATLAB基础应用精讲-【数模应用】负二项回归(附R语言和python代码实现)
目录 前言 几个高频面试题目 负二项回归、Probit回归如何选择 负二项回归 Probit回归 知识储备 逻辑回归 算法原理 多阈值负二项回归模型 模型及估计方法 负二项回归模型 多阈值负二项回归模型 分割阶段 精确估计阈值阶段 负二项回归的操作步骤 负二项回归…...

20240803 芯动科技 笔试
文章目录 1、单选题1.11.21.31.42、填空题2.12.23、问答题3.13.23.34、编程题4.14.24.3岗位:嵌入式软件工程师(25届校招)(J12042) 题型:4 道单选题,2 道填空题, 3 道简答题,3 道编程题 1、单选题 1.1 已知 5 个元素的出栈序列是 1,2,3,4,5,6 则对应的入栈顺序可能是 …...