AndroidStudio项目结构目录

Android

在这里插入图片描述

app

Manifests

APP配置信息目录

java

主要为源代码和测试代码目录

res

主要是资源目录,存储所有的项目资源

drawable

存放各种位图文件(.png,.jpg,.9png,.gif等)和drawable类型的XML文件

layout

存放布局文件

mipmap

存放图片资源

values
colors

定义颜色资源

string

定义字符串资源

themes

定义主题资源

Geadle Scripts

gradle编译相关的脚本

build.gradle(project:xxx)

app模块的gradle编译文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.5.0"
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

项目构建时,会先找到该文件执行构建,里面的配置对整个工程全局有效,我们可以在这里做些全局性的配置

repositories:声明仓库的源

dependencies:声明项目所需的依赖

classpath “com.android.tools.build:gradle:4.2.1”
声明了android gradle plugin的版本。

那么buildscript中的repositories和allprojects的repositories的作用和区别是什么呢?
答:
1、 buildscript里是gradle脚本执行所需依赖,分别是对应的maven库和插件
2、 allprojects里是项目本身需要的依赖,比如我现在要依赖我自己maven库的toastutils库,那么我应该将maven {url ‘https://dl.bintray.com/calvinning/maven’}写在这里,而不是buildscript中,不然找不到。

buildScript块的repositories主要是为了Gradle脚本自身的执行,获取脚本依赖插件。我在写的一篇博客《尝试Artifactory》中Gradle脚本需要com.jfrog.artifactory插件才能执行成功,而这个插件是从URL为https://plugins.gradle.org/m2/的Maven仓库获得。

根级别的repositories主要是为了当前项目提供所需依赖包,比如log4j、spring-core等依赖包可从mavenCentral仓库获得。

allprojects块的repositories用于多项目构建,为所有项目提供共同所需依赖包。而子项目可以配置自己的repositories以获取自己独需的依赖包。

build.gradle(module:xxx)

构建具体到每一个module时,会执行该文件,里面的配置仅对当前module生效

gradle.properties(Global Properties)

gradle相关的全局属性设置

gradle-wrapper.properties(Gradle Version)

声明了gradle的目录与下载路径以及当前项目使用的gradle版本

proguard-rules.pro(ProGuard Rules for xxx)

app模块的代码混淆配置文件

gradle.properties(Project Properties)

settings.gradle(Project Settings)

设置相关的gradle脚本

local.properties(SDK Location)

配置SDK/NDK所在的路径

出处

buildscript和allprojects的作用和区别是什么?
Android Studio 工程目录结构精炼详解
[Gradle] buildScript块与allprojects块及根级别的repositories区别

todo

https://www.jianshu.com/p/a8f034a03318/
https://blog.csdn.net/weixin_41101173/article/details/80148758

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值