简体   繁体   English

如何检查我的项目中使用了哪个 Gradle Android 插件版本?

[英]How can I check which Gradle Android plugin version is used in my project?

In my build.gradle file I set the following dependency:在我的 build.gradle 文件中,我设置了以下依赖项:

dependencies {
    classpath 'com.android.tools.build:gradle:0.5.+'
} 

This will automatically adapt to the latest released version (like it's described here ).这将自动适应最新发布的版本(像它的描述在这里)。

How can I check which current release is used in my project?如何检查我的项目中使用的是哪个当前版本?

EDIT 2013-08-08:编辑 2013-08-08:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}

Showing the resolved dependencies for the build script class path isn't a built-in operation as for other configurations (which can be inspected with gradle dependencies ).显示构建脚本类路径的已解析依赖项不是其他配置的内置操作(可以使用gradle dependencies进行检查)。 However, you can write a task to do so.但是,您可以编写一个任务来执行此操作。 For example:例如:

task showClasspath  {
    doLast {
        buildscript.configurations.classpath.each { println it.name }
    }
}

A variation that just shows the Android plugin version:仅显示 Android 插件版本的变体:

task showVersion {
    doLast {
        println buildscript.configurations.classpath.resolvedConfiguration.firstLevelModuleDependencies.moduleVersion
    }
}

Newer versions of Gradle (3.0+, and possibly earlier) support a built-in buildEnvironment task that shows the dependency graph for buildscript.较新版本的 Gradle(3.0+,可能更早版本)支持内置buildEnvironment任务,该任务显示buildEnvironment的依赖关系图。

./gradlew buildEnvironment

https://docs.gradle.org/current/userguide/tutorial_gradle_command_line.html#sec:listing_buildscript_dependencies https://docs.gradle.org/current/userguide/tutorial_gradle_command_line.html#sec:listing_buildscript_dependencies

To determine what revision of the plugin you are using, check the version declaration in the project-level build.gradle file.要确定您使用的是哪个版本的插件,请检查项目级build.gradle文件中的版本声明。

Source 来源

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
}

In the above example, the Gradle Android plugin version/revision is 1.3.0在上面的例子中,Gradle Android 插件版本/修订版是 1.3.0

try the following code:试试下面的代码:

com.android.builder.Version.ANDROID_GRADLE_PLUGIN_VERSION

This is the easiest one I think.这是我认为最简单的一种。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应该在项目中使用哪个Android Gradle插件版本? - Which Android Gradle Plugin version should I use in my project? 如果Android项目不是基于Maven或Gradle的,我如何知道IntelliJ使用的是哪个版本的Android工具 - How can I tell which version of Android tools is used by IntelliJ if an Android project is not Maven or Gradle-based 我可以在gradle 2.14中使用哪个版本的android gradle插件? - Which version of android gradle plugin i can use with gradle 2.14? 如何从我自己的 Gradle 插件中确定正在使用的 Android Gradle 插件版本? - How can I determine the Android Gradle plugin version in use from within my own Gradle plugin? 如何确定目标SDK需要哪个Android Gradle插件版本? - How do I determine which Android Gradle Plugin version is needed for my target SDK? 如何跳过“此项目使用的是 android gradle 插件的版本 xxx,与此版本的 android studio 不兼容”对话框? - How to skip "This project is using version xxx of android gradle plugin, which is incompatible with this version of android studio" dialog? 您可以从命令行检查项目的 Android Gradle 插件版本吗? - Can you check Android Gradle Plugin version for project from command line? 如何获取 Android Gradle 插件正在使用的 R8 版本? - How to get version of R8 that is being used by the Android Gradle Plugin? Android Studio版本与使用的Gradle插件不兼容 - Version of Android Studio is incompatible with the Gradle Plugin used 如何使用0.14+版本的Android Gradle插件为我的APK文件添加版本号? - How do I add a version number to my APK files using 0.14+ versions of the Android Gradle plugin?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM