当前位置: 首页 > news >正文

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.

相关文章:

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 开发领域的经典著作&#xff0c;作者 Joshua Bloch 以丰富的经验和深入的知识&#xff0c;全面…...

Vivado HLS学习

视频链接: 6课&#xff1a;数据类型的转换_哔哩哔哩_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的现代化日志模块&#xff0c;具备窗口事件穿透、拖拽和缩放功能。 Axp Logger文档 特性现代化的UI设计支持点击穿透模式&#xff08;不影响脚本运行&#xff09;监听音量-键切换模式支持窗口操作模式窗口拖拽移动窗口自由缩放清空日志关闭日…...

成都睿明智科技有限公司共创抖音电商新篇章

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

Spark的安装配置及集群搭建

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

网络编程基础-IO模型深入理解

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

go 语言学习路线图(一)

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

前端自动化部署,Netlify免费满足你

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

Linux的开发工具gcc Makefile gdb的学习

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

基于SSM出租车管理系统的设计

管理员账户功能包括&#xff1a;系统首页&#xff0c;个人中心&#xff0c;车辆管理&#xff0c;驾驶员管理&#xff0c;基础数据管理&#xff0c;公告管理 驾驶员账号功能包括&#xff1a;系统首页&#xff0c;学生管理&#xff0c;车辆管理&#xff0c;公告管理 开发系统&a…...

iPhone照片内存怎么清理,参考这些方法

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

【Triton教程】向量相加

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

关于CSS中毛玻璃和滤镜使用总结

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

陷入产出危机的我聊聊近况

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

HarmonyOS 开发知识总结

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

[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批量处理数据时&#xff0c;有时候需要自动搜索文件夹中的所有txt文件&#xff0c;并将每个txt文件中的数据存放到一个以一定规律命名的变量中&#xff0c;以便于后续通过循环处理每个变量数据。 然而&#xff0c;MATLAB并不支持在变量名中直接使用i来动态生成变量…...

LabVIEW智能可变温循环PCT测试系统

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

SparkSQL整合Hive

spark-sql可以直接使用hive的元数据 1、环境搭建如下&#xff1a; ## 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…...

vscode里如何用git

打开vs终端执行如下&#xff1a; 1 初始化 Git 仓库&#xff08;如果尚未初始化&#xff09; git init 2 添加文件到 Git 仓库 git add . 3 使用 git commit 命令来提交你的更改。确保在提交时加上一个有用的消息。 git commit -m "备注信息" 4 …...

【HarmonyOS 5.0】DevEco Testing:鸿蒙应用质量保障的终极武器

——全方位测试解决方案与代码实战 一、工具定位与核心能力 DevEco Testing是HarmonyOS官方推出的​​一体化测试平台​​&#xff0c;覆盖应用全生命周期测试需求&#xff0c;主要提供五大核心能力&#xff1a; ​​测试类型​​​​检测目标​​​​关键指标​​功能体验基…...

可靠性+灵活性:电力载波技术在楼宇自控中的核心价值

可靠性灵活性&#xff1a;电力载波技术在楼宇自控中的核心价值 在智能楼宇的自动化控制中&#xff0c;电力载波技术&#xff08;PLC&#xff09;凭借其独特的优势&#xff0c;正成为构建高效、稳定、灵活系统的核心解决方案。它利用现有电力线路传输数据&#xff0c;无需额外布…...

(二)TensorRT-LLM | 模型导出(v0.20.0rc3)

0. 概述 上一节 对安装和使用有个基本介绍。根据这个 issue 的描述&#xff0c;后续 TensorRT-LLM 团队可能更专注于更新和维护 pytorch backend。但 tensorrt backend 作为先前一直开发的工作&#xff0c;其中包含了大量可以学习的地方。本文主要看看它导出模型的部分&#x…...

大数据零基础学习day1之环境准备和大数据初步理解

学习大数据会使用到多台Linux服务器。 一、环境准备 1、VMware 基于VMware构建Linux虚拟机 是大数据从业者或者IT从业者的必备技能之一也是成本低廉的方案 所以VMware虚拟机方案是必须要学习的。 &#xff08;1&#xff09;设置网关 打开VMware虚拟机&#xff0c;点击编辑…...

C++ 基础特性深度解析

目录 引言 一、命名空间&#xff08;namespace&#xff09; C 中的命名空间​ 与 C 语言的对比​ 二、缺省参数​ C 中的缺省参数​ 与 C 语言的对比​ 三、引用&#xff08;reference&#xff09;​ C 中的引用​ 与 C 语言的对比​ 四、inline&#xff08;内联函数…...

Element Plus 表单(el-form)中关于正整数输入的校验规则

目录 1 单个正整数输入1.1 模板1.2 校验规则 2 两个正整数输入&#xff08;联动&#xff09;2.1 模板2.2 校验规则2.3 CSS 1 单个正整数输入 1.1 模板 <el-formref"formRef":model"formData":rules"formRules"label-width"150px"…...

Aspose.PDF 限制绕过方案:Java 字节码技术实战分享(仅供学习)

Aspose.PDF 限制绕过方案&#xff1a;Java 字节码技术实战分享&#xff08;仅供学习&#xff09; 一、Aspose.PDF 简介二、说明&#xff08;⚠️仅供学习与研究使用&#xff09;三、技术流程总览四、准备工作1. 下载 Jar 包2. Maven 项目依赖配置 五、字节码修改实现代码&#…...

嵌入式学习笔记DAY33(网络编程——TCP)

一、网络架构 C/S &#xff08;client/server 客户端/服务器&#xff09;&#xff1a;由客户端和服务器端两个部分组成。客户端通常是用户使用的应用程序&#xff0c;负责提供用户界面和交互逻辑 &#xff0c;接收用户输入&#xff0c;向服务器发送请求&#xff0c;并展示服务…...

Go 并发编程基础:通道(Channel)的使用

在 Go 中&#xff0c;Channel 是 Goroutine 之间通信的核心机制。它提供了一个线程安全的通信方式&#xff0c;用于在多个 Goroutine 之间传递数据&#xff0c;从而实现高效的并发编程。 本章将介绍 Channel 的基本概念、用法、缓冲、关闭机制以及 select 的使用。 一、Channel…...