Zum Inhalt springen

Android Training/Creating an Android Project: Unterschied zwischen den Versionen

keine Bearbeitungszusammenfassung
(Inhalt mit englischem Inhalt ersetzt)
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
<languages />
<translate>
An Android project contains all the files that comprise the source code for your Android app.
An Android project contains all the files that comprise the source code for your Android app.


Zeile 6: Zeile 8:


== Create a Project with Android Studio ==
== Create a Project with Android Studio ==
[[Datei:Adt-firstapp-setup.png|thumb|'''Figure 1.''' Configuring a new project in Android Studio.]]
</translate>
[[Datei:Adt-firstapp-setup.png|thumb|<translate>'''Figure 1.''' Configuring a new project in Android Studio.</translate>]]
<translate>
# In Android Studio, create a new project:
# In Android Studio, create a new project:
#* If you don't have a project opened, in the '''Welcome''' screen, click '''New Project'''.
#* If you don't have a project opened, in the '''Welcome''' screen, click '''New Project'''.
Zeile 22: Zeile 26:
#Click the '''Finish''' button to create the project.
#Click the '''Finish''' button to create the project.
Your Android project is now a basic "Hello World" app that contains some default files. Take a moment to review the most important of these:
Your Android project is now a basic "Hello World" app that contains some default files. Take a moment to review the most important of these:
 
