前言:我知道我遇到许多有关该错误的问题,但我仍然不认为我的问题是重复的,因为似乎所有较早的问题都涉及使用Android Studio进行构建,而我正在尝试构建一个Android Windows上从命令行下载应用程序。
因此,我们开始:我刚刚在Windows 7系统上安装了最新的Android Studio,Android NDK和JDK 8。我用build.gradle
创建了一个最小的测试项目,如下所示:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
当我打开命令行并键入
gradle wrapper
时,出现以下错误:Build file 'D:\TestProject\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Minimum supported Gradle version is 3.3. Current version is 3.2. If using the gradle wrapper, try editing the distributionUrl in D:\TestProject\gradle\wrapper\gradle-wrapper.properties to gradle-3.3-all.zip
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.085 secs
我无法遵循错误消息中提出的建议,因为文件
D:\TestProject\gradle\wrapper\gradle-wrapper.properties
根本不存在。在AFAIU中,这些东西是包装器的一部分,应该由对gradle wrapper
的调用生成,因此提示我修改不存在的文件对我来说没有太大意义。更令人困惑的是,当我在Android Studio中打开Google提供的
HelloJNI
测试项目并转到File/Project Structure/Project
时,Gradle版本显示为3.3。但是,查看C:\Program Files\Android\Android Studio\gradle
内部表明我仅安装了3.2,而不是3.3,因为gradle-3.2
内部只有C:\Program Files\Android\Android Studio\gradle
目录。因此,这全都令人困惑,而且我对如何解决此问题没有任何想法。这就是任何帮助深表感谢的原因!
最佳答案
When I open a command line and type gradle wrapper I get the following error
实际上,这实际上意味着您安装了Gradle的独立本地副本。您尚未运行Gradle Wrapper,因为那将是
./gradlew
,而不是gradle
。因此,请访问the Gradle installation site并将Gradle的独立本地副本升级到3.3。
关于android - 在Windows上使用Gradle从命令行构建Android应用:版本太旧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43428624/