eclipse太难用了,幸好android支持ant来编译工程,纯手工打造,下面以hello-jni为例来试验一下。
-
sun@ubuntu:/tmp/project/hello-jni$ ls
-
AndroidManifest.xml default.properties jni res src tests
-
sun@ubuntu:/tmp/project/hello-jni$ android list target ;列出支持的target
Available Android targets:
----------
id: 1 or "android-11"
Name: Android 3.0
Type: Platform
API level: 11
Revision: 2
Skins: WXGA (default)
ABIs : armeabi
----------
id: 2 or "Google Inc.:Google APIs:11"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 3.0 (API level 11)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: WXGA (default)
ABIs : armeabi
-
sun@ubuntu:/tmp/project/hello-jni$ android update project -p . -t android-11
-
Updated and renamed default.properties to project.properties
-
Updated local.properties
-
No project name specified, using Activity name 'HelloJni'.
-
If you wish to change it, edit the first line of build.xml.
-
Added file ./build.xml
-
Added file ./proguard-project.txt
-
It seems that there are sub-projects. If you want to update them
-
please use the --subprojects parameter.
-
sun@ubuntu:/tmp/project/hello-jni$ ant debug
-
Buildfile: /tmp/project/hello-jni/build.xml
-
BUILD SUCCESSFUL
-
Total time: 4 seconds
1. 只需要两步就搞定了,不过这个是没有签名的。 说明:
a. android update project -p -t
-t 后的参数 可以用 android list target查看
执行后会生成build.xml
b. 用 ant debug -->编译工具自动签名debug key和使用zipalign优化打包
用 ant release -->需要自己签名和优化
2. 进行手动签名
-
sun@ubuntu:/tmp/project/hello-jni$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
-
Enter keystore password:
-
Re-enter new password:
-
What is your first and last name?
-
[Unknown]: name
-
What is the name of your organizational unit?
-
[Unknown]: unit
-
What is the name of your organization?
-
[Unknown]: org
-
What is the name of your City or Locality?
-
[Unknown]: ciyt
-
What is the name of your State or Province?
-
[Unknown]: state
-
What is the two-letter country code for this unit?
-
[Unknown]: 123
-
Is CN=name, OU=unit, O=org, L=ciyt, ST=state, C=123 correct?
-
[no]: yes
-
-
Generating 2,048 bit RSA key pair and self-signed certificate (SHA1withRSA) with a validity of 10,000 days
-
for: CN=name, OU=unit, O=org, L=ciyt, ST=state, C=123
-
Enter key password for
-
(RETURN if same as keystore password):
-
[Storing my-release-key.keystore]
-
sun@ubuntu:/tmp/project/hello-jni$ jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore my-release-key.keystore ./bin/HelloJni-release-unsigned.apk alias_name
Enter Passphrase for keystore:
adding: META-INF/MANIFEST.MF
adding: META-INF/ALIAS_NA.SF
adding: META-INF/ALIAS_NA.RSA
signing: AndroidManifest.xml
signing: resources.arsc
signing: classes.dex
sun@ubuntu:/tmp/project/hello-jni$ adb install ./bin/HelloJni-release-unsigned.apk
87 KB/s (4877 bytes in 0.054s)
pkg: /data/local/tmp/HelloJni-release-unsigned.apk
Success
3. 自动签名,这项技术我还没有掌握
[参]
阅读(9037) | 评论(0) | 转发(0) |