</translate>
<code>app/src/main/res/layout/activity_my.xml</code>
<code>app/src/main/res/layout/activity_my.xml</code>
* This is the XML layout file for the activity you added when you created the project with Android Studio. Following the New Project workflow, Android Studio presents this file with both a text view and a preview of the screen UI. The file includes some default settings and a <code>TextView</code> element that displays the message, "Hello world!"
* <translate>This is the XML layout file for the activity you added when you created the project with Android Studio. Following the New Project workflow, Android Studio presents this file with both a text view and a preview of the screen UI. The file includes some default settings and a <code>TextView</code> element that displays the message, "Hello world!"</translate>
<code>app/src/main/java/com.mycompany.myfirstapp/MyActivity.java</code>
<code>app/src/main/java/com.mycompany.myfirstapp/MyActivity.java</code>
* A tab for this file appears in Android Studio when the New Project workflow finishes. When you select the file you see the class definition for the activity you created. When you build and run the app, the <code>Activity</code> class starts the activity and loads the layout file that says "Hello World!"
* <translate>A tab for this file appears in Android Studio when the New Project workflow finishes. When you select the file you see the class definition for the activity you created. When you build and run the app, the <code>Activity</code> class starts the activity and loads the layout file that says "Hello World!"</translate>
<code>app/src/main/AndroidManifest.xml</code>
<code>app/src/main/AndroidManifest.xml</code>
* The [http://developer.android.com/guide/topics/manifest/manifest-intro.html manifest file] describes the fundamental characteristics of the app and defines each of its components. You'll revisit this file as you follow these lessons and add more components to your app.
* <translate>The [http://developer.android.com/guide/topics/manifest/manifest-intro.html manifest file] describes the fundamental characteristics of the app and defines each of its components. You'll revisit this file as you follow these lessons and add more components to your app.</translate>
<code>app/build.gradle</code>
<code>app/build.gradle</code>
* Android Studio uses Gradle to compile and build your app. There is a <code>build.gradle</code> file for each module of your project, as well as a <code>build.gradle</code> file for the entire project. Usually, you're only interested in the<code>build.gradle</code> file for the module, in this case the <code>app</code> or application module. This is where your app's build dependencies are set, including the <code>defaultConfig</code> settings:
* <translate>Android Studio uses Gradle to compile and build your app. There is a <code>build.gradle</code> file for each module of your project, as well as a <code>build.gradle</code> file for the entire project. Usually, you're only interested in the<code>build.gradle</code> file for the module, in this case the <code>app</code> or application module. This is where your app's build dependencies are set, including the <code>defaultConfig</code> settings:
** <code>compiledSdkVersion</code> is the platform version against which you will compile your app. By default, this is set to the latest version of Android available in your SDK. (It should be Android 4.1 or greater; if you don't have such a version available, you must install one using the [[SDK Manager]].) You can still build your app to support older versions, but setting this to the latest version allows you to enable new features and optimize your app for a great user experience on the latest devices.
** <code>compiledSdkVersion</code> is the platform version against which you will compile your app. By default, this is set to the latest version of Android available in your SDK. (It should be Android 4.1 or greater; if you don't have such a version available, you must install one using the [[SDK Manager]].) You can still build your app to support older versions, but setting this to the latest version allows you to enable new features and optimize your app for a great user experience on the latest devices.
** <code>applicationId</code> is the fully qualified package name for your application that you specified during the New Project workflow.
** <code>applicationId</code> is the fully qualified package name for your application that you specified during the New Project workflow.
Zeile 37: Zeile 41:
* See [http://developer.android.com/sdk/installing/studio-build.html Building Your Project with Gradle] for more information about Gradle.
* See [http://developer.android.com/sdk/installing/studio-build.html Building Your Project with Gradle] for more information about Gradle.
Note also the <code>/res</code> subdirectories that contain the [http://developer.android.com/guide/topics/resources/overview.html resources] for your application:
Note also the <code>/res</code> subdirectories that contain the [http://developer.android.com/guide/topics/resources/overview.html resources] for your application:
 
</translate>
<code>drawable''<density>''/</code>
<code>drawable''<density>''/</code>
* Directories for drawable objects (such as bitmaps) that are designed for various densities, such as medium-density (mdpi) and high-density (hdpi) screens. Other drawable directories contain assets designed for other screen densities. Here you'll find the ic_launcher.png that appears when you run the default app.
* <translate>Directories for drawable objects (such as bitmaps) that are designed for various densities, such as medium-density (mdpi) and high-density (hdpi) screens. Other drawable directories contain assets designed for other screen densities. Here you'll find the ic_launcher.png that appears when you run the default app.</translate>
<code>layout/</code>
<code>layout/</code>
* Directory for files that define your app's user interface like activity_my.xml, discussed above, which describes a basic layout for the MyActivity class.
* <translate>Directory for files that define your app's user interface like activity_my.xml, discussed above, which describes a basic layout for the MyActivity class.</translate>
<code>menu/</code>
<code>menu/</code>
* Directory for files that define your app's menu items.
* <translate>Directory for files that define your app's menu items.</translate>
<code>values/</code>
<code>values/</code>
* Directory for other XML files that contain a collection of resources, such as string and color definitions. The strings.xml file defines the "Hello world!" string that displays when you run the default app.
* <translate>Directory for other XML files that contain a collection of resources, such as string and color definitions. The strings.xml file defines the "Hello world!" string that displays when you run the default app.
To run the app, continue to the [[Spezial:MyLanguage/Android Training/Running Your Application|next lesson]].
To run the app, continue to the [[Spezial:MyLanguage/Android Training/Running Your Application|next lesson]].


Zeile 51: Zeile 55:
If you're not using the Android Studio IDE, you can instead create your project using the SDK tools from a command line:
If you're not using the Android Studio IDE, you can instead create your project using the SDK tools from a command line:
# Change directories into the Android SDK’s <code>sdk/</code> path.
# Change directories into the Android SDK’s <code>sdk/</code> path.
# Execute: tools/android list targets This prints a list of the available Android platforms that you’ve downloaded for your SDK. Find the platform against which you want to compile your app. Make a note of the target ID. We recommend that you select the highest version possible. You can still build your app to support older versions, but setting the build target to the latest version allows you to optimize your app for the latest devices.  If you don't see any targets listed, you need to install some using the Android SDK Manager tool. See [http://developer.android.com/sdk/installing/adding-packages.html Adding SDK Packages].
# Execute: </translate>
# Execute: android create project --target <target-id> --name MyFirstApp \ --path <path-to-workspace>/MyFirstApp --activity MyActivity \ --package com.example.myfirstapp Replace <code><target-id></code> with an ID from the list of targets (from the previous step) and replace <code><path-to-workspace></code> with the location in which you want to save your Android projects.
:: <code>tools/android list targets</code>
:: <translate>This prints a list of the available Android platforms that you’ve downloaded for your SDK. Find the platform against which you want to compile your app. Make a note of the target ID. We recommend that you select the highest version possible. You can still build your app to support older versions, but setting the build target to the latest version allows you to optimize your app for the latest devices.  If you don't see any targets listed, you need to install some using the Android SDK Manager tool. See [http://developer.android.com/sdk/installing/adding-packages.html Adding SDK Packages].
# Execute:</translate>
:: <code>android create project --target <target-id> --name MyFirstApp \ --path <path-to-workspace>/MyFirstApp --activity MyActivity \ --package com.example.myfirstapp</code>
:: <translate>Replace <code><target-id></code> with an ID from the list of targets (from the previous step) and replace <code><path-to-workspace></code> with the location in which you want to save your Android projects.
'''Tip:''' Add the <code>platform-tools/</code> as well as the <code>tools/</code> directory to your <code>PATH</code> environment variable.
'''Tip:''' Add the <code>platform-tools/</code> as well as the <code>tools/</code> directory to your <code>PATH</code> environment variable.


Your Android project is now a basic "Hello World" app that contains some default files. To run the app, continue to the [[Spezial:MyLanguage/Android Training/Running Your Application|next lesson]].{{TNT|Android Training/Attribution}}
Your Android project is now a basic "Hello World" app that contains some default files. To run the app, continue to the [[Spezial:MyLanguage/Android Training/Running Your Application|next lesson]].
</translate>
 
{{TNT|Android Training/Attribution}}
[[Kategorie:Android Training]]
[[Kategorie:Android Training]]
11.008

Bearbeitungen

Cookies helfen uns bei der Bereitstellung von Android Wiki. Durch die Nutzung von Android Wiki erklärst du dich damit einverstanden, dass wir Cookies speichern.