Android 开发环境搭建,模拟器以及设备上运行

Tags: Android 

本篇目录

说明

第一个 Android 项目

学习资料:Build Your First Android App in Java

通过 Android Studio 的 File->New Project 创建一个 Basic Activity,选择 Java 或者 Kotlin 语言,选择最小的 sdk 版本。

项目目录

项目目录说明:源代码核心目录是 app/src/main,在 Android Studio 的左侧面板中看到目录树的根是 app/src/main。

➜  01-first-proj git:(main)ls app/src/main   
AndroidManifest.xml java                res

Android Studio目录结构

manifests/AndroidManifest.xml 是对 app 内各组件的描述,android runtime 读取该文件。

java 目录中是 app 的源代码。

res 目录中是 app 使用的资源文件,其中:

  • drawable 存放图片
  • layout 存放每个交互界面的 UI 布局
  • menu 存放 app 中的菜单
  • mipmap 存放 app 的图标
  • navigation 存放交互界面的切换顺讯
  • values 存放颜色、字符串等自定义资源

用模拟器运行

通过 Android Studio 的 Tools -> AVD Manager 安装本地安卓模拟器,然后就可以用运行按钮启动:

Android Studio运行本地安卓模拟器

用物理设备运行

进入 android 手机的开发者设置,打开 USB 调试,将手机脸上电脑上,在 Android Studio 中就可以看到增加的设备,选择并运行即可。

Android Studio设备上运行

应用架构

App component 加载顺序是不确定的,而且可能会被随时销毁,不能在 app component 中存放数据。

it’s possible for your app components to be launched individually and out-of-order, and the operating system or user can destroy them at any time. Because these events aren’t under your control, you shouldn’t store or keep in memory any application data or state in your app components, and your app components shouldn’t depend on each other.

参考

  1. 李佶澳的博客
  2. Android
  3. Android开发课
  4. Build Your First Android App in Java

推荐阅读

Copyright @2011-2019 All rights reserved. 转载请添加原文连接,合作请加微信lijiaocn或者发送邮件: [email protected],备注网站合作

友情链接:  李佶澳的博客  小鸟笔记  软件手册  编程手册  运营手册  网络课程  收藏文章  发现知识星球  百度搜索 谷歌搜索