簡體   English   中英

如何在命令行中創建apk文件?

[英]How to create apk file in command line?

我正在使用eclipse ide構建apk文件。 現在我想在Linux的命令行中創建apk文件。 但是當我說螞蟻調試它給出了以下錯誤:

Unable to obtain resource from anttasks.jar
  java.util.zip.ZipException : error in opening zip file

Problem : failed to create task or type checkenv 
Cause : The name is undefined 
Action : Check the spelling
Action : Check that any custom tasks/types have been declared
Action : Check that any <presetdef>/<macrodef> declarations have taken place

我的螞蟻版本為1.9.2。 和android版本17。我有build.xml文件。

編輯:我將我的ant版本更改為1.8.0,但是無論如何我仍然得到那些無法創建任務或鍵入checkenv錯誤的信息。

確保在根目錄(即與build.xml相同的目錄)中有一個名為local.properties的文件。

確保此文件包含以下行:

sdk.dir=c:\\tools\\android-sdk

(當然,您需要使路徑適應您的有效SDK位置)

仔細檢查路徑是否正確。

重新運行ant debug

注意:文件local.properties是本地文件(通常不受版本控制!)

使用此示例,您需要將sdk.dir傳遞給ant,即ant -Dsdk.dir=<path to Android SDK>

您還需要指定七個左右的Android構建目標之一,因為默認的構建目標是'help'。

如果僅運行ant -Dsdk.dir=<path to Android SDK>ant -Dsdk.dir=<path to Android SDK>獲得一些幫助輸出,如下所示:

help:
 [echo] Android Ant Build. Available targets:
 [echo]    help:      Displays this help.
 [echo]    clean:     Removes output files created by other targets.
 [echo]    compile:   Compiles project's .java files into .class files.
 [echo]    debug:     Builds the application and signs it with a debug key.
 [echo]    release:   Builds the application. The generated apk file must be

 [echo]               signed before it is published.
 [echo]    install:   Installs/reinstalls the debug package onto a running
 [echo]               emulator or device.
 [echo]               If the application was previously installed, the
 [echo]               signatures must match.
 [echo]    uninstall: Uninstalls the application from a running emulator or
 [echo]               device.

成功構建總時間:7秒要構建APK,您必須指定調試或發布。

ant -Dsdk.dir=<path to Android SDK> debug

這將幫助您創建一個apk文件

我在做

1)SDK /工具/ Android更新項目-t 3 -p

2)螞蟻清潔釋放

3)jarsigner -keystore -storepass -keypass

4)sdk /工具/ zipalign -v 4 /bin/.apk

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM