(首先简单介绍一下Android)

Android平台架构

android androidx配置 android项目配置_android

  • Linux Kernel(Linux内核层)
  • Librarles(核心类库层)

android androidx配置 android项目配置_android-studio_02

  • Android Runtime(一进程一虚拟)

android androidx配置 android项目配置_android androidx配置_03

  • Application Framework(应用开发层)
  • Application(应用层)

Android基本组件

  • 活动

android androidx配置 android项目配置_android-studio_04

  • 服务

android androidx配置 android项目配置_android androidx配置_05

  • 广播接收者

接收消息(消息列表接收的内容)

  • 内容提供者

android androidx配置 android项目配置_java_06

Android应用程序一般无程序入口

搭建Android开发环境

1.下载并安装SDK

android androidx配置 android项目配置_java_07

android androidx配置 android项目配置_java_08

完成下载并解压,然后再打开解压之后的android-sdk-windows文件,打开SDK Manager.exe并运行

勾选下面的内容并下载安装

android androidx配置 android项目配置_android-studio_09

下载完成后整体的目录结构如下

android androidx配置 android项目配置_android-studio_10

2.添加环境变量

打开环境变量设置,添加一个新的系统变量,选择之前解压之后的android-sdk-windows文件

android androidx配置 android项目配置_android studio_11

在Path路径下添加三个新的环境

%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\tools
%ANDROID_HOME%\build-tools\29.0.3

android androidx配置 android项目配置_android-studio_12

%ANDROID_HOME%\build-tools\ 后面的版本根据你自己下载的文件版本添加(案例是29.0.3)

android androidx配置 android项目配置_android_13

最后验证一下是否搭建成功,运行cmd 输入adb命令

android androidx配置 android项目配置_android_14

3.idea内创建项目

在任意一个项目里,File --> Other Settings --> Structure for New Projects

android androidx配置 android项目配置_android androidx配置_15

点击New,新添Android SDK,然后Apply – OK 即可

android androidx配置 android项目配置_android_16

关闭此项目;创建新项目

android androidx配置 android项目配置_android androidx配置_17

点击Android项目创建Empty Activity,点击next

android androidx配置 android项目配置_android studio_18

接下来选择存放路径,开发语言,选择完毕后Finish

android androidx配置 android项目配置_android_19

创建完成项目后,点击目录上方的Project选择Android(这样在之后的开发看的很方便一些);

然后设置右上方的app运行(idea里一直下一步即可,不需要其他设置);

android androidx配置 android项目配置_android studio_20

最后选择安卓设备查看运行效果,这里推荐第三方的运行软件(本案例用的是逍遥模拟器)

启动完逍遥模拟器,选择模拟器的设备即可

android androidx配置 android项目配置_java_21

运行效果:

android androidx配置 android项目配置_android-studio_22