Eclipse and gradle android-library projects - android

I have a main Android project which references 4 other Android-Library projects in gradle. It compiles just fine and i can deploy it via gradle commandline, however I would like to debug my code using eclipse.
Whenever I load up the projects in Eclipse using the gradle integration plugin for Eclipse, eclipse won't even recognize them as library projects and instead treats them like normal android applications. Is this behavior normal or is something wrong with my gradle build script or does eclipse simply not support such a setup yet? Running/debugging the main application in eclipse just installs the individual libraries as regular applications which results in my main application not being able to find the specified classes.
My gradle build script is basically a c&p from Mike Gouline's sample project https://github.com/mgouline/android-samples with "apply: android" replaced with "apply: android-library" for my library projects.

Eclipse doesn't properly support Android Gradle projects. The Android plugin has a lot of specialized support for android-library modules that Eclipse's Gradle integration doesn't know about. For the time being, if you want full IDE support for Android/Gradle, Android Studio or IntelliJ with the Android plugin are your only choices.
We know the situation for people who are using the Gradle build system and want to use Eclipse isn't great; it's something we're thinking about, but we don't have anything definite on the roadmap yet.

Related

Import maven project from Eclipse to Android Studio

I have a very complex maven project in Eclipse with many modules and submodules and a lot of dependencies to each other and to third party files in pom.xml files. It works well in net browsers. But how can I try it in PC within an Android phone emulator? I have found this Android Studio program, but how can I import my very complex maven project from Eclipse without adding extra file(s) to it (like AndroidManifest.xml,etc) and not to destroy the original structure of the project?Anyway, I could use the File/Open option from menu and I can see the project in AS, but I can't run it. What should I do to run?
If you are trying to migrate an Android application from Eclipse IDE to Android Studio, then the hard truth is there is no easy way. I know because I already did this and it was worth the move.
And if you decide to take the hard route you will need to fully understand the directory structure of your Eclipse project compared to the directory structure of Android Studio projects and how the two IDEs build and deploy the project - because they are totally different and Android Studio uses gradle for its build.
Try reading through the Android Studio Guide and the Migrate to Android Studio from Eclipse.

Is Gradle required for an Android app to run in Android studio?

I have an android project that I can import to android studio. It opens but refuses to run. The file contains 4 folders (.idea, gen, java, res) and 2 files (AndroidManifest.xml and project.apk). I can't seem to run the app. When I import it, Android studio tells me "This project does not use the Gradle and migrate project to gradle.
Yes, Gradle is required for apps developed in or migrated to Android studio.
Android Studio’s build system is based on Gradle and uses build
configuration files written in Groovy syntax for ease of extensibility
and customization.
Since the whole build system is based on Gradle, you're stuck using it! Not a bad thing, Gradle is pretty great.
I have migrated quite a few projects to Android studio, for the most part it has been quick and painless.
There's a nice guide to help you migrate to Android Studio over at the Android development site: https://developer.android.com/studio/intro/migrate.html

How can I tell which IDE an Android project was made with?

For example this project. I see it has Gradle files, but a quick search says Eclipse has a Gradle plugin as well.
https://github.com/sephiroth74/HorizontalVariableListView
The Android build system is built on top of gradle:
https://developer.android.com/tools/building/plugin-for-gradle.html
So that means that just plain gradle is not enough to build an Android project.
As ADT never used gradle and Google has ended Eclipse support, you can be reasonably confident that an Android gradle project was made using Android Studio.
Gradle is a building tool. It has plugins for Eclipse, IntelliJ, Android Studio and Netbeans. So you won't be able to tell which IDE an Android project is made with from just a gradle file. Some project structures vary, for Eclipse projects and IntelliJ ones, you can find easily differences between them if you are familiar with both. But some are not explicitly, for IntelliJ projects and Android Studio ones.
BTW, do IDEs matter? The App you are building does, I am afraid.
Android Studio, which is developed based on IntelliJ. It uses gradle to build the project.
If a project contains .classpath or .project, it should be made by Eclipse. Or it should be made by android studio. A project made by android studio can not be imported into eclipse.

