(03/11/12 ) Google just announced a new version of Maps APIs so expected a revamp of this tutorial quite soon as I found a way to implement the new system !
In fact, it should be simplier : Just use a standard SlidingFragmentActivity extending SherlockFragmentActivity and use a MapFragment.
The advantage of this new « MapFragment » is to avoid having FragmentActivity built over MapActivity adding « useless » functions to your Activity object when you don’t use a Map ! If you don’t get it, it means your don’t need a special ActionBarSherlock and just the pom.xml from my SlidingMenu … ( I still have to check potential dependency tree issues )
(12/12/12) Hum… I checked GMaps API v2… Quite cool for simple stuffs but LOOKS LIKE HORRIBLE for advanced projects… ! The new APIs doesn’t fit my usage and I’m thinking about staying on the V1 … or wait a v3 😡
As an example : If you used a real time thread to modify your overlay’s bitmaps… you have to create new Markers/Overlay objects every time… ! Great memory management.
MyLocationOverlay looks like it was merged into a higher level abstraction so that you can’t provide it the GPS data you might collect with your own location service over the application state…
I might be wrong but let’s be honest : it sucks and it’s tough to move from v1 to v2 if you did advanced features.
I’ll try to make a new post with GMaps V2 when something is definitly working 🙂
What’s for ? :
As I’m going to create an upcoming SIG App for one of my engineering school project, I wanted to use both ActionBarSherlock and SlidingMenu … but as it’s a teamwork… people expected to have some Maven stuff to ease IDE setup. You might want to check it out for a complete example working just with a Mercurial repository import in Eclipse.
It was quite troublesome since I barely know how works Maven ! ( In fact It has started to become clearer as I spent 5 hours to get it working ! )
(3/02/13) if you want to see the result here it is :
A video of the full app is available there :
The requirements :
- First, I suggest to get Maven 3, do the path stuff to use it as command line ( scroll down the download page of Maven website for more explanations ).
- Now some android maven setup ( you just need to do the ANDROID_HOME path trick ).
- Ok now, you should be able to build stuff with Maven !
- You might already know that Maven create a « .m2 » directory in your « home » ( in windows something like : C:\Users\Kayrnt\.m2\ ) inside, it creates your local repository !
As I’m building Android projects, I need Android SDK to be in this repository and referenced as a maven dependency source.
That’s where Maven Android SDK Deployer is really useful !
- Download it there and do a « mvn clean install » inside the directory.
If you are lazy, you check my maven repository where you can find Android SDK 4.1.2.
It should do the stuff !
The snippets/custom versions :
OK now the the snippets I wrote or modified :
- ActionBarSherlock 4.2.0 ( I modified sources to use android support v4 with maps)
- SlidingMenu (it’s a modified one with ActionBarSherlock support and with the pom.xml inside)
- Finally an example of my pom.xml for my final project !
If you use my « final » pom.xml is as an « example », don’t forget to completed it with signing / zipalign etc… see the maven android website.
You just have to do « mvn clean install » in ActionBarSherlock then in the SlidingMenu directory and you’re done !
Finally use « mvn android:deploy » to deploy the apk on your device.
I set the SlidingMenu apklib version to 1.0.0 since there aren’t any for the time being.
Note that it could be interesting to upload it to Maven central !
Now some potential troubleshooting :
It looks like m2e-Android doesn’t support correctly apklib in Eclipse. However building with maven in console works properly with just apklib files.
Adding « jar » files to your pom.xml allow m2e-Android to detect classes correctly but you can’t use ressources ( like @style/Theme.Light.Sherlock ) like this.
To work properly… just have your projects opened in your workspace ( the ones declaring the apklib used in your main project ).
M2e-android-configurator has a certain issue with APKlib showing problem at building in eclipse even it’s compiling just fine using a terminal.
In fact, if you want to build with maven and still want to use Eclipse as an IDE, you need to get the « Android library projects » opened in your workspace !
You might also need to specify JDK 1.6 in run configuration of your maven build if you use Eclipse else it might not find « tools.jar » instead of a JRE.