greensopinion / gradle-android-eclipse

A Gradle plug-in that enables generation of Eclipse project files (.project and .classpath) to enable use of the Eclipse IDE for Android projects.
Apache License 2.0
25 stars 12 forks source link

Plugin with id 'com.greensopinion.gradle-android-eclipse' not found. #21

Closed gorpong closed 4 years ago

gorpong commented 5 years ago

I followed the instructions but when I try to run the gradle eclipse command, I get the output that it can't find that plugin. I believe it should have found it with the Maven repository in the buildscript, but it doesn't seem to work and just bails out with that error.

I don't know gradle as a build system, I'm trying to build the FTC SkyStone android application using eclipse so I'm not entirely sure what to try next to get it to work.

Any assistance would be greatly appreciated.

greensopinion commented 4 years ago

Hi gorpong, if you want anyone to help with this you'll have more luck by posting the console output that shows the issue that you're having.

gorpong commented 4 years ago

Here's what shows up in the console file. I tried both android-eclipse:1.1 as per the instructions as well as 0.2.2 as per the build.gradle example file, neither of them work:

BUILD FAILED in 1s

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project '6210_Stryke_SkyStone'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find gradle.plugin.com.greensopinion.gradle-android-eclipse:android-eclipse:1.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/gradle/plugin/com/greensopinion/gradle-android-eclipse/android-eclipse/1.1/android-eclipse-1.1.pom
       - https://dl.google.com/dl/android/maven2/gradle/plugin/com/greensopinion/gradle-android-eclipse/android-eclipse/1.1/android-eclipse-1.1.jar
       - https://jcenter.bintray.com/gradle/plugin/com/greensopinion/gradle-android-eclipse/android-eclipse/1.1/android-eclipse-1.1.pom
       - https://jcenter.bintray.com/gradle/plugin/com/greensopinion/gradle-android-eclipse/android-eclipse/1.1/android-eclipse-1.1.jar
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
gorpong commented 4 years ago

I moved the Maven URL to a different place and now it finds the 0.2.2 version but there's a different error:

C:\>gradlew eclipse

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':eclipseClasspath'.
> Task with path 'generateDebugSources' not found in root project '6210_Stryke_SkyStone'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

The gradlew command is included with the FTC SDK that is a wrapper around an included JAR file that has the gradle stuff embedded with the sources.

Interestingly enough, the gradle within Eclipse generates a different error when I save the build.gradle file:

> Task :nothing UP-TO-DATE

FAILURE: Build failed with an exception.

* What went wrong:
Could not get unknown property 'android' for root project '6210_Stryke_SkyStone' of type org.gradle.api.Project.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
gorpong commented 4 years ago

Here are the various gradle-related files with the FTC SDK:

Top-level build.gradle:

/**
 * Top-level build file for ftc_app project.
 *
 * It is extraordinarily rare that you will ever need to edit this file.
 */

apply plugin: 'com.greensopinion.gradle-android-eclipse'
apply plugin: 'eclipse'
apply plugin: 'java'

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url "https://plugins.gradle.org/m2/"
        }    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "gradle.plugin.com.greensopinion.gradle-android-eclipse:android-eclipse:0.2.2"
    }
}

// This is now required because aapt2 has to be downloaded from the
// google() repository beginning with version 3.2 of the Android Gradle Plugin
allprojects {
    repositories {
        google()
        jcenter()

    }
}

eclipse {
    classpath {
        plusConfigurations += [ configurations.compile, configurations.testCompile ]
        downloadSources = true
    }
}

Top-level settings.gradle file:

include ':FtcRobotController'
include ':TeamCode'

Top-level build.common.gradle file:

/**
 * build.common.gradle
 *
 * Try to avoid editing this file, as it may be updated from time to time as the FTC SDK
 * evolves. Rather, if it is necessary to customize the build process, do those edits in
 * the build.gradle file in TeamCode.
 *
 * This file contains the necessary content of the 'build.gradle' files for robot controller
 * applications built using the FTC SDK. Each individual 'build.gradle' in those applications
 * can simply contain the one line:
 *
 *      apply from: '../build.common.gradle'
 *
 * which will pick up this file here. This approach allows makes it easier to integrate
 * updates to the FTC SDK into your code.
 */

