Java Android AAPT 发生了什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2451840/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 07:53:29  来源:igfitidea点击:

What happened to Android AAPT?

javaandroidexceptionant

提问by mike boldischar

I downloaded the most recent version of Android for Linux (android-sdk_r05-linux_86.tgz). I was trying to use the the Android Ant task(s) for packaging, building, and deploying my code. I should mention that I'm running AMD64, but I have the 32-bit libraries installed. The Android Ant tasks are all broken.

我下载了适用于 Linux 的最新版本的 Android (android-sdk_r05-linux_86.tgz)。我试图使用 Android Ant 任务来打包、构建和部署我的代码。我应该提到我正在运行 AMD64,但我安装了 32 位库。Android Ant 任务都被破坏了。

First, the start-emulator task never gets the emulator running. It does get past starting adb, but then it just sits there.

首先,启动模拟器任务永远不会让模拟器运行。它确实通过了启动 adb,但它只是坐在那里。

Second, the SDK is missing the AAPT binary in the tools directory. So, the example notepad sample application will not even package correctly.

其次,SDK 在工具目录中缺少 AAPT 二进制文件。因此,示例记事本示例应用程序甚至无法正确打包。

java.lang.IllegalStateException: Can't find aapt inside the sdk
at /home/user/bin/android-sdk-linux_86
at com.googlecode.autoandroid.lib.AndroidTools.locateTool(AndroidTools.java:116)
at com.googlecode.autoandroid.lib.AndroidTools.startTool(AndroidTools.java:103)
at com.googlecode.autoandroid.lib.AndroidTools.startTool(AndroidTools.java:91)
at com.googlecode.autoandroid.lib.UnixAndroidTools.aapt(UnixAndroidTools.java:9)

java.lang.IllegalStateException:找不到AAPT的SDK里面
在/ home / user中/斌/ Android的SDK-linux_86
在com.googlecode.autoandroid.lib.AndroidTools.locateTool(AndroidTools.java:116)
在com.googlecode .autoandroid.lib.AndroidTools.startTool(AndroidTools.java:103
)
在 com.googlecode.autoandroid.lib.AndroidTools.startTool(AndroidTools.java:91 )在 com.googlecode.autoandroid.lib.UnixAndroidTools.aapt(UnixAndroidTools.java :9)

I have all the dependencies configured for Android. I can run it from the command line just fine.

我为 Android 配置了所有依赖项。我可以从命令行运行它就好了。

I assume the Ant code is out of sync with the recent SDK updates. Can anyone shed some light on this problem? At this point, I'm considering writing my own Python scripts to interact with the Android SDK. Ugh.

我假设 Ant 代码与最近的 SDK 更新不同步。任何人都可以对这个问题有所了解吗?此时,我正在考虑编写自己的 Python 脚本来与 Android SDK 进行交互。啊。

采纳答案by CommonsWare

I have written three books all using the Android Ant build scripts. Trust me, they work.

我写了三本书都使用 Android Ant 构建脚本。相信我,它们有效。

First, the start-emulator task never gets the emulator running. It does get past starting adb, but then just sits there.

首先,启动模拟器任务永远不会让模拟器运行。它确实通过了启动 adb,但只是坐在那里。

Run the androidcommand and launch the emulator from AVD Manager window that appears. AFAIK, there is no start-emulatortask in Ant -- in fact, I'm not aware that there ever has been one.

运行android命令并从出现的 AVD Manager 窗口启动模拟器。AFAIK,start-emulatorAnt 中没有任务——事实上,我不知道曾经有过这样的任务。

Second, the SDK is missing the aapt binary in the tools directory.

其次,SDK 缺少工具目录中的 aapt 二进制文件。

If you are looking in $ANDROID_HOME/tools/(where $ANDROID_HOMEis where you unpacked the SDK), you aren't supposed to find aapt there. That directory is for tools that directly support all API levels. API-level-specific tools, like aapt, will reside in $ANDROID_HOME/platforms/$SDK/tools/(where $SDKis the name of some Android version, like android-2.1).

如果你正在寻找$ANDROID_HOME/tools/$ANDROID_HOME你在哪里解压 SDK),你不应该在那里找到 aapt。该目录用于直接支持所有 API 级别的工具。特定于 API 级别的工具,例如aapt,将驻留在$ANDROID_HOME/platforms/$SDK/tools/(其中$SDK是某些 Android 版本的名称,例如android-2.1)中。

If you do not have anything in $ANDROID_HOME/platforms/, please follow step 4 of the installation instructions.

如果您没有任何东西$ANDROID_HOME/platforms/,请按照安装说明的第 4 步操作

回答by Sofi Software LLC

For anyone running into this recently, aapt moved again. It's now in $ANDROID_SDK/build-tools/17.0.0.

对于最近遇到此问题的任何人,aapt 再次移动。它现在位于 $ANDROID_SDK/build-tools/17.0.0。