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 mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java     1111      manual mode
  2            /usr/lib/jvm/java-17-openjdk-amd64/bin/java     1112      manual mode

Press <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.

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Linux 中 .bash_history、.bash_logout 等用户配置文件

目录 前言.bash_history.bash_logout.bash_profile.bashrc.cshrc.tcshrc.viminfo 总结 前言 在 Linux 中我们经常会看见用户家目录下存在 .bash_history、.bash_logout、.bash_profile、.bashrc、.cshrc、.tcshrc、.viminfo 这写文件&#xff0c;那它们区别是什么呢&#xff1…

2024软考网络工程师笔记 - 第8章.网络安全

文章目录 网络安全基础1️⃣网络安全威胁类型2️⃣网络攻击类型3️⃣安全目标与技术 &#x1f551;现代加密技术1️⃣私钥密码/对称密码体制2️⃣对称加密算法总结3️⃣公钥密码/非对称密码4️⃣混合密码5️⃣国产加密算法 - SM 系列6️⃣认证7️⃣基于公钥的认证 &#x1f552…

Unity CRP学习笔记(一)

Unity CRP学习笔记&#xff08;一&#xff09; 主要参考&#xff1a; https://catlikecoding.com/unity/tutorials/custom-srp/ https://docs.unity.cn/cn/2022.3/ScriptReference/index.html 中文教程部分参考&#xff08;可选&#xff09;&#xff1a; https://tuncle.blog/c…

算力的定义、单位、影响因素、提升方法、分类、应用等。附超算排名

文章目录 算力的定义算力的单位FLOPS&#xff08;Floating Point Operations Per Second&#xff0c;浮点运算次数/秒&#xff09;IPS&#xff08;Instructions Per Second&#xff0c;指令/秒&#xff09;TOPS&#xff08;Trillion Operations Per Second&#xff0c;万亿次/秒…

Win10系统安装docker操作步骤

Docker下载 docker下载地址&#xff1a;Docker: Accelerated Container Application Development 打开网页后&#xff0c;点击图下所示&#xff0c;下载windows版本的docker 启用Hyper-V 和容器特性 右键左下角windows图标&#xff0c;选择应用和功能 然后在下面的界面中&am…

【Nuvoton干货分享】开发应用篇 4 -- 8bit MCU Flash 操作

我们在进行实际开发设计中&#xff0c;难免需要进行数据存储&#xff0c;早期很多都是外接EEPROM来进行设计&#xff0c;但是需要增加成本。其实芯片内部的Flash也是可以当成数据存储空间的。本章节主要介绍新唐的8位机如何进行常量数据的存储操作。 一、存储空间划分 我这边…

w~自动驾驶合集6

我自己的原文哦~ https://blog.51cto.com/whaosoft/12286744 #自动驾驶的技术发展路线 端到端自动驾驶 Recent Advancements in End-to-End Autonomous Driving using Deep Learning: A SurveyEnd-to-end Autonomous Driving: Challenges and Frontiers 在线高精地图 HDMa…

小程序无法获取头像昵称以及手机号码

用户在使用小程序的时候&#xff0c;登录弹出获取昵称头像或者个人中心点击默认头像弹窗获取头像昵称的时候&#xff0c;点击弹窗中的头像昵称均无反应&#xff0c; 这个是因为你的小程序隐私政策没有更新&#xff0c;或者老版本没有弹窗让用户同意导致的 解决办法&#xff1…

利用彩色相机给激光点云染色

文章目录 概述核心代码效果概述 在激光SLAM(Simultaneous Localization and Mapping)中,使用彩色相机为激光点云染色是一个常见的做法。这种技术结合了激光雷达的高精度距离测量和相机的丰富色彩信息,使得生成的点云不仅包含空间位置信息,还包含颜色信息,从而更直观和细…

【OpenAI】第六节(语音生成与语音识别技术)从 ChatGPT 到 Whisper 的全方位指南

前言 在人工智能的浪潮中&#xff0c;语音识别技术正逐渐成为我们日常生活中不可或缺的一部分。随着 OpenAI 的 Whisper 模型的推出&#xff0c;语音转文本的过程变得前所未有的简单和高效。无论是从 YouTube 视频中提取信息&#xff0c;还是将播客内容转化为文本&#xff0c;…

