gradle-androidannotations-plugin icon indicating copy to clipboard operation
gradle-androidannotations-plugin copied to clipboard

AndroidAnnotations plugin does't work with Android plugin.

Open jmodrako opened this issue 11 years ago • 1 comments

I use AndroidAnnotations in my Android project and I would like to move that project to new project layout to build it using Gradle. It can't be done because your plugin internally uses "java gradle plugin" which can't be use with "android gradle plugin".

Exception during building project:

Gradle: : com.android.build.gradle.internal.BadPluginException: The 'java' plugin has been applied, but it is not compatible with the Android plugins.

This exception is throw because Android plugin checks if java plugin already exist in build file:

// get current plugins and look for the default Java plugin.
if (project.plugins.hasPlugin(JavaPlugin.class)) { 
     throw new BadPluginException(
     "The 'java' plugin has been applied, but it is not compatible with the Android plugins.")
}

Here is my gradle build file:

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }

    def gradleAndroidAnnotationsPluginVersion = '0.3.0'

    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
        classpath "net.ealden.gradle.plugins:gradle-androidannotations-plugin:$gradleAndroidAnnotationsPluginVersion"
    }

}

// Android plugin can't work with java plugin, included below in your androidannotations //plugin. 
apply plugin: 'android'

// Here is where java plugin is applied.
apply plugin: 'androidannotations'

apply plugin: 'idea'

dependencies {
    compile files('libs/android-support-v4.jar')
    androidannotations 'com.googlecode.androidannotations:androidannotations:2.7'
    compile 'com.googlecode.androidannotations:androidannotations-api:2.7'
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }
}

So my question is, Is it possible to configure build file to work properly?

jmodrako avatar May 21 '13 06:05 jmodrako

I also reproduce this issue. Also, I tried to build this sample https://github.com/ealden/gradle-androidannotations-plugin-sample.

Result is:

Starting Build
Settings evaluated using empty settings script.
Projects loaded. Root project using build file '/home/main/Projects/thirdparty/gradle-androidannotations-plugin-sample/build.gradle'.
Included projects: [root project 'gradle-androidannotations-plugin-sample']
Evaluating root project 'gradle-androidannotations-plugin-sample' using build file '/home/main/Projects/thirdparty/gradle-androidannotations-plugin-sample/build.gradle'.
Compiling build file '/home/main/Projects/thirdparty/gradle-androidannotations-plugin-sample/build.gradle' using BuildScriptClasspathScriptTransformer.
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/org/gradle/api/plugins/gradle-android-plugin/1.2.0-SNAPSHOT/maven-metadata.xml]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/org/gradle/api/plugins/gradle-android-plugin/1.2.0-SNAPSHOT/gradle-android-plugin-1.2.0-SNAPSHOT.pom]
Resource missing. [HTTP HEAD: http://repo1.maven.org/maven2/org/gradle/api/plugins/gradle-android-plugin/1.2.0-SNAPSHOT/gradle-android-plugin-1.2.0-SNAPSHOT.jar]
Resource missing. [HTTP GET: https://oss.sonatype.org/content/groups/public/org/gradle/api/plugins/gradle-android-plugin/1.2.0-SNAPSHOT/maven-metadata.xml]
Resource missing. [HTTP GET: https://oss.sonatype.org/content/groups/public/org/gradle/api/plugins/gradle-android-plugin/1.2.0-SNAPSHOT/gradle-android-plugin-1.2.0-SNAPSHOT.pom]
Resource missing. [HTTP HEAD: https://oss.sonatype.org/content/groups/public/org/gradle/api/plugins/gradle-android-plugin/1.2.0-SNAPSHOT/gradle-android-plugin-1.2.0-SNAPSHOT.jar]

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'gradle-androidannotations-plugin-sample'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not find org.gradle.api.plugins:gradle-android-plugin:1.2.0-SNAPSHOT.
     Required by:
         :gradle-androidannotations-plugin-sample:unspecified > net.ealden.gradle.plugins:gradle-androidannotations-plugin:0.4.0.BUILD-SNAPSHOT

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Total time: 5.186 secs

So, there is no version 1.2.0-SNAPSHOT, but there is 1.2.0 instead.

ok3141 avatar May 24 '13 06:05 ok3141