Android编译错误; Java插件已被应用,与android不兼容 [英] Android compile error; Java plugin has been applied, not compatible with android

查看:4382
本文介绍了Android编译错误; Java插件已被应用,与android不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我制作了一个可穿戴应用程序,可以使用MessageListenerService在屏幕上控制带有按钮的机器人汽车。在尝试构建项目后,我遇到了一些问题,它要求我从SDK中安装Android支持库,而我已经拥有它。我在SO(链接)上发现了另一个类似问题它有一个解决方案,但现在它说


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


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

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


sourceCompatibility = JavaVersion.VERSION_1_6 //这两行
targetCompatibility = JavaVersion.VERSION_1_6 //是唯一重要的

android {
compileSdkVersion 20
buildToolsVersion20.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文件('path / to / release.keystore')
storePassword'cut -out'
}
}

defaultConfig {
applicationIdrobowheel.robond
minSdkVersion 20
targetSdkVersion 20
versionCode 1
versionName1.0
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard -rules.pro'
signingconfig signingConfigs.release

}
}
}

依赖项{
编译fileTree(dir :'libs',包括:['* .jar'])
编译'com.google.android.support:wearable:+'
compilecom.android.support:support-v4:20.0 。+
compile'c​​om.google.android.gms:play-services-wearable:+'
// compile'c​​om.google.android.gms:play-services-wearable:6.1.11 '

}

任何人都知道这是怎么回事?感谢advancoi

解决方案

问题是您不能同时应用 com.android.application

code>和同一模块中的 java 插件。你为什么这样做?



删除包含 apply plugin:'java',你很好去

So I've made a wearable application where I can control a robot-car with the buttons on screen with the MessageListenerService. After trying to build the project, I had some problems where it asked me to install "Android Support Repository" from the SDK, which I already had. I found another similar problem on SO (link) which had a sort-of solution, but now it says

"Error: The java Plugin has been applied, but it is not compatible with the Android Plugins"

This is my build.gradle in my wearable module

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 signingConfigs.release

    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:+'
compile "com.android.support:support-v4:20.0.+"
compile 'com.google.android.gms:play-services-wearable:+'
 //   compile 'com.google.android.gms:play-services-wearable:6.1.11'

}

Anyone know what is the matter? Thanks in advancoi

解决方案

The problem is that you cannot apply both the com.android.application and the java plugin in the same module. Why are you doing that? There's nothing in the question you reference that tell you to apply the java plugin.

Remove the line with apply plugin: 'java', and you're good to go

这篇关于Android编译错误; Java插件已被应用,与android不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