文件'Androidtest.apk'不包含AndroidManifest文件

时间:2013-10-01 10:26:54

标签: apk aapt android-package-managers

我正在尝试创建apk file using appt tool from command prompt。我使用了以下命令。问题是,我无法在设备/模拟器中安装生成的APK 文件。得到file 'Androidtest.apk' does not contain AndroidManifest file错误。请你检查一下并通知我我做了什么错误?

echo on

SET PREV_PATH=%CD%
cd /d %0\..

REM Clear bin folder
rmdir "bin" /S /Q
rmdir "gen" /S /Q
mkdir "bin" || goto EXIT
mkdir "gen" || goto EXIT

REM Set your application name
SET APP_NAME=AndroidAPKGeneration

REM Define minimal Android revision
SET ANDROID_REV=android-16

REM Define aapt add command
SET ANDROID_AAPT_ADD="%ANDROID-SDK%\build-tools\android-4.2.2\aapt.exe" add

REM Define aapt pack and generate resources command
SET ANDROID_AAPT_PACK="%ANDROID-SDK%\build-tools\android-4.2.2\aapt.exe" package -v -f -I "%ANDROID-SDK%\platforms\%ANDROID_REV%\android.jar"

REM Define class file generator command
SET ANDROID_DX="%ANDROID-SDK%\build-tools\android-4.2.2\dx.bat" --dex

REM Define Java compiler command
SET JAVAC="%JAVABIN%\javac.exe" -classpath "%ANDROID-SDK%\platforms\%ANDROID_REV%\android.jar"
SET JAVAC_BUILD=%JAVAC% -sourcepath "src;gen" -d "bin"

REM Generate R class and pack resources and assets into resources.ap_ file
call "%ANDROID-SDK%\build-tools\android-4.2.2\aapt.exe" package -v -f -I "%ANDROID-SDK%\platforms\android-16\android.jar" -M "AndroidManifest.xml" -A "assets" -S "res" -m -J "gen" -F "bin\resources.ap_" || goto EXIT

REM Compile sources. All *.class files will be put into the bin folder
call %JAVAC_BUILD% src\com\example\androidapkgeneration\*.java || goto EXIT

REM Generate dex files with compiled Java classes
call %ANDROID_DX% --verbose --output="%CD%\bin\classes.dex" %CD%\bin %CD%\libs || goto EXIT

REM Recources file need to be copied. This is needed for signing.
copy "%CD%\bin\resources.ap_" "%CD%\bin\%APP_NAME%.ap_" || goto EXIT

REM Create unsigned Android application from *.ap_ file. Output and Input files must be different.
call %ANDROID_AAPT_PACK% -F %CD%\bin\%APP_NAME%.unsigned.apk %CD%\bin

REM Delete temp file
del "bin\%APP_NAME%.ap_"

:EXIT
cd "%PREV_PATH%"
ENDLOCAL
exit /b %ERRORLEVEL%

参考:http://geosoft.no/development/android.html

0 个答案:

没有答案