command line to create an Android projectView SDK Information
Change the directory to the tools/path of the Android SDK.
Perform:
Android list targets
This will print a list of available Android platforms that you have downloaded for your SDK. Find the note that you want to compile the target ID of the platform for your application. We recommend that you select the highest possible version. You can still build your application to support older versions, but setting the build target to the latest version allows you to optimize the latest devices for your application.
Create a Project command
Android Create Project--target <target_ID>--name <your_project_name>--path path/to/your/project-- Activity <your_activity_name>--package
command example
Android Create Project--target--name myfirstapp--path F:\Workspace_Test\test\MyFirstApp--activity mainactivity--p Ackage Com.example.myfirstapp
Command description
42 for SDK ID
Myfirstapp for Project name
F:\Workspace_Test\test\MyFirstApp for the project root directory
Mainactivity the project main activity name (that is, initiating activity)
Com.example.myfirstapp for the project package name
Command line Packaging 1. Build R.java file Create gen Directory
If there is no Gen directory under the F:\WORKSPACE_TEST\TEST\MYFIRSTAPP directory, run
mkdir F:\Workspace_Test\test\MyFirstApp\gen
Run the AAPT command to generate a R.java file to switch to the Aapt.exe root directory
CD F:\AndroidSDK\android-sdk-windows\build-tools\19.0.0
Generate R.java File
Aapt.exe package-f-m-j gen-s res-i F:\AndroidSDK\android-sdk-windows\platforms\android-Honeycomb\android.jar-M Android Oidmanifest.xml
Command description
F:\AndroidSDK\android-sdk-windows\platforms\android-Honeycomb\android.jar This is going to correspond to the previous 42.
2. Compiling a Java file into a class file
If you do not have a bin directory, first create it with mkdir F:\Workspace_Test\test\MyFirstApp\bin
Javac-encoding UTF-8-target 1.7-bootclasspath F:\AndroidSDK\android-sdk-windows\platforms\android-Honeycomb\ Android.jar-dbin Src\com\example\myfirstapp\*.java Gen\com\example\myfirstapp\r.java
Command description
1.7 for JDK version
F:\AndroidSDK\android-sdk-windows\platforms\android-Honeycomb \android.jar corresponds to generating R.java file
Src\com\example\myfirstapp is where the Java files are located
Gen\com\example\myfirstapp is the location of the R.java file
3. Generate the Dex file (note to use absolute path) to switch to the Dx.bat root directory
CD F:\AndroidSDK\android-sdk-windows\build-tools\19.0.0
Generate DEX Files
Dx.bat--dex--output=f:\workspace_test\test\myfirstapp\bin\classes.dex F:\Workspace_Test\test\MyFirstApp\bin
Command description
F:\Workspace_Test\test\MyFirstApp\bin\classes.dex save location and name for Dex files
F:\Workspace_Test\test\MyFirstApp\bin is the Bin folder location
4. Generate a resource bundle file to switch to the Aapt.exe root directory
CD F:\AndroidSDK\android-sdk-windows\build-tools\19.0.0
Generate a resource bundle file
If you do not have a assets folder, create it with mkdir F:\Workspace_Test\test\MyFirstApp\assets first
Aapt.exe package-f-M androidmanifest.xml-s res-a assets-i F:\AndroidSDK\android-sdk-windows\platforms\ Android-honeycomb\android.jar-f bin\resources
Command description
F:\AndroidSDK\android-sdk-windows\platforms\android-Honeycomb\android.jar corresponding to generated R.java file
5. Generate an unsigned apk package (Apkbuilder.bat deprecated)
Set Classpath=f:\androidsdk\android-sdk-windows\tools\lib\sdklib.jar;.; %classpath% (set Sdklib.jar reference, Tools\lib\sdklib.jar in the SDK root directory)
Java com.android.sdklib.build.ApkBuilderMain F:\Workspace_Test\test\MyFirstApp\bin\app.apk-v-u-z F:\Workspace_ Test\test\myfirstapp\bin\resources-f F:\WORKSPACE_TEST\TEST\MYFIRSTAPP\BIN\CLASSES.DEX-RF F:\Workspace_Test\test \myfirstapp\src
Command description
F:\Workspace_Test\test\MyFirstApp\bin\app.apk the location and name of the generated unsigned apk
Just modify all the F:\Workspace_Test\test\MyFirstApp for the project root directory path
6. Signature Generation Signature
Keytool-genkey-alias android.keystore-keyalg rsa-validity 20000-keystore android.keystore (20000 for finite period (days))
Signature APK switch to SDK tools directory
CD F:\AndroidSDK\android-sdk-windows\tools
Jarsigner-verbose-keystore F:\Workspace_Test\test\keystore\android.keystore-storepassandroid-signedjar f:\ workspace_test\test\myfirstapp\bin\app_signed.apk F:\Workspace_Test\test\MyFirstApp\bin\app.apk Android.keysotre -digestalg Sha1-sigalg Md5withrsa
Command description
Jdk1.6 does not add-digestalgsha1-sigalg Md5withrsa
Jdk1.7 must be added to the back-digestalgsha1-sigalg Md5withrsa
F:\Workspace_Test\test\keystore\android.keystore to KeyStore file path
Android for KeyStore password
F:\WORKSPACE_TEST\TEST\MYFIRSTAPP\BIN\APP_SIGNED.APK for the post-signature apk file path
F:\Workspace_Test\test\MyFirstApp\bin\app.apk for unsigned apk file path
Android.keysotre to KeyStore Alias
7. Align (optimize application)
Zipalign-v 4 F:\Workspace_Test\test\MyFirstApp\bin\app_signed.apk F:\Workspace_Test\test\MyFirstApp\bin\app_ signed_aligned.apk
Command description
F:\Workspace_Test\test\MyFirstApp\bin\app_signed.apk for signature apk file path
F:\WORKSPACE_TEST\TEST\MYFIRSTAPP\BIN\APP_SIGNED_ALIGNED.APK for the aligned signature apk file path
Document Address: Android command line create and package project
PS: This XXXX blog editor really do not, from word copied over, incredibly will be more space and less space, this does not matter, the problem is not much more, should not be less
Android command line to create and package projects