当前位置: 首页 > article >正文

Android Studio build.gradle获取项目绝对路径

通过这个字段

 ${project.rootProject.projectDir}";

如项目根build.gradle中:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        mavenCentral()
        // jcenter() // keeped as anchor, will be removed soon
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    ext {
	    // 定义全局变量,常用于版本管理
	    // 变量在子模块的build.gradle中直接以: $NAME 的形式调用
        RootProjectDir = "${project.rootProject.projectDir}".replace("\\", "/")
    }
}

apply from: NATIVE_DIR +"/build.gradle"

app的build.gradle中:

android {

    defaultConfig {
		...
    }
    ...
    println  "Root project2:   ${RootProjectDir}";
}

输出:
在这里插入图片描述


http://www.kler.cn/a/153744.html

相关文章:

  • LeetCode Hot100 287.寻找重复数
  • 剑指 Offer(第2版)题解(C++ Version)
  • Visual Studio Code之自动补全的设置
  • WPF不使用AllowsTransparency实现高性能透明背景异形窗体
  • MidJourney笔记(6)-Niji模式
  • 解决element ui tree组件不产生横向滚动条
  • JVM 类的加载
  • [Linux] 正则表达式及grep和awk
  • 微信小程序自定义tabBar简易实现
  • 二叉树的遍历及哈夫曼编码的代码思路及实现
  • Linux 系统是如何收发网络包的?(计算机网络)
  • 向量数据库,展望AGI时代
  • (二) Windows 下 Sublime Text 3 安装离线插件 Anaconda
  • 2312skia,13画布包入门
  • 自然语言处理 (NLP) 中的组合语义分析
  • MicroPython STM32F4 RTC功能使用介绍
  • 【数据结构】循环链表和双向链表
  • redis单线程为什么这么快
  • CentOS系统环境搭建(二十三)——运行Java服务
  • 带你用uniapp从零开发一个仿小米商场_10.开发一个占剩余窗口的滚动区域