buildship icon indicating copy to clipboard operation
buildship copied to clipboard

Doesn't work with plugin com.android.application

Open bmaehr opened this issue 5 years ago • 8 comments

When using

apply plugin: 'com.android.application'

eclipse is not able to include dependencies or build the source code.

The app project was not set up as gradle project by the gradle project import. After fixing this manually still the buildpath is not correctly set up. If using plugin 'com.android.application' instead of 'java-library' the build path of the eclipse project looses all dependencies.

buildTypes and productFlavors are not supported.

bmaehr avatar Oct 04 '18 23:10 bmaehr

That's expected, the IDE for Android development is Android Studio, not Eclipse.

oehme avatar Oct 05 '18 08:10 oehme

Use this Gradle plugin: https://github.com/greensopinion/gradle-android-eclipse to generate Eclipse project classpath. It will help to resolve compile errors and auto imports.

Then you just import your project as Eclipse project, create new Run configuration as Gradle Project with your task (assembleDebug) and it builds android project without ADT, only with Gradle.

mortalis13 avatar Oct 09 '18 12:10 mortalis13

It might make sense to take another look.

donat avatar Jun 30 '22 08:06 donat

we can simply to reproduce this via Android Studio new project -> Basic Activity -> Language: Java and finish the wizard.

CsCherrYY avatar Jun 30 '22 08:06 CsCherrYY

I managed to add classpath entries by manually defining plusConfigurations:

afterEvaluate {
  eclipse {
    classpath {
      plusConfigurations = [configurations.debugUnitTestRuntimeClasspath]
    }
  }
}

Of course, this is not a recommendation, just a simple test.

donat avatar Jul 18 '22 15:07 donat

The gradle plugin @mortalis13 mentioned seems to be unmaintained and archived. Also, if would be great if android support works without any changes in build.gradle, so that people can easily use this in other editors like eclipse and vscode without having to change something in a shared app.

Looking forward to a solution for this! Happy to help if I can, though I'm not very familiar with any of these.

nisargjhaveri avatar Aug 02 '22 02:08 nisargjhaveri

@donat, I'm trying to see how stuff works. I tried adding this to my app/build.gradle and sync in vs code. Doesn't seem to help, the java files still errors that it is not on the classpath of the project. What am I missing?

apply plugin: 'eclipse'

afterEvaluate {
  eclipse {
    classpath {
      plusConfigurations = [configurations.debugUnitTestRuntimeClasspath]
    }
  }
}

nisargjhaveri avatar Aug 05 '22 05:08 nisargjhaveri

@nisargjhaveri I think the snippet above will help resolve classpath for you. Besides, there are serveal things to do to make android project work:

  1. add source set. Since android plugin will not adopt java plugin's structure hypothesis, you might have to add main source set manually, e.g.,
allprojects {
     plugins.withId('com.android.application', { _ ->
             sourceSets {
                 main {
                     java {
                         srcDir 'src/main/java'
                     }
                 }
             }
     })
 }
  1. it seems that you have to manully add android.jar in the project platfrom to your classpath.

Then it might work. Anyway, it would be great if we can have a built-in support in buildship so we can import andorid project successfully at least.

CsCherrYY avatar Aug 05 '22 05:08 CsCherrYY