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 yourPATHenvironment variable.Add the following line to your
~/.bashrc(or~/.profile):export PATH=/opt/gradle/gradle-8.10/bin:$PATHThen 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
PATHenvironment 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…...
浏览器访问 AWS ECS 上部署的 Docker 容器(监听 80 端口)
✅ 一、ECS 服务配置 Dockerfile 确保监听 80 端口 EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]或 EXPOSE 80 CMD ["python3", "-m", "http.server", "80"]任务定义(Task Definition&…...
MongoDB学习和应用(高效的非关系型数据库)
一丶 MongoDB简介 对于社交类软件的功能,我们需要对它的功能特点进行分析: 数据量会随着用户数增大而增大读多写少价值较低非好友看不到其动态信息地理位置的查询… 针对以上特点进行分析各大存储工具: mysql:关系型数据库&am…...
visual studio 2022更改主题为深色
visual studio 2022更改主题为深色 点击visual studio 上方的 工具-> 选项 在选项窗口中,选择 环境 -> 常规 ,将其中的颜色主题改成深色 点击确定,更改完成...
使用分级同态加密防御梯度泄漏
抽象 联邦学习 (FL) 支持跨分布式客户端进行协作模型训练,而无需共享原始数据,这使其成为在互联和自动驾驶汽车 (CAV) 等领域保护隐私的机器学习的一种很有前途的方法。然而,最近的研究表明&…...
为什么需要建设工程项目管理?工程项目管理有哪些亮点功能?
在建筑行业,项目管理的重要性不言而喻。随着工程规模的扩大、技术复杂度的提升,传统的管理模式已经难以满足现代工程的需求。过去,许多企业依赖手工记录、口头沟通和分散的信息管理,导致效率低下、成本失控、风险频发。例如&#…...
【Redis技术进阶之路】「原理分析系列开篇」分析客户端和服务端网络诵信交互实现(服务端执行命令请求的过程 - 初始化服务器)
服务端执行命令请求的过程 【专栏简介】【技术大纲】【专栏目标】【目标人群】1. Redis爱好者与社区成员2. 后端开发和系统架构师3. 计算机专业的本科生及研究生 初始化服务器1. 初始化服务器状态结构初始化RedisServer变量 2. 加载相关系统配置和用户配置参数定制化配置参数案…...
Xen Server服务器释放磁盘空间
disk.sh #!/bin/bashcd /run/sr-mount/e54f0646-ae11-0457-b64f-eba4673b824c # 全部虚拟机物理磁盘文件存储 a$(ls -l | awk {print $NF} | cut -d. -f1) # 使用中的虚拟机物理磁盘文件 b$(xe vm-disk-list --multiple | grep uuid | awk {print $NF})printf "%s\n"…...
AI病理诊断七剑下天山,医疗未来触手可及
一、病理诊断困局:刀尖上的医学艺术 1.1 金标准背后的隐痛 病理诊断被誉为"诊断的诊断",医生需通过显微镜观察组织切片,在细胞迷宫中捕捉癌变信号。某省病理质控报告显示,基层医院误诊率达12%-15%,专家会诊…...
return this;返回的是谁
一个审批系统的示例来演示责任链模式的实现。假设公司需要处理不同金额的采购申请,不同级别的经理有不同的审批权限: // 抽象处理者:审批者 abstract class Approver {protected Approver successor; // 下一个处理者// 设置下一个处理者pub…...
Netty从入门到进阶(二)
二、Netty入门 1. 概述 1.1 Netty是什么 Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients. Netty是一个异步的、基于事件驱动的网络应用框架,用于…...
