Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2111845
  • 博文数量: 438
  • 博客积分: 3871
  • 博客等级: 中校
  • 技术积分: 6075
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-10 00:11
个人简介

邮箱: wangcong02345@163.com

文章分类

全部博文(438)

文章存档

2017年(15)

2016年(119)

2015年(91)

2014年(62)

2013年(56)

2012年(79)

2011年(16)

分类: Android平台

2012-12-05 14:36:54

eclipse太难用了,幸好android支持ant来编译工程,纯手工打造,下面以hello-jni为例来试验一下。
  1. sun@ubuntu:/tmp/project/hello-jni$ ls
  2. AndroidManifest.xml default.properties jni res src tests
  3. 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

  4. sun@ubuntu:/tmp/project/hello-jni$ android update project -p . -t android-11
  5. Updated and renamed default.properties to project.properties
  6. Updated local.properties
  7. No project name specified, using Activity name 'HelloJni'.
  8. If you wish to change it, edit the first line of build.xml.
  9. Added file ./build.xml
  10. Added file ./proguard-project.txt
  11. It seems that there are sub-projects. If you want to update them
  12. please use the --subprojects parameter.
  13. sun@ubuntu:/tmp/project/hello-jni$ ant debug
  14. Buildfile: /tmp/project/hello-jni/build.xml
  15. BUILD SUCCESSFUL
  16. 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. 进行手动签名
  1. sun@ubuntu:/tmp/project/hello-jni$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
  2. Enter keystore password:
  3. Re-enter new password:
  4. What is your first and last name?
  5.   [Unknown]: name
  6. What is the name of your organizational unit?
  7.   [Unknown]: unit
  8. What is the name of your organization?
  9.   [Unknown]: org
  10. What is the name of your City or Locality?
  11.   [Unknown]: ciyt
  12. What is the name of your State or Province?
  13.   [Unknown]: state
  14. What is the two-letter country code for this unit?
  15.   [Unknown]: 123
  16. Is CN=name, OU=unit, O=org, L=ciyt, ST=state, C=123 correct?
  17.   [no]: yes

  18. Generating 2,048 bit RSA key pair and self-signed certificate (SHA1withRSA) with a validity of 10,000 days
  19.     for: CN=name, OU=unit, O=org, L=ciyt, ST=state, C=123
  20. Enter key password for
  21.     (RETURN if same as keystore password):
  22. [Storing my-release-key.keystore]
  23. 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. 自动签名,这项技术我还没有掌握
[参]
阅读(8967) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~