(首先简单介绍一下Android)
Android平台架构
- Linux Kernel(Linux内核层)
- Librarles(核心类库层)
- Android Runtime(一进程一虚拟)
- Application Framework(应用开发层)
- Application(应用层)
Android基本组件
- 活动
- 服务
- 广播接收者
接收消息(消息列表接收的内容)
- 内容提供者
Android应用程序一般无程序入口
搭建Android开发环境
1.下载并安装SDK
完成下载并解压,然后再打开解压之后的android-sdk-windows文件,打开SDK Manager.exe并运行
勾选下面的内容并下载安装
下载完成后整体的目录结构如下
2.添加环境变量
打开环境变量设置,添加一个新的系统变量,选择之前解压之后的android-sdk-windows文件
在Path路径下添加三个新的环境
%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\tools
%ANDROID_HOME%\build-tools\29.0.3
%ANDROID_HOME%\build-tools\ 后面的版本根据你自己下载的文件版本添加(案例是29.0.3)
最后验证一下是否搭建成功,运行cmd 输入adb命令
3.idea内创建项目
在任意一个项目里,File --> Other Settings --> Structure for New Projects
点击New,新添Android SDK,然后Apply – OK 即可
关闭此项目;创建新项目
点击Android项目创建Empty Activity,点击next
接下来选择存放路径,开发语言,选择完毕后Finish
创建完成项目后,点击目录上方的Project选择Android(这样在之后的开发看的很方便一些);
然后设置右上方的app运行(idea里一直下一步即可,不需要其他设置);
最后选择安卓设备查看运行效果,这里推荐第三方的运行软件(本案例用的是逍遥模拟器)
启动完逍遥模拟器,选择模拟器的设备即可
运行效果: