当前位置: 首页 > 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…...

AI-调查研究-01-正念冥想有用吗?对健康的影响及科学指南

点一下关注吧&#xff01;&#xff01;&#xff01;非常感谢&#xff01;&#xff01;持续更新&#xff01;&#xff01;&#xff01; &#x1f680; AI篇持续更新中&#xff01;&#xff08;长期更新&#xff09; 目前2025年06月05日更新到&#xff1a; AI炼丹日志-28 - Aud…...

SkyWalking 10.2.0 SWCK 配置过程

SkyWalking 10.2.0 & SWCK 配置过程 skywalking oap-server & ui 使用Docker安装在K8S集群以外&#xff0c;K8S集群中的微服务使用initContainer按命名空间将skywalking-java-agent注入到业务容器中。 SWCK有整套的解决方案&#xff0c;全安装在K8S群集中。 具体可参…...

【Linux】shell脚本忽略错误继续执行

在 shell 脚本中&#xff0c;可以使用 set -e 命令来设置脚本在遇到错误时退出执行。如果你希望脚本忽略错误并继续执行&#xff0c;可以在脚本开头添加 set e 命令来取消该设置。 举例1 #!/bin/bash# 取消 set -e 的设置 set e# 执行命令&#xff0c;并忽略错误 rm somefile…...

智慧医疗能源事业线深度画像分析(上)

引言 医疗行业作为现代社会的关键基础设施,其能源消耗与环境影响正日益受到关注。随着全球"双碳"目标的推进和可持续发展理念的深入,智慧医疗能源事业线应运而生,致力于通过创新技术与管理方案,重构医疗领域的能源使用模式。这一事业线融合了能源管理、可持续发…...

C++:std::is_convertible

C++标志库中提供is_convertible,可以测试一种类型是否可以转换为另一只类型: template <class From, class To> struct is_convertible; 使用举例: #include <iostream> #include <string>using namespace std;struct A { }; struct B : A { };int main…...

day52 ResNet18 CBAM

在深度学习的旅程中&#xff0c;我们不断探索如何提升模型的性能。今天&#xff0c;我将分享我在 ResNet18 模型中插入 CBAM&#xff08;Convolutional Block Attention Module&#xff09;模块&#xff0c;并采用分阶段微调策略的实践过程。通过这个过程&#xff0c;我不仅提升…...

【第二十一章 SDIO接口(SDIO)】

第二十一章 SDIO接口 目录 第二十一章 SDIO接口(SDIO) 1 SDIO 主要功能 2 SDIO 总线拓扑 3 SDIO 功能描述 3.1 SDIO 适配器 3.2 SDIOAHB 接口 4 卡功能描述 4.1 卡识别模式 4.2 卡复位 4.3 操作电压范围确认 4.4 卡识别过程 4.5 写数据块 4.6 读数据块 4.7 数据流…...

系统设计 --- MongoDB亿级数据查询优化策略

系统设计 --- MongoDB亿级数据查询分表策略 背景Solution --- 分表 背景 使用audit log实现Audi Trail功能 Audit Trail范围: 六个月数据量: 每秒5-7条audi log&#xff0c;共计7千万 – 1亿条数据需要实现全文检索按照时间倒序因为license问题&#xff0c;不能使用ELK只能使用…...

电脑插入多块移动硬盘后经常出现卡顿和蓝屏

当电脑在插入多块移动硬盘后频繁出现卡顿和蓝屏问题时&#xff0c;可能涉及硬件资源冲突、驱动兼容性、供电不足或系统设置等多方面原因。以下是逐步排查和解决方案&#xff1a; 1. 检查电源供电问题 问题原因&#xff1a;多块移动硬盘同时运行可能导致USB接口供电不足&#x…...

CRMEB 框架中 PHP 上传扩展开发:涵盖本地上传及阿里云 OSS、腾讯云 COS、七牛云

目前已有本地上传、阿里云OSS上传、腾讯云COS上传、七牛云上传扩展 扩展入口文件 文件目录 crmeb\services\upload\Upload.php namespace crmeb\services\upload;use crmeb\basic\BaseManager; use think\facade\Config;/*** Class Upload* package crmeb\services\upload* …...