Android-Command line tools

 Android-Command line tools

1.mkdir Hello

2.cd Hello\

3.mkdir src\dom\domain

4.vim src\dom\domain\SayingHello.java

vim > 

 package dom.domain;
 import android.widget.TextView;

 public final class SayingHello extends android.app.Activity
 {
     public void onCreate( final android.os.Bundle activityState )
     {
         super.onCreate( activityState );
         final TextView textV = new TextView( SayingHello.this );
         textV.setText( "Hello world" );
         setContentView( textV );
     }
 }
vim > :wq 

5.vim AndroidManifest.xml

vim > 

<?xml version='1.0'?>
<manifest xmlns:a='http://schemas.android.com/apk/res/android'
  package='dom.domain' a:versionCode='0' a:versionName='0'>
     <application a:label='Saying hello'>
         <activity a:name='dom.domain.SayingHello'>
              <intent-filter>
                 <category a:name='android.intent.category.LAUNCHER'/>
                 <action a:name='android.intent.action.MAIN'/>
               </intent-filter>
          </activity>
      </application>
</manifest>
vim > :wq  

6.mkdir res

7.aapt  Parses, indexes, and compiles Android resources into a binary format that is optimized for the Android platform, and packages the compiled resources into a single output.

aapt package -f -I C:\ware\Android\sdk\platforms\android-27\android.jar -J src -m -M AndroidManifest.xml -S res -v

SDK Folder: C:\ware\Android\sdk\ 

8.javac -bootclasspath C:\ware\Android\sdk\platforms\android-27\android.jar -classpath src -source 1.7 -target 1.7 src\dom\domain\*.java


src\dom\domain\SayingHello.class

9.to dex 
 9.1 jill  .class  to .jayce

java -jar C:\ware\Android\sdk\build-tools\27.0.3\jill.jar --output classes.jayce src

 classes.jayce   

9.2 jack   .jayce to .dex  

java -jar C:\ware\Android\sdk\build-tools\27.0.3\jack.jar --import classes.jayce --output-dex .

 classes.dex  

10.create app.apkPart

aapt package -f -F app.apkPart -I C:\ware\Android\sdk\platforms\android-27\android.jar -M AndroidManifest.xml -S res -v

  app.apkPart 

11.  ApkBuilder   dex   apk  

java -classpath C:\ware\Android\sdk\tools\lib\sdklib-26.0.0-dev.jar com.android.sdklib.build.ApkBuilderMain app.apkUnalign -f classes.dex -u -z app.apkPart

app.apkUnalign 

12.  zipalign    Optimizes APK files 

zipalign -f -v 4 app.apkUnalign app_aligned.apk

 app_aligned.apk  

13.  debug   apk  

jarsigner -verbose -keystore "C:\Users\Kevin Wang\.android\debug.keystore" -signedjar app.apk app_aligned.apk androiddebugkey
  • 1

C:\Users\Kevin Wang  is the folder of your user address which is in %USERPROFILE%. Here is the security key library of Android debug.
Next, you will be asked to enter the password, the default password is android
After this step is completed, the app.apk file will be generated in the current directory.
This apk file is the final apk, which can be installed and run directly on the real machine, or installed and run using the Android emulator.

13.Start up Android Emulator

First check the existing Android emulator: 

emulator -avd -list-avds
start up Android Emulator
emulator -avd Pixel_2_API_28

Among them, Pixel_2_API_28 is the name of the simulator, just select one of the existing simulators listed in the previous step(emulator -avd Pixel_2_API_28).

14.Install apk

open new window of console, then to install apk

adb install app.apk
  • 1

15.Run app

adb shell am start -n dom.domain/.SayingHello
https://blog.csdn.net/AlpinistWang/article/details/105844012

评论

此博客中的热门博文

XML, XSL, HTML

Input in element.eleme.io

Data URI是由RFC 2397 ACE