[实时计算flink]数据摄入YAML作业快速入门

实时计算Flink版基于Flink CDC&#xff0c;通过开发YAML作业的方式有效地实现了将数据从源端同步到目标端的数据摄入工作。本文介绍如何快速构建一个YAML作业将MySQL库中的所有数据同步到StarRocks中。 前提条件 已创建Flink工作空间&#xff0c;详情请参见开通实时计算Flink版…

Jenkins配置CI/CD开发环境(理论到实践的完整流程)

目录 一、对于CI/CD的理解1.1、什么是CI&#xff08;持续集成&#xff09;1.2、CI 的主要特点&#xff1a;1.3、CI 的优势&#xff1a;**实际开发中的场景举例:** 1.4、什么是 CD&#xff08;持续交付和持续部署&#xff09;1.5、持续交付&#xff08;Continuous Delivery&…

鸿蒙HarmonyOS NEXT 5.0开发(2)—— ArkUI布局组件

文章目录 布局Column&#xff1a;从上往下的布局Row&#xff1a;从左往右的布局Stack&#xff1a;堆叠布局Flex&#xff1a;自动换行或列 组件Swiper各种选择组件 华为官方教程B站视频教程 布局 主轴和交叉轴的概念&#xff1a; 对于Column布局而言&#xff0c;主轴是垂直方…

如何区分真假Facebook三不限海外户?

对于需要推广到海外的企业来说&#xff0c;Facebook是一个重要的渠道。由于Facebook对国内普通企业户的风控极为严格&#xff0c;让不少出海广告主都很头疼&#xff0c;一到要出量的时刻就限额、挂户各种问题&#xff0c;根本没有办法跑起来量&#xff0c;白白错过好时机。对于…

R语言统计分析——置换检验3

参考资料&#xff1a;R语言实战【第2版】 列联表的独立性 通过chisq_test()或cmh_test()函数&#xff0c;我们可以用置换检验判断两类别型变量的独立性。当数据可根据第三个类别型变量进行分层时&#xff0c;需要使用后一个函数。若变量都是有序型&#xff0c;可使用lbl_test(…

047_python基于Hadoop的租房数据分析系统的设计与实现

目录 系统展示 开发背景 代码实现 项目案例 获取源码 博主介绍&#xff1a;CodeMentor毕业设计领航者、全网关注者30W群落&#xff0c;InfoQ特邀专栏作家、技术博客领航者、InfoQ新星培育计划导师、Web开发领域杰出贡献者&#xff0c;博客领航之星、开发者头条/腾讯云/AW…

基于 Konva 实现Web PPT 编辑器(三)

完善公式 上一节我们简单讲述了公式的使用&#xff0c;并没有给出完整的样例&#xff0c;下面还是完善下相关步骤&#xff0c;我们是默认支持公式的编辑功能的哈&#xff0c;因此&#xff0c;我们只需要提供必要的符号即可&#xff1a; 符号所表达的含义是 mathlive 的command命…

socket套接字

1.IP地址 IP地址是在IP协议中, 用来标识网络中不同主机的地址。由点分十进制组成&#xff0c;在数据传输中IP地址是一直不变的。 在IP数据包头部中, 有两个IP地址&#xff0c; 分别叫做源IP地址和目的IP地址。 2.端口号 由2字节16位整数组成&#xff0c;标识当前主机的唯一…

YOLO V3 网络构架解析

YOLO V3&#xff08;You Only Look Once version 3&#xff09;是由Joseph Redmon等人于2018年提出的一种基于深度学习的目标检测算法。它在速度和精度上相较于之前的版本有了显著提升&#xff0c;成为计算机视觉领域的一个重要里程碑。本文将详细解析YOLO V3的网络架构&#x…

关于WPF项目降低.Net版本

本来有项目是.NET Framework 4.8的&#xff0c;为了兼容升级到.NET 8.0&#xff0c;后期又为了兼容放弃.NET 8.0&#xff0c;升级的步骤&#xff1a;利用vs2022 的 .NET Upgrade Assistant 扩展&#xff0c;磕磕绊绊也升级完成了&#xff1b; 扩展链接&#xff1a; Upgrading…