相关疑难解决方法(0)

Gradle中buildscript块的目的

我是Gradle的新手,我正在阅读文档,但我不了解它的某些部分.其中一个部分与buildscript块连接.它的目的是什么?

如果构建脚本需要使用外部库,则可以将它们添加到构建脚本本身的脚本类路径中.您可以使用buildscript()方法执行此操作,并传入一个声明构建脚本类路径的闭包.

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath group: 'commons-codec', name: 'commons-codec', version: '1.2'
  }
}
Run Code Online (Sandbox Code Playgroud)

好的但是有什么区别:

repositories {
  mavenCentral()
}
dependencies {
  compile group: 'commons-codec', name: 'commons-codec', version: '1.2'
}
Run Code Online (Sandbox Code Playgroud)

例如,为什么有必要使用buildscript

classpath gradle

219
推荐指数
5
解决办法
5万
查看次数

Android编译错误; 已经应用了Java插件,与android不兼容

所以我做了一个可穿戴的应用程序,我可以用屏幕上的按钮和MessageListenerService来控制机器人车.在尝试构建项目之后,我遇到了一些问题,它要求我从SDK中安装"Android Support Repository",我已经拥有了.我在SO(链接)上发现了另一个类似的问题, 它有一种解决方案,但现在它说

"错误:已经应用了java插件,但它与Android插件不兼容"

这是我的可穿戴模块中的build.gradle

apply plugin: 'com.android.application'
apply plugin: 'java'


sourceCompatibility = JavaVersion.VERSION_1_6   //these two lines
targetCompatibility = JavaVersion.VERSION_1_6   //are the only ones that matter

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }
signingConfigs {
    release {
        keyAlias 'C:\\Users\\Riekelt\\coolie.jks'
        keyPassword 'cut-out'
        storeFile file('path/to/release.keystore')
        storePassword 'cut-out'
    }
}

defaultConfig {
    applicationId "robowheel.robond"
    minSdkVersion 20
    targetSdkVersion 20
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig …
Run Code Online (Sandbox Code Playgroud)

java android gradle wear-os

31
推荐指数
2
解决办法
3万
查看次数

标签 统计

gradle ×2

android ×1

classpath ×1

java ×1

wear-os ×1