import java.util.regex.Pattern

apply plugin: 'com.android.application'

android {

    compileSdkVersion 28

    signingConfigs {
        debug {
            keyAlias 'androiddebugkey'
            keyPassword 'android'
            storeFile rootProject.file('libs/ftc.debug.keystore')
            storePassword 'android'
        }
    }

    aaptOptions {
        noCompress "tflite"
    }

    defaultConfig {
        applicationId 'com.qualcomm.ftcrobotcontroller'
        minSdkVersion 19
        targetSdkVersion 26

        /**
         * We keep the versionCode and versionName of robot controller applications in sync with
         * the master information published in the AndroidManifest.xml file of the FtcRobotController
         * module. This helps avoid confusion that might arise from having multiple versions of
         * a robot controller app simultaneously installed on a robot controller device.
         *
         * We accomplish this with the help of a funky little Groovy script that maintains that
         * correspondence automatically.
         *
         * @see <a href="http://developer.android.com/tools/building/configuring-gradle.html">Configure Your Build</a>
         * @see <a href="http://developer.android.com/tools/publishing/versioning.html">Versioning Your App</a>
         */
        def manifestFile = project(':FtcRobotController').file('src/main/AndroidManifest.xml');
        def manifestText = manifestFile.getText()
        //
        def vCodePattern = Pattern.compile("versionCode=\"(\\d+(\\.\\d+)*)\"")
        def matcher = vCodePattern.matcher(manifestText)
        matcher.find()
        def vCode = Integer.parseInt(matcher.group(1))
        //
        def vNamePattern = Pattern.compile("versionName=\"(.*)\"")
        matcher = vNamePattern.matcher(manifestText);
        matcher.find()
        def vName = matcher.group(1)
        //
        versionCode vCode
        versionName vName
    }

    // Advanced user code might just want to use Vuforia directly, so we set up the libs as needed
    // http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html
    buildTypes {
        release {
            // Disable debugging for release versions so it can be uploaded to Google Play.
            //debuggable true
            ndk {
                abiFilters "armeabi-v7a"
            }
        }
        debug {
            debuggable true
            jniDebuggable true
            renderscriptDebuggable true
            ndk {
                abiFilters "armeabi-v7a"
            }
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    sourceSets.main {
        jni.srcDirs = []
        jniLibs.srcDir rootProject.file('libs')
    }
}

repositories {
    flatDir {
        dirs rootProject.file('libs')
    }
}
apply from: 'build.release.gradle'

FtcRobotController build.gradle file:

//
// build.gradle in FtcRobotController
//
apply plugin: 'com.android.library'

android {

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 26
    }

    compileSdkVersion 28

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

repositories {
    flatDir {
        dirs '../libs'
    }
}

apply from: 'build.release.gradle'

FtcRobotController build.release.gradle file:

dependencies {
    implementation (name:'Inspection-release', ext: 'aar')
    implementation (name:'Blocks-release', ext: 'aar')
    implementation (name:'RobotCore-release', ext: 'aar')
    implementation (name:'RobotServer-release', ext: 'aar')
    implementation (name:'OnBotJava-release', ext: 'aar')
    implementation (name:'Hardware-release', ext: 'aar')
    implementation (name:'FtcCommon-release', ext: 'aar')
    implementation (name:'WirelessP2p-release', ext:'aar')
    implementation 'com.android.support:support-compat:28.0.0'
}

TeamCode build.gradle file:

//
// build.gradle in TeamCode
//
// Most of the definitions for building your module reside in a common, shared
// file 'build.common.gradle'. Being factored in this way makes it easier to
// integrate updates to the FTC into your code. If you really need to customize
// the build definitions, you can place those customizations in this file, but
// please think carefully as to whether such customizations are really necessary
// before doing so.

// Custom definitions may go here

// Include common definitions from above.
apply from: '../build.common.gradle'

TeamCode build.release.gradle file:

dependencies {
    implementation project(':FtcRobotController')
    implementation (name: 'RobotCore-release', ext: 'aar')
    implementation (name: 'Hardware-release', ext: 'aar')
    implementation (name: 'FtcCommon-release', ext: 'aar')
    implementation (name: 'WirelessP2p-release', ext:'aar')
    implementation (name: 'tfod-release', ext:'aar')
    implementation (name: 'tensorflow-lite-0.0.0-nightly', ext:'aar')
}
gorpong commented 4 years ago

I'm running the gradlew eclipse from the primary root directory of the project, meaning the directory ABOVE the FtcRobotController and TeamCode directories.

I'm not actually trying to build the application, I'm a parent mentor for an FTC Robotics team and I'm trying to use Eclipse to look at their code to help them debug and troubleshoot. Really need things like "Open Declaration" and other things to work in order figure out what's going on and what their code's doing. While I can figure out things manually by keeping track of the sub-classing and such, having an IDE makes that so much easier, and that's really all I'm trying to do.

If there's a manual way to do this which will accomplish all of this without requiring your plugin, since the FTC SDK might be an edge case of what you're doing with your plugin, then I'd appreciate it if you could give me an idea of what I should do with the various .aar files that they include in the FTC SDK so that Eclipse can read them and use them.

Thanks!

greensopinion commented 4 years ago

I've not tried this plug-in with a build configuration like yours, however at first glance it looks like you want to add it to build.common.gradle instead of the top-level build.gradle. Version 1.1 of the plug-in is a better choice than 0.22.

Keep in mind that this plug-in is a bit outdated and may not work with builds using more modern versions of Android Studio. More details on that here: https://github.com/greensopinion/gradle-android-eclipse/wiki/2020-experiment

gorpong commented 4 years ago

I've not tried this plug-in with a build configuration like yours, however at first glance it looks like you want to add it to build.common.gradle instead of the top-level build.gradle. Version 1.1 of the plug-in is a better choice than 0.22.

I'll try moving it to the build.common.gradle and will take a look at your 2020-experiment, but it can't find version 1.1, which is why I went back to 0.2.2.

All I did was change the classpath bits in the dependencies to this:

classpath "gradle.plugin.com.greensopinion.gradle-android-eclipse:android-eclipse:1.1"

And it generates this error:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project '6210_Stryke_SkyStone'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find gradle.plugin.com.greensopinion.gradle-android-eclipse:android-eclipse:1.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/gradle/plugin/com/greensopinion/gradle-android-eclipse/android-eclipse/1.1/android-eclipse-1.1.pom
       - https://dl.google.com/dl/android/maven2/gradle/plugin/com/greensopinion/gradle-android-eclipse/android-eclipse/1.1/android-eclipse-1.1.jar
       - https://jcenter.bintray.com/gradle/plugin/com/greensopinion/gradle-android-eclipse/android-eclipse/1.1/android-eclipse-1.1.pom
       - https://jcenter.bintray.com/gradle/plugin/com/greensopinion/gradle-android-eclipse/android-eclipse/1.1/android-eclipse-1.1.jar
       - https://plugins.gradle.org/m2/gradle/plugin/com/greensopinion/gradle-android-eclipse/android-eclipse/1.1/android-eclipse-1.1.pom
       - https://plugins.gradle.org/m2/gradle/plugin/com/greensopinion/gradle-android-eclipse/android-eclipse/1.1/android-eclipse-1.1.jar
     Required by:
         project :

Thanks!

greensopinion commented 4 years ago

This is working for me. To test it out I created a new Android project, then modified the app/build.gradle as follows:

apply plugin: 'com.android.application'
apply plugin: 'com.greensopinion.gradle-android-eclipse'
apply plugin: 'eclipse'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.greensopinion.example.androideclipse"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "gradle.plugin.com.greensopinion.gradle-android-eclipse:gradle-android-eclipse:1.1"
    }
}

eclipse {
    classpath {
        plusConfigurations += [ configurations.compile, configurations.testCompile ]
        downloadSources = true
    }
}