Building Android app with Jenkins & Gradle

I'm a devops engineer, and my company is building their first Android app. For all of our other projects, we've used Jenkins to handle builds.
I've read quite a few tutorials on getting android building on Jenkins and they all seem to rely on Gradle. I'd like to get out in front of the devs a bit and start the job. Is it possible that the app that they build doesn't support Gradle? What scenarios are those, so I can influence decisions?
Maybe Gradle isn't the latest thing, if not, what is?
Is it possible that the app that they build doesn't support Gradle?
It is possible that they are not currently building the app with Gradle, but highly unlikely that the app could not be built with Gradle.
What scenarios are those, so I can influence decisions?
The most likely scenario where they are not building with Gradle, is that they use the Eclipse IDE to develop the app. Eclipse projects have historically been built more often with Ant or Maven. But an Eclipse project can be built with Gradle. That said, configuring an Android project to be built with Gradle is not a requirement to build that project with Jenkins. Ant, Maven, and other build tools play nice with Jenkins also. So, if your dev team is using a build tool other than Gradle, that shouldn't be a blocker for you. You should be able to accommodate them, if that's going to cause less friction.
Maybe Gradle isn't the latest thing, if not, what is?
I'm not sure about latest, but Gradle does currently have a lot of momentum as the build tool of choice for Android projects because it is the default build tool for Android Studio (which is positioned to replace Eclipse as the default Android IDE).
So, my advice would be to ask your dev team what IDE and build tool they are currently using, and go from there... (if they use Eclipse and you want to build with Gradle: Is it possible to use the Gradle build system for Android with Eclipse?)
Source: At the company I work for, I develop two Android apps and make daily builds with Jenkins. A few months ago I switched from Eclipse (Ant) to Android Studio (Gradle).
I hope this was helpful. I have not answered many questions on here so I'm not entirely sure I'm doing it right. :)

Migration from Eclipse to Android Studio

So,
as it seems that more and more people are using Android Studio i got curious and wanted to take a peek at it.
I have used Eclipse up until now and wanted to migrate a project to Android Studio. So i exported a gradle buildfile from within Eclipse, as android.developer.com suggested.
That worked fine, now i wanted to import that into Android Studio 0.3.2
When trying to import i got that Unable to import Eclipse project to Android Studio error. Now it is building.
But it got a new suprise, now before it is finished building, its asking specifically for an older Version of Gradle(1.6)... Ok, i can do that. Which leads me right back to the first error. So i tried this - Gradle version 1.6 is required. Current version is 1.8-20130730220035+0000
I can however create a New Project with Android Studio.
I've tried this for about an hour now and im getting sort of pissed, because it doesnt seem to know what it wants. Is it some sort of Bug or did i make some sort of mistake.
You're using a very old version of Android Studio. I'd recommend upgrading to 0.4.3. Versions later than 0.4.0 allow direct import of Eclipse projects instead of requiring you to do the cumbersome (and as you've seen problematic) export of projects from Eclipse; it's smarter about setting up the right plugin and Gradle versions. 0.4.3 has some important bugfixes over 0.4.0-0.4.2.
I've just migrated my projects. Here is two suggestions from my side.
Take the latest Android Studio.
Do not export / import projects from Eclipse. Most likely you are going to have errors in the project after this step. Starting from a clean project, which builds, will safe you a lot of time and avoid unnecessary frustration.
Create an empty Android Project in Android Studio. It must build without errors (⌘ F9). The start to enhance it using official Gradle Plugin user guide.
Create libraries folder and add all libraries in there one by one. Update build.gradle dependencies as mentioned in user guide. Make sure everything builds successfully.
After all libraries build you can copy-paste sources, resources and assets from Eclipse project to corresponding folders of Android Studio project. Make sure everything build as expected.
Now you can start with more advanced configuration like ProGuard configuration, release certificates etc.
I've done it in a couple of hours. Hope this helps you too.

Categories

Resources