如何在不使用任何构建工具的情况下使用aapt2编译Android应用? [英] How to compile an Android app with aapt2 without using any build tools?

查看:331
本文介绍了如何在不使用任何构建工具的情况下使用aapt2编译Android应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在不使用Gradle或任何其他构建工具的情况下,在Android Studio上编译刚在Kotlin中创建的Android应用程序.我的意图是加快编译应用程序的速度,而不必使用Android Studio或安装诸如Gradle,ant或buck的构建工具.我在将文件与aapt2链接时遇到问题.

I'm trying to compile an Android application I just created in Kotlin on Android Studio, without using Gradle or any other build tools. My intention is to speed up compiling applications without having to use Android Studio or install build tools like Gradle, ant or buck. I'm running into an issue linking files with aapt2.

我正在使用aapt2将res文件夹中的所有文件编译为一个zip文件.但是,当我尝试链接它们时,aapt2吐出错误. 该错误似乎是由于缺少应用程序兼容库造成的,我的问题是如何成功链接所有这些文件和kotlin文件以创建可部署的apk文件.

I'm compiling all files in res folder into a zip file with aapt2. But when I try to link them aapt2 spits out errors. The errors seem to be due to missing app compat libraries,and my questions is how to successfully link all these and kotlin files to create a deployable apk file.

以下内容将编译res文件夹中的所有文件,并创建resources.zip文件.

The following compiles all files in res folder and creates resources.zip file.

$AAPT compile --dir $APP_DIR/src/main/res -o $APP_DIR/build/intermediate/resources.zip    

但是这失败了.

$AAPT link -o $APP_DIR/build/intermediate/ -I $PLATFORM $APP_DIR/build/intermediate/resources.zip --manifest $APP_DIR/src/main/AndroidManifest.xml

有以下错误

error: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.example.myapplication:style/Theme.AppCompat.Light.DarkActionBar) not found.
./projects/MyApplication/app/src/main/res/values/styles.xml:6: error: style attribute 'attr/colorPrimary (aka com.example.myapplication:attr/colorPrimary)' not found.
./projects/MyApplication/app/src/main/res/values/styles.xml:7: error: style attribute 'attr/colorPrimaryDark (aka com.example.myapplication:attr/colorPrimaryDark)' not found.
./projects/MyApplication/app/src/main/res/values/styles.xml:8: error: style attribute 'attr/colorAccent (aka com.example.myapplication:attr/colorAccent)' not found.
error: resource style/ThemeOverlay.AppCompat.Dark.ActionBar (aka com.example.myapplication:style/ThemeOverlay.AppCompat.Dark.ActionBar) not found.
./projects/MyApplication/app/src/main/res/values/styles.xml:11: error: style attribute 'attr/windowActionBar (aka com.example.myapplication:attr/windowActionBar)' not found.
./projects/MyApplication/app/src/main/res/values/styles.xml:12: 
error: style attribute 'attr/windowNoTitle (aka com.example.myapplication:attr/windowNoTitle)' not found.
error: resource style/ThemeOverlay.AppCompat.Light (aka com.example.myapplication:style/ThemeOverlay.AppCompat.Light) not found.

错误:链接引用失败.

error: failed linking references.

这似乎是由于缺少应用程序兼容性库.我尝试手动下载appcompat-v7-27.1.1.aar文件并将其链接,但失败了.

This appears to be due to missing app compat libraries.I've tried manually downloading appcompat-v7-27.1.1.aar file and linking it but this to fails.

如果有人找到解决方案,请赐教.谢谢.

If anyone has come across a solution to this please enlighten me. Thanks.

我想用aapt2复制这里可用的内容 https://github.com/authmane512/android-project- template/blob/master/build.sh

I want to replicate what's available here with aapt2 https://github.com/authmane512/android-project-template/blob/master/build.sh

推荐答案

使用以下链接作为参考,以使用aapt/appt2来编译Java应用程序,以便您可以自己编写一个用于编译kotlin的程序.

Use the below link for reference of using aapt/appt2 for compiling java app, so that you can make one for compiling kotlin on your own.

https://github.com/HemanthJabalpuri/AndroidExplorer

这篇关于如何在不使用任何构建工具的情况下使用aapt2编译Android应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