一、Android Projects Android Projects An Android project is the container for your application's source code, resource files, and files such as the Ant build and Android Manifest file. An application project is the main type of project and the contents are eventually built into an .apk file that you install on a device. Test Projects These projects contain code to test your application projects and are built into applications that run on a device.Library Projects These projects contain shareable Android source code and resources that you can reference in Android projects. This is useful when you have common code that you want to reuse. Library projects cannot be installed onto a device, however, they are pulled into the .apk file at build time. 二、项目结构 Platform Project = Android SDK Project + Library Projects(N) 其中:Android SDK Project的“AndroidManifest.xml”需整合各个Libary Project的“AndroidManifest.xml”,并在jar中添加各个Libary Project的“bin/**.jar”。 三、Eclipse 截图 四、ANT 脚本 build.xml [html] view plaincopy01. 02. Generating R.java / Manifest.java from the resources... 03. 04. 05. 06. 07. 08. 09. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 注意事项: a. 通过aapt创建所有library project的R.java均生成到Android Project的gen目录下,不会发生资源冲突; b. 通过-S添加所有项目(library projects+Android Project)的资源目录,这样每个项目对于的包路径下的R文件内容一样,并且也不需要拷贝所有库项目的资源文件到android项目的资源目录中了。 --(参考Eclipse的编译后效果) 五、资源文件 资源文件中,有个目录比较特殊(values),编译的时候会将该资源目录下的内容编译到class中,比如: [html] view plaincopy01. 02. 03. MyAppName 04. 如果不加处理的编译,会报异常: [exec] ../tfb_sdk/res/values/sdk_strings.xml:6: error: Resource at app_name appears in overlay but not in the base package; use to add. 有两种处理方法: 1. 讲各个项目中的values打头的资源目录下的xml文件均拷贝到当前编译的Android Project的对于目录下; 2. 在values对于的资源中使用重写。 第一种方法显然是我们不想操作的,资源可能冲突,也需要额外的工作,安全加上程序猿的惰性,只能选择第二种了,也有两种添加方法: [html] view plaincopy01. 02. 03. MyAppName 04. //这种写法会造成res里面的layout等资源无法调用,造成开发困扰,Eclipse错误提示如下: [2012-10-16 13:23:46 - ftb_main] F:\workfolder\ftb_sdk\res\layout\sdk_title_bar_layout.xml:8: error: Error:No resource found that matches the given name (at 'text' with value '@string/sdk_back'). [html] view plaincopy01. 02. 03. 04. MyAppName 05. //这种写法是正解,虽然稍微麻烦了点。 如果是color,调用方法需修改:TextView.setTextColor(R.color.gray)=> TextView.setTextColor(getResources().getColor(R.color.gray)) 最后再提一点:library project中调用资源的地方,如有switch(比如重载onClick())资源ID的,需改成if...else...;至此,整个平台项目就算搭建完成了。 好久不写技术文档了,写的有点零散, 附 Resource Types Each of the documents in this section describe the usage, format and syntax for a certain type of application resource that you can provide in your resources directory (res/). Here's a brief summary of each resource type: Animation Resources Define pre-determined animations. Tween animations are saved in res/anim/ and accessed from the R.anim class. Frame animations are saved in res/drawable/ and accessed from the R.drawable class. Color State List Resource Define a color resources that changes based on the View state. Saved in res/color/ and accessed from the R.color class. Drawable Resources Define various graphics with bitmaps or XML. Saved in res/drawable/ and accessed from the R.drawable class. Layout Resource Define the layout for your application UI. Saved in res/layout/ and accessed from the R.layout class. Menu Resource Define the contents of your application menus. Saved in res/menu/ and accessed from the R.menu class. String Resources Define strings, string arrays, and plurals (and include string formatting and styling). Saved in res/values/ and accessed from the R.string, R.array, and R.plurals classes. Style Resource Define the look and format for UI elements. Saved in res/values/ and accessed from the R.style class. More Resource Types Define values such as booleans, integers, dimensions, colors, and other arrays. Saved in res/values/ but each accessed from unique R sub-classes (such as R.bool, R.integer, R.dimen, etc.). More Resource Types defines more types of resources you can externalize, including: Bool XML resource that carries a boolean value. Color XML resource that carries a color value (a hexadecimal color). Dimension XML resource that carries a dimension value (with a unit of measure). ID XML resource that provides a unique identifier for application resources and components. Integer XML resource that carries an integer value. Integer Array XML resource that provides an array of integers. Typed Array XML resource that provides a TypedArray (which you can use for an array of drawables).

更多相关文章

  1. Android(安卓)Studio编译失败:java.util.concurrent.ExecutionExc
  2. Android的项目练习
  3. Android(安卓)静默安装apk
  4. xbmc for android 编译
  5. Android(安卓)错误信息集锦(持续更新)
  6. android弹钢琴的一个简单程序
  7. Android中各类.mk文件的编写
  8. android使用keystore打包错误解决方法
  9. android:xlargeScreens="false" Only for 2.3 above SDK

随机推荐

  1. PC安卓模拟器PANIC: Could not open:C:\
  2. Android 渗透测试学习手册 第三章 Androi
  3. Android音视频开发:录制视频 + 语音识别 +
  4. android Post Get(普通)
  5. android的touch事件详解
  6. android commend build.xml
  7. android 系统音乐播放器分析
  8. Xamarin android沉浸式状态栏
  9. Android学习06-----布局管理器
  10. 利用android的Debug调试分析源码