Maven Android Project with Test Suite - android

I'm trying to set up a project with dependencies on ActionBarSherlock (4.0 RC1) and ViewPagerIndicator, I'm currently using Eclipse IDE, and I would like to be able to build and run an Android test project for this project. I had tell Eclipse to ignore the proguard and generate-sources goals to get it to stop giving me errors, it seems that was the solution for it, but I'm having a hard time confirming if that is still the correct solution. I've had moderate success with ABS thus far, I was able to deploy a package to the emulator that had an action bar, and Eclipse seems to know about the classes and resources in ABS. However, it doesn't know about the themes (like Theme.Sherlock.Light) and displays an error. I'm okay with that, except it means I can't run using Eclipse. But it doesn't seem to work for ViewPagerIndicator. And I keep running into random errors and it feels like I'm just running around in a circle.
So I tried adding a test project (again..), so that I can test the project as I build it, to make sure it meets all my specifications at each step. But I can't seem to get that to work. If I could just get these 3 things and how to run the tests I should be able to debug other problems that are arising, but as it is now I can't even confirm where the problems lie. Most of my researching has yielded partial answers and out-of-date solutions.
Using:
ActionBarSherlock 4.0 RC1
ViewPagerIndicator 2.2.3
android-maven-plugin 3.1.1.99.0.6
Apache Maven 3.0.3
Eclipse Indigo
m2e 1.0.100.20110804-1717

I also posted this question on the maven-android-plugin Google group, and Manfred Moser pointed me to Gaug.es app for Android. It has a set up for building the app with Maven, and has dependencies for ABS, ViewPagerIndicator, RoboGuice, Robotium, and a few others. It is set up to do unit tests with surefire and integration tests with instrumentation.
He also mentioned that he uses IntelliJ IDEA, which I thought I would try for myself (since Eclipse was giving me issues and TextMate is not even an IDE). The Community Edition has been serving well so far,it provides nicer (or easier to understand) integration with ant and maven, so I can specify my "clean package android:deploy" run configuration, for example.
If you're having similar issues, I would recommend taking a look at Gaug.es, it can be a little overbearing and do more than you want or should start off with. I can post the details of what I gathered from Gaug.es for my own app if anyone else is curious, but I thought I would note that my question is currently resolved, and how it was resolved.

Related

Cordova: Trouble importing Android Downloader_Library into project

I'm using Android Studio and I'm close to just canceling the Android version of my app and just sticking with the released iOS version. I need to use an expansion APK and I cannot for the life of me get the downloader_library to import into Android Studio.
I try and run the project and it says it can't find anything from the expansion downloader. I've tried everything I can find on the forums. I've tried bringing into Eclipse and exporting out. I just can't get this to work.
I don't know if I have some kind of fundamental misunderstanding about Android and libraries and modules and things but I'm about ready to give up on this unless someone has an easy way to help me through. This is the very last step. I have the IAB working, the app works on multiple devices, the performance is good, I just can't figure out this splitting of the APK.

