Skip to main content

Creating Your First Android Project

Eclipse will save all projects into a workspace directory. By default it creates a workspace directory called workspace in your home directory, but you can choose the workspace under File > Switch Workspace. I use this capability to create a workspace androidWorkspace in my home directory for all android projects, for example. If necessary, use File > Switch Workspace to choose the workspace you wish to use for the project. In default mode Eclipse will remember the workspace from your last session and start off there. 

Create a New Project

To create a new Android Project in Eclipse:

  1. Select File > New > Project.

  2. Select Android > Android Project, and click Next (after you do this once you will have the future option of the shortcut File > New > Android Project).

  3. Specify the contents for the project:

    • Project Name: name of the subdirectory in the workspace directory where your project will be created. Example: MyApp. Then if your default Android Eclipse workspace is /home/guidry/androidWorkspace, the project will be created in the directory /home/guidry/androidWorkspace/MyApp.

    • Contents: select Create new project in workspace; select project workspace location.

    • Target: select a Build Target, which specifies which Android platform you'd like your application built against. You can change the build target for your project at any time.

    • Properties:

      • Application name: The name that will appear on the screen of the Android device labeling the app. Choice is optional and it can be blank.

      • Package name: namespace of the package. It must be a fully qualified package namespace (following the rules for packages in Java) where all the source code will reside, and must have at least two components. Example: com.lightcone.myapp (it is normal for this package name to be all lower case). Choose this carefully, since it determines organizational structure for the project and is not very easy to change later because it ends up being used in various places.
        Each application in the system must have a unique package name, which can be ensured by systematically naming packages using the same reversed domain prefix but different suffixes: com.lightcone.app1, com.lightcone.app2, ... This produces a directory structure in the workspace of the form com/lightcone/app1, com/lightcone/app2, ... For practice and development you can use a default like org.example (e.g., org.example.myapp), but for deployment of apps for use by others you should systematically name your packages with a reversed domain that is unique (ideally an IP address that you control, though that isn't essential).


      • Create Activity: (optional) name for your main Activity class. Example: MyApp. Because of Java name conventions, the main class in a file must have the same name as the file (a file can contain more than one class, though this can be confusing if overused): Example: if the main class is MyApp, the file containing it must be named MyApp.java. It is also convention to begin Java class names with capital letters, as in the just-cited example.

      • Min SDK Version: integer greater than or equal to zero that indicates the minimum API Level required to properly run your application. This can be blank. The number entered here automatically sets the minSdkVersion attribute in the <uses-sdk> of your AndroidManifest.xml file (and it can be changed later by editing that file). If you're unsure of the appropriate API Level to use, copy the API Level listed for the Build Target you selected in the Target tab (generally it must be less than or equal to that number).
        The minSdkVersion level is NOT the Android version number. Some Android platforms that we will use and the corresponding SDK number (in parentheses) include:


        • Android 1.5 (API level 3)

        • Android 1.6 (API level 4)

        • Android 2.1 (API level 7)

        • Android 2.2 (API level 8)


  4. Click Finish.




Comments

Popular posts from this blog

Fragment: App loads with white screen for 3 secs before showing proper UI

Issue: 1) When my application start then white/black screen appears, and then main UI is display.  2) Before my fragment load in activity black/white screen appears for 3/4 seconds and then fragment load. Solution: To fix this nasty problem, update the /res/values/styles.xml to include <item name="android:windowDisablePreview">true</item> or <item name="android:windowBackground">@android:color/black</item> for example : <!-- Application theme. -->  <style name="AppTheme" parent="AppBaseTheme">  <!-- All customizations that are NOT specific to a particular API-level can go here. -->  <item name="android:windowDisablePreview">true</item>  <!-- <item name="android:windowBackground">@android:color/black</item> -->  </style>

Android: The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

Solution Try the following any one solution and problem will go away: 1)  Apply following steps: Close the project and reopen it. Clean the project (It will rebuild the buildpath hence reconfiguring with the JDK libraries) OR Delete and Re-import the project and if necessary do the above steps again. 2)  Apply following steps: Go to properties of project with the build error (right click > Properties) View the "Libraries" tab in the "Build Path" section Find the "JRE System Library" in the list (if this is missing then this error message is not an eclipse bug but a mis-configured project) Remove the "JRE System Library" Hit "Add Library ...", Select "JRE System Library" and add the appropriate JRE for the project (eg. 'Workspace default JRE') Hit "Finish" in the library selection and "OK" in the project properties and then wait for the re-build of the project Hopefully th

Error: Retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23

My project is going on easily but suddenly what I found below bugs when developing an app. I know it's minor bug but it may be useful to anyone. Here is the error: Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'. Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'. Solution: This happens because after updates your android studio uses API 23 by default. 1) First check that your compile SDK version must match the support library's major version. If you are using version 23 of the support library, you need to compile against version 23 of the Android SDK. Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22.   2) Go to your project structure -> Properties -> and change Build tool version to