Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android compile error; Java plugin has been applied, not compatible with android

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

like image 596
Riekelt Avatar asked Nov 11 '14 08:11

Riekelt


2 Answers

For those that are using kotlin and are making an Android library: make sure to use apply plugin: 'kotlin-android' instead of apply plugin: 'kotlin'.

like image 169
Mavamaarten Avatar answered Sep 21 '22 19:09

Mavamaarten


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

like image 33
Nilzor Avatar answered Sep 23 '22 19:09

Nilzor