How to develop Android applications? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I used to be an Android developer for 2 years, but over 2 years ago. I believe that things changed - we have Android Studio, Gradle and probably more tools that I'm not aware of right now.
What is the current development stack for creating Android applications? What tools should we used right now?
I used to use eclipse with ant, but as far as I can see, a lot of people are using AS with Gradle, which is, for my first experience, extremely slow.
How to jump back into Android development after some time of not being up to date with development stack?
Eclipse vs Android Studio is a matter of choice. You can get used to it within hours, or you can continue with Eclipse. I am using both tools for different projects.
Android Studio seemed to be more stabile at some points.
Update on Android SDK and third party libraries are more easily handled with Android Studio.
Android Studio has not NDK support yet. You have to compile native codes outside of Android Studio. Edit:(Well, actually it has support but claimed to be deprecated, probably developers are working on a better solution)
Edit2:(It will be soon officially supported with C/C++ debugger)
With Android Studio you can use java7 syntax, but you have to stick with java6 syntax on Eclipse. Edit:(you can now force java8 with a plugin on A.S and I guess java7 is usable on eclipse too) Edit2:(java7 is a must now for both parties, but still java8 syntax can only be used in A.S with a help of plugin)
Google releases example codes compatible with Android Studio saying eclipse versions will be available soon.
Android Studio has better GUI designer.
Android Studio has better refactoring capabilities.
The most important change is SDK itself, actually. Just check if Android Studio is good enough for you and study on SDK.
It depends on your project. For non critical or hobby projects you should definitely start with AS and Gradle right away because this the the future of Android development. Although it is still in 'beta' and it can break some stuff after a new upgrade, it has many new features which make you more productive and happier in development.
If you have a critical project and you don't want to spend your time with checking and fixing things your are not supposed to fix, you should stick back to Eclipse, at least until AS is released.
Independently on whether you use AS or Eclipse, you should already start learning and using Gradle. It works perfectly for both options. If you hesitate you can even keep Ant and Gradle building your project in parallel. They work together and don't overlap.
I have been using Android Studio the last year and I can say that it is a very powerful tool, that I believe, in the next year, will overcome Eclipse.
When AS was still in version 4.+ Alpha, there were some issues (mostly with external libraries .jar) but since beta was released and up until now almost every bug was fixed.
Moreover, AS is better when it comes to indexing and suggestions. You will be surprised by its suggestion system, which helps you save a lot of time when coding.
I still use eclipse for other projects, but I believe for Android Development AS is the tool you should invest in, if not for now, definitely for the future.
We are using both, Android Studio and the good old Eclipse IDE. We noticed, that it basically depends on what you're doing. Android Studio is good enough for developing from now and it will replace Eclipse soon. However, it has some drawbacks where Eclipse is your choice. A small comparison was made by Google themselves: https://developer.android.com/sdk/installing/studio.html
Eclipse: Eclipse is very stable and works perfectly with ant driven builds. However, if you want to use gradle, there's some work to do to get the build process working with eclipse. We tried to use Eclipse with Gradle but the Gradle Plugin was quite buggy at this time. If you want to use native C code, you must use Eclipse, as Android Studio does not support that, yet.
Android Studio: Looks great and does also a very good job. The gradle integration works much better there. This is a big advantage over Eclipse when you have to deal with many dependencies. This is probably not an issue for small projects. But, if you're developing projects with additional libraries or frameworks you should definitely give Gradle a try. I hope, that the NDK support is coming soon, so that we can switch to AS completely. Ant builds are someway out-dated.
First of all, I will not debate about Android Studio vs Eclipse as it's an opinion based discussion and a kind of a troll...
The Android development basically the same : the base tools still ADB, Android SDK, Java language... So you can continue to use a "notepad" and compile, build and deploy by the SDK tools.
However, like in every development project, you could choose your upper level tools. Your question is about IDE and building system. This is only a matter of choice.
Android Studio and Gradle are still in beta phase for Android developments and you could use them only if you keep this in mind. You could continue to use Eclipse and Maven or switch to Android Studio and Gradle or keep using Eclipse but moving from Maven to Gradle... just make what you prefer.
The Android development stack evolved this way :
Basics tools : Text editor, SDK tools
First IDE : Eclipse with ADT plugin (can run your program from an IDE)
Industrialisation phase : Eclipse ADT + Maven (dependencies management, building process management...)
Coming phase : Android Studio (IntelliJ based) + Gradle (you can compare Gradle to Maven, but this is another discussion)
I think that other answers will give you personnal points of view about Eclipse vs Android Studio, Maven vs Gradle, etc... which is a really personnal choice ;)
My development stack for Android :
IntelliJ 14
Maven
Android SDK
plus my own OSS Framework to ease the pain of Android for a Java EE developer
Reasons:
IntelliJ is the best available IDE imo
Maven is pretty mature
The plugin has become useable
The workspace integration Maven -> IntelliJ is working great (both, using maven builds and deriving IDE builds from maven)
If Android Studio (which is in great parts IntelliJ) has become slow, it come due to the gradle stuff. I had a large scale project based on gradle and made these experiences :
Slow, Slower, gradle (up to 2GB memor consumption for building an app)
Xml is horrible, but gradle dsl is imo even worse
Switching to gradle 2.1 broke the predicate logic (e.g. formerly working project.hasProperty("foo") && property.ext.foo.equals("bar") does not work any more, this must not happen during a MINOR release
Compared with maven's xml hell, gradle leaves a callow, unmature impression on me, especially building with gradle is hell of a slow job compared with maven.
But - and this is my true oppionion - if gradle is pushed by google and gradleware, it definitely has the potential to become the next generation building tool, although I doubt that the flexibility in gradle will ever lead to a proper IDE workspace build derivation. From my point of view, the choice for gradle over maven done by google happened in a too early state.
just my two cents.
PS: Try tuning the memory settings. Give more memory to IDEA (e.g. 2GB in a 64bit enviroment). My experience with IntelliJ is, that the default mem settings are too small. You can find it in $InstallDir/bin/idea.exe.vmoptions resp. $InstallDir/bin/idea64.exe.vmoptions
EDIT: This is not intended to be gradle bashing. Gradle has large potentials indeed. This post reflects my experiences during my last project basing on gradle (non-Android). For beginners gradle might be the better choice since it is a lot easier than maven.

Unit tests in Android Studio 0.8

BREAKING NEWS: Android Studio 1.1.0 now has built-in support for unit testing. See more here: https://sites.google.com/a/android.com/tools/tech-docs/unit-testing-support
At first I know that there are very, very, very much similar questions (even here on SO). Most of them are terribly outdated so I'm asking a fresh new question which should be up to date for Android Studio 0.8.x.
I know there are some libraries which work somehow, but in almost each case I had no evidence that the information were up to date. I know there is e.g. roboelectric, there are also some deprecated Jake Wharton like gradle-android-test-plugin or double-espresso, I also found the library RoboSpock and Deckard. But none of them seems to have any Android Studio integration.
After long reseach I found this two bugs in all implementations:
The classpath is broken and needs to been hacked to get junit running
The junit tests cannot been debugged
What I'm looking for:
I want to automatically test an algorithm (which is plain java)
I want to check the integration in my Android app works
I want an integration in Android Studio so that I can jump into the code out of a stacktrace
I want to step thrue the test code
I found also somewhere a nice hack which run the tests in gradle as an external task and pushed the results into AS so that the results could been displayed, but unfortunately I cannot find that link again (and if I remember correctly it did also not work for me).
Do you guys have some fresh references? Does it work for you?
You have to edit the .iml file that Android Studio generates to point to your test-classes directory and also to fix the Stub error from Junit. There is currently no work around for this.
Gradlectric is a sample that uses the Robolectric Gradle Plugin to run unit tests in Android Studio.
Here you miss one example project setup https://github.com/nenick/android-gradle-template
But none of them seems to have any Android Studio integration.
This project is maintained for android studio
The classpath is broken and needs to been hacked to get junit running
gradle scripts will fix the classpath
The junit tests cannot been debugged
tests a running inside AS so they are easy to debug
This project of mine does not cover all your requests, but a fair lot of them.
It covers a default Java test case, and some tests interacting with Views.
The root project uses Travis CI, which uses gradle connectedCheck to run the tests. To be able to debug the tests, you can just create a test run configuration in AS and run it in debugging mode.
Note that this does not use any special Android testing frameworks like robolectric.
You can find a fork of Jake Wharton's gradle-android-test-plugin here. This is compatible with AS 0.6 and is regularly maintained by Robolectric. You can look at this project to set up Robolectric in Android Studio with help of this plugin. You can achieve fair bit of functionality you mentioned with the help of robolectric-gradle-plugin. You can also successfully debug your test code using AS.

Building an Android Project with Ant/Ivy

I am currently working on a growing Android project. In order to freeze "Jar Hell" in its tracks I am trying to set up Ivy with Ant to manage dependencies. I have built an ivy.xml file that successfully retrieves all of it's dependencies when called. After doing this I installed the Eclipse IvyDE plugin in order to use the ivy.xml with my current project. All the dependencies show up in Eclipse and when I go to the build path they are there. When I click "Run as android application" everything builds. When the app loads (in either an emulator or an actual phone) it immediately crashes on startup. From what I can tell the dependencies are not being compiled with my app. Eclipse itself seems to be aware of the dependencies because it does not produce any error messages.
So... Can anyone point me in the right direction to solve this problem? Is there something I am misunderstanding about Ivy or the IvyDE Plugin? Thanks!
I have also looked at this question Add Ivy managed dependencies to Android build path where the asker seemed to be having the same problem. I am using the most current version of all tools involved.
Although no one responded to this I figured I would answer it to show any other lost googlers what I have done. It turned out my problem was related to how I had ivysettings.xml set up. I was misunderstanding the way that retrieve pattern works. Fortunately, I found this project on GitHub which demonstrates how to use Ivy with an Android project. This example project provided a solid foundation for me to work with I hope it can help you too.
https://github.com/h8/IvyAndroidExample

Ant versus Eclipse builds for Android: Strengths of Each?

I've used Eclipse and vim variously as development environments for Android applications and found both the Eclipse plugin and the command-line SDK tools to be of similar capability.
Since I haven't explored either in its entirety, however, I'd like to ask:
What advantages are there to using Eclipse over the command-line tools and vice-versa?
I could see:
(Eclipse) nice GUI for debugging
(ant/adb/android) more amenable to automation
(hybrid) you can have it all, can't you!?
I'm especially interested in specific features that may be a deal-breaker for one and move a developer in the direction of the other.
Using Eclipse as a development environment for Android doesn't preclude you from also building with Ant to hook into nightly builds or CI tools. You could even configure Eclipse to build using your Ant buildfile if you wanted. If you want some kind of CLI build tool, you might also consider Maven, as it also has plugins to enable building Android apps.
It has been some time (like six months) since I have used eclipse, so maybe it is better now, but I gave up on it because I found it to be very slow and buggy. Maybe it is the integration with ADT, but several times I spent hours hunting down problems that turned out to be fixed if I killed and restarted eclipse (and these problems were not fixed if I did a "clean" within eclipse). After doing that a few times, I felt like throwing the computer against the wall.
"ant clean" is much easier and faster than stopping and restarting eclipse.
Across my personal projects and multiple professional instances of building Android apps, I've always used both types of builds. You'll want to use Ant (or Maven, if you prefer) to set up continuous integration and automated testing. Trying to get that working with Eclipse (which I did a long time ago when the Android SDKs were first coming out) is a nightmare, while Ant/Maven is easily used from any of your favorite CI tools (I've usually used Hudson for this). If there's nothing unusual about your project, it'll be a snap to put together continuous integration, and off you go.
Meanwhile, for just day to day development work, using Eclipse to build your app locally works just fine. But that can easily be left up to the individual developer. I'd make the build that your CI system is running the canonical build, but I do use Eclipse for my normal development.
I'd use Eclipse until such time as you are happy with the debug build. Then you can set up Ant to produce the signed release build.
You can set it up to use the same source files as Eclipse but put the output binaries outside your workspace. You can also set it to use your release.keystore, sign it automatically and obfuscate the code all in one go.
I've set it up to do this. I open a command line (DOS box) move to the projects home directory (\dev\projects\Eclipse\Project1 say), I type "Ant release" and the apk ends up in \dev\projects\AntBuilds\Project1\bin as Project1-release.apk.
If you want the best of both worlds, you might want to look at the m2eclipse-android-integration Eclipse plug-in which allows you to use your command-line Maven build in the ADT/Eclipse environment as well:
https://code.google.com/a/eclipselabs.org/p/m2eclipse-android-integration/
Well for me im just a beginner, but I find eclipse much easier to work with. Android is a pretty complicated to get used to (for me) so having everything layed out in a GUI is preferable to command line. Plus SDK updates and such are easier to get.

Categories

Resources