我使用android studio。
我想运行一个任务,对于java jar文件编译,所以想要执行"可执行文件" as" java"在gradle但它说
找不到Gradle DSL方法:' executable()' 可能的原因:
我的build.gradle for module是,
// 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
}
我的应用程序构建gradle是
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")
答案 0 :(得分:1)
我找到了解决方案:
在任务中添加一个参数,
task run(type:JavaExec){
}
这清除了错误
答案 1 :(得分:0)