先看官網說明
http://developer.android.com/intl/zh-TW/guide/developing/tools/aapt.html
aapt stands for Android Asset Packaging Tool and is included in the tools/ directory of the SDK. This tool allows you to view, create, and update Zip-compatible archives (zip, jar, apk). It can also compile resources into binary assets.
檔案位置 $ANDROID_HOME\platforms\$SDK\tools\
例如 D:\android-sdk-windows-1.5_r2\platforms\android-2.0\tools
搭配參數的實際用法
(1)list
aapt list HelloWorld.apk
可以看到HelloWorld.apk裡面所有的檔案,由此可知apk其實是個壓縮檔。如果用解壓縮軟體例如WinRAR或7-zip將apk解開,就會有下面這些檔案
res/layout/main.xml
AndroidManifest.xml
resources.arsc
res/drawable-hdpi/icon.png
res/drawable-ldpi/icon.png
res/drawable-mdpi/icon.png
classes.dex
META-INF/MANIFEST.MF
META-INF/CERT.SF
META-INF/CERT.RSA
(2)dump
aapt dump badging HelloWorld.apk
可以看到HelloWorld.apk裡package相關資料
package: name='com.gill.helloworld' versionCode='1' versionName='1.0'
application: label='HelloWorld' icon='res/drawable-mdpi/icon.png'
launchable activity name='com.gill.helloworld.Start'label='HelloWorld' icon=''
sdkVersion:'5'
main
supports-screens: 'small' 'normal' 'large'
locales: '--_--'
densities: '120' '160' '240'
我們來和AndroidManifest.xml比較一下內容,可發現相同之處
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gill.helloworld"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Start"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="5" />
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
</manifest>
請注意versionCode和versionName的差異。versionCode是整數,通常由1開始遞增到2、3、4…以此類推。versionName則是字串,例如一開始是1.1.1,下次為1.1.2。如有重大改版則為2.1.1…以此類推。
(3) dump permissions
aapt dump permissions HelloWorld.apk
可以看到HellowWorld.apk需要那些權限
package: com.gill.helloworld
uses-permission: android.permission.VIBRATE
uses-permission: android.permission.ACCESS_WIFI_STATE
uses-permission: android.permission.ACCESS_NETWORK_STATE
其它功能請參考網址 http://elinux.org/Android_aapt
http://developer.android.com/intl/zh-TW/guide/developing/tools/aapt.html
aapt stands for Android Asset Packaging Tool and is included in the tools/ directory of the SDK. This tool allows you to view, create, and update Zip-compatible archives (zip, jar, apk). It can also compile resources into binary assets.
檔案位置 $ANDROID_HOME\platforms\$SDK\tools\
例如 D:\android-sdk-windows-1.5_r2\platforms\android-2.0\tools
搭配參數的實際用法
(1)list
aapt list HelloWorld.apk
可以看到HelloWorld.apk裡面所有的檔案,由此可知apk其實是個壓縮檔。如果用解壓縮軟體例如WinRAR或7-zip將apk解開,就會有下面這些檔案
res/layout/main.xml
AndroidManifest.xml
resources.arsc
res/drawable-hdpi/icon.png
res/drawable-ldpi/icon.png
res/drawable-mdpi/icon.png
classes.dex
META-INF/MANIFEST.MF
META-INF/CERT.SF
META-INF/CERT.RSA
(2)dump
aapt dump badging HelloWorld.apk
可以看到HelloWorld.apk裡package相關資料
package: name='com.gill.helloworld' versionCode='1' versionName='1.0'
application: label='HelloWorld' icon='res/drawable-mdpi/icon.png'
launchable activity name='com.gill.helloworld.Start'label='HelloWorld' icon=''
sdkVersion:'5'
main
supports-screens: 'small' 'normal' 'large'
locales: '--_--'
densities: '120' '160' '240'
我們來和AndroidManifest.xml比較一下內容,可發現相同之處
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gill.helloworld"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Start"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="5" />
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
</manifest>
請注意versionCode和versionName的差異。versionCode是整數,通常由1開始遞增到2、3、4…以此類推。versionName則是字串,例如一開始是1.1.1,下次為1.1.2。如有重大改版則為2.1.1…以此類推。
(3) dump permissions
aapt dump permissions HelloWorld.apk
可以看到HellowWorld.apk需要那些權限
package: com.gill.helloworld
uses-permission: android.permission.VIBRATE
uses-permission: android.permission.ACCESS_WIFI_STATE
uses-permission: android.permission.ACCESS_NETWORK_STATE
其它功能請參考網址 http://elinux.org/Android_aapt
沒有留言:
張貼留言