热门课程

免费试听

上课方式

开班时间

当前位置: 首页 -   文章 -   新闻动态 -   正文

Android Studio创建一个安卓项目

知了堂姐
2024-07-09 11:12:24
0

Android Studio创建一个安卓项目

目前不管事项目还是产品,都是有各种的APP、小程序,这里就跟大家分享一个App项目的搭建吧。

前提条件:需要安装JDK,这里要注意,AS要求JDK7及更高版本,这里就不必多说。

在新建项目之前,可以看一下已经下载的SDK,如果是经常开发,我们可以把常用的sdk都下载好

点击图标打开sdk管理器


 

勾选右下角,可以查看具体下载的api版本

点击切换查看sdktools

新建项目时,根据自定义向导finish以后,开始构建项目,可能会构建失败,一般情况是因为墙的问题,我们配置一下镜像。 把项目选到project模式,然后选中下面那个build.gradle文件(app目录外面的,app里面是配置具体sdk版本等信息的地方)

打开文件后修改


// Top-level build file where you can add configuration options common to all
sub-projects/modules.buildscript {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/'
}
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
maven{ url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}allprojects {
repositories {
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google'
} maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
maven(){
url "https://dl.bintray.com/auteloss/android"其中的
版本号要和gradle/wrapper文件夹下gradle-wrapper.properties文件中gradle版本对应起来
版本对应图如下
}
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}}task clean(type: Delete) {
delete rootProject.buildDir}

其中的


dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

版本号要和gradle/wrapper文件夹下gradle-wrapper.properties文件中gradle版本对应起来

版本对应图如下

app内的build.gradle文件

apply plugin,声明是Android应用程序还是库模块

android 闭包,配置项目构建的各种属性,compileSdkVersion用于指定项目的编译SDK版本,buildToolsVersion用于指定项目构建工具的版本。此闭包还可包含以下闭包。

defaultConfig闭包:默认配置,应用程序包名,最小 sdk 版本,目标 sdk 版本,版本号,版本名buildTypes闭包:指定生成安装文件的配置,是否对代码进行混淆signingConfigs 闭包:签名信息配置sourceSets 闭包:源文件路径配置lintOptions 闭包:lint 配置

dependencies 闭包,指定当前项目的所有依赖关系,本地依赖,库依赖以及远程依赖

repositories闭包,仓库配置

以上信息都搞明白了后,就可以成功构建项目了呀,导入Android也是同样的道理,只要镜像配置好,每个地方配置的版本对应好就可以了。

总结

随着智能时代移动设备(如手机、平板电脑等)终端 的日益普及和发展的到来,将会有更多的PC机上才能实现的功能迁移到移动设备上已成为社会的发展趋势。 移动设备以其灵活、高效和便捷的特性就获得更多人的热爱,而如果将单位的业务结合手机的APP,就可以实现真正意义上的移动办公啦。

大家都在看

计算机专业大四学生,有必要报软件开发培训班吗?

2024-07-09 浏览次数:0

网络安全培训要学多久?要考哪些证书?

2024-07-09 浏览次数:0

谁适合学习软件测试?你适合学习软件测试吗?

2024-07-09 浏览次数:0

成都前端开发培训怎么样?成都前端开发培训这么选

2024-07-09 浏览次数:0

本科生参加5个月的Java培训能找到工作吗?

2024-07-09 浏览次数:0

网络安全能干到多大年龄?网络安全有中年危机吗?

2024-07-09 浏览次数:0
最新资讯
Android Studio创... 目前不管事项目还是产品,都是有各种的APP、小程序,这里就跟大家分享一个App项目的搭建吧。 ...
Android9.0正式版发布... 北京时间 8 月 7 日上午,Google 正式发布 Android 9.0 正式版系统,并宣布系统...