Creating an Android Project

An Android project contains all the files that comprise the source code for your Android app. The Android SDK tools make it easy to start a new Android project with a set of default project directories and files.

This lesson shows how to create a new project either using Eclipse (with the ADT plugin) or using the SDK tools from a command line.

Note: You should already have the Android SDK installed, and if you're using Eclipse, you should also have the ADT plugin installed (version 20.0.0 or higher). If you don't have these, follow the guide to Installing the Android SDK before you start this lesson.

Create a Project with Eclipse

  1. In Eclipse, click New Android App Project in the toolbar. (If you don’t see this button, then you have not installed the ADT plugin—see Installing the Eclipse Plugin.)


  2. Fill in the form that appears:
    • Application Name is the app name that appears to users. For this project, use "My First App."

    • Project Name is the name of your project directory and the name visible in Eclipse.
    • Package Name is the package namespace for your app (following the same rules as packages in the Java programming language). Your package name must be unique across all packages installed on the Android system. For this reason, it's generally best if you use a name that begins with the reverse domain name of your organization or publisher entity. For this project, you can use something like "com.example.myfirstapp." However, you cannot publish your app on Google Play using the "com.example" namespace.
    • Build SDK 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 the build target to the latest version allows you to enable new features and optimize your app for a great user experience on the latest devices.
    • Minimum Required SDK is the lowest version of Android that your app supports. To support as many devices as possible, you should set this to the lowest version available that allows your app to provide its core feature set. If any feature of your app is possible only on newer versions of Android and it's not critical to the app's core feature set, you can enable the feature only when running on the versions that support it.

      Leave this set to the default value for this project.

    Click Next.

  3. The following screen provides tools to help you create a launcher icon for your app.

    You can customize an icon in several ways and the tool generates an icon for all screen densities. Before you publish your app, you should be sure your icon meets the specifications defined in the Iconography design guide.

    Click Next.

  4. Now you can select an activity template from which to begin building your app.

    For this project, select BlankActivity and click Next.

  5. Leave all the details for the activity in their default state and click Finish.

Your Android project is now set up with some default files and you’re ready to begin building the app. Continue to the next lesson.

Create a Project with Command Line Tools

If you're not using the Eclipse IDE with the ADT plugin, you can instead create your project using the SDK tools from a command line:

  1. Change directories into the Android SDK’s tools/ path.
  2. Execute:
    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 Adding Platforms and Packages.

  3. Execute:
    android create project --target <target-id> --name MyFirstApp \
    --path <path-to-workspace>/MyFirstApp --activity MainActivity \
    --package com.example.myfirstapp
    

    Replace <target-id> with an id from the list of targets (from the previous step) and replace <path-to-workspace> with the location in which you want to save your Android projects.

Your Android project is now set up with several default configurations and you’re ready to begin building the app. Continue to the next lesson.

Tip: Add the platform-tools/ as well as the tools/ directory to your PATH environment variable.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这个警告是在使用NumPy创建多维数组时出现的。其中,输入的嵌套序列(nested sequences)的形状可能不一致,因此会被称为“ragged”,即不整齐的序列。 在 NumPy 中,数组是由相同大小的元素组成的,因此当创建一个由 ragged sequences 组成的数组时,NumPy 需要将其转换为一个整齐的数组。这个转换过程可能会导致数据的丢失或不准确。 因此,这个警告提示你可能需要检查你的输入数据是否正确,或者尝试使用其他方法来创建数组,以避免数据的不准确或丢失。 ### 回答2: “visibledeprecationwarning: creating an ndarray from ragged nested sequences”是一种警告提示信息,通常出现在使用NumPy库中的ndarray对象时。它的意思是在将嵌套序列转换为ndarray时,会出现不均匀的嵌套序列,即长度不相等的嵌套列表或元组等。 这个警告意味着代码中存在潜在的问题,因为嵌套序列的长度不相等,可能会导致错误或崩溃。 虽然ndarray对象可以处理大小相等的嵌套序列,但是在尝试转换不均匀嵌套序列时会发出弃用警告,以提醒开发者尽快进行代码修复。 因此,如果实现代码正确而且没有错误发生,不建议忽略这个警告。开发者可以通过修改嵌套序列的长度来解决此问题。在一些情况下,可以使用pad_sequences方法来将长度不均匀的序列对齐。有时也可以通过动态调整嵌套序列的长度来避免警告。 总而言之,在使用ndarray对象时,如果出现“visibledeprecationwarning: creating an ndarray from ragged nested sequences”这个警告,开发者需要仔细查看代码并调整数据形式以确保实现代码的正确性。 ### 回答3: 在Python编程中,当我们创建一个数组(ndarray)的时候,可能会在输出中看到一个警告信息:“visibledeprecationwarning: creating an ndarray from ragged nested sequences”,这是什么意思呢? 首先,我们需要了解什么是ndarray。ndarray是NumPy库中的数据类型,它是一个多维数组对象,每个元素都是相同类型的数据。ndarray在科学计算中非常常用,因为它能够高效地处理大规模数据,同时提供了许多数学函数和操作。 当我们创建一个ndarray的时候,我们通常会使用一个列表(list)或者其他序列作为输入参数,例如: import numpy as np a = np.array([1, 2, 3]) 这样就创建了一个包含1、2、3三个元素的一维数组。但是,警告信息中多出了“ragged nested sequences”这个词,它是什么意思呢? ragged nested sequences是指嵌套列表或者元组中的不规则数据结构。例如: import numpy as np b = np.array([[1, 2], [3, 4, 5]]) 这里创建了一个二维数组,第一行有两个元素,第二行有三个元素。这就是一个不规则的嵌套列表,被称为ragged nested sequences。 在早期的NumPy版本中,ndarray可以从ragged nested sequences中创建,但是这种方式很容易出错,而且效率不高。因此,在较新的版本中,这种创建方式已被弃用(deprecated),同时也给出了一个警告信息。 因此,当我们看到这个警告信息的时候,应该尽量避免使用ragged nested sequences,而是使用规则的列表或者其他序列来创建ndarray。这样可以避免不必要的错误,并且提高代码的效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值