Android project structure in Eclipse

來源:互聯網
上載者:User

Android projects are the projects that eventually get built into an .apk file that you install onto a device. They contain things such as application source code and resource files. Some are generated for you by default, while others should be created if required. The following directories and files comprise an Android project:

src/
Contains your stub Activity file, which is stored at  src/your/package/namespace/ActivityName.java. All other source code files (such as  .java or  .aidl files) go here as well.
bin
Output directory of the build. This is where you can find the final  .apk file and other compiled resources.
jni
Contains native code sources developed using the Android NDK. For more information, see the Android NDK documentation.
gen/
Contains the Java files generated by ADT, such as your  R.java file and interfaces created from AIDL files.
assets/
This is empty. You can use it to store raw asset files. Files that you save here are compiled into an  .apk file as-is, and the original filename is preserved. You can navigate this directory in the same way as a typical file system using URIs and read files as a stream of bytes using the the  AssetManager. For example, this is a good location for textures and game data.
res/
Contains application resources, such as drawable files, layout files, and string values. See Application Resourcesfor more information.
anim/
For XML files that are compiled into animation objects. See the Animation resource type.
color/
For XML files that describe colors. See the Color Values resource type.
drawable/
For bitmap files (PNG, JPEG, or GIF), 9-Patch image files, and XML files that describe Drawable shapes or a Drawable objects that contain multiple states (normal, pressed, or focused). See the Drawable resource type.
layout/
XML files that are compiled into screen layouts (or part of a screen). See the Layout resource type.
menu/
For XML files that define application menus. See the Menus resource type.
raw/
For arbitrary raw asset files. Saving asset files here instead of in the  assets/ directory only differs in the way that you access them. These files are processed by aapt and must be referenced from the application using a resource identifier in the  R class. For example, this is a good place for media, such as MP3 or Ogg files.
values/
For XML files that are compiled into many kinds of resource. Unlike other resources in the  res/ directory, resources written to XML files in this folder are not referenced by the file name. Instead, the XML element type controls how the resources is defined within them are placed into the  R class.
xml/
For miscellaneous XML files that configure application components. For example, an XML file that defines a PreferenceScreenAppWidgetProviderInfo, or Searchability Metadata. See Application Resources for more information about configuring these application components.
libs/
Contains private libraries.
AndroidManifest.xml
The control file that describes the nature of the application and each of its components. For instance, it describes: certain qualities about the activities, services, intent receivers, and content providers; what permissions are requested; what external libraries are needed; what device features are required, what API Levels are supported or required; and others. See the AndroidManifest.xml documentation for more information
The manifest file describes the fundamental characteristics of the app and defines each of its components. You'll learn about various declarations in this file as you read more training classes.

One of the most important elements your manifest should include is the <uses-sdk> element. This declares your app's compatibility with different Android versions using the android:minSdkVersionand android:targetSdkVersion attributes. For your first app, it should look like this:

<manifestxmlns:android="http://schemas.android.com/apk/res/android" ... ><uses-sdkandroid:minSdkVersion="8"android:targetSdkVersion="17"/>    ...</manifest>

You should always set the android:targetSdkVersion as high as possible and test your app on the corresponding platform version. For more information, read Supporting Different Platform Versions.

project.properties
This file contains project settings, such as the build target. This file is integral to the project, so maintain it in a source revision control system. To edit project properties in Eclipse, right-click the project folder and select Properties.
local.properties
Customizable computer-specific properties for the build system. If you use Ant to build the project, this contains the path to the SDK installation. Because the content of the file is specific to the local installation of the SDK, the local.properties should not be maintained in a source revision control system. If you use Eclipse, this file is not used.
ant.properties
Customizable properties for the build system. You can edit this file to override default build settings used by Ant and also provide the location of your keystore and key alias so that the build tools can sign your application when building in release mode. This file is integral to the project, so maintain it in a source revision control system. If you use Eclipse, this file is not used.
build.xml
The Ant build file for your project. This is only applicable for projects that you build with Ant.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.