【发布时间】:2018-11-24 02:38:11
【问题描述】:
我用的是安卓工作室。
我想运行一个任务,用于 java jar 文件编译,所以想在 gradle 中将“可执行文件”作为“java”执行,但它说
未找到 Gradle DSL 方法:'executable()' 可能的原因:
我的 build.gradle 模块是,
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task run (overwrite:true){
executable 'java'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我的应用的构建等级是
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.xxx.yyy.logcatdemo"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:recyclerview-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
build.finalizedBy("run")
【问题讨论】:
标签: android android-studio gradle build.gradle