Using MapView in Android

Just getting started in Silver and searching for examples of how to get a MapView working in an Android app. I know I can convert Java code, but I’m not sure what components I need to reference in my project? I know about needing an API key and such from Google, but haven’t got to the stage of having a ‘grey’ map show up in my app which would indicate all is good other than the API key. Can anyone offer assistance or refer me to an example Maps app for Android in Silver?

We don’t have a sample for Maps on Android/Silver, but you need to reference:

C:\Path\To\adt-bundle-windows-x86\sdk\add-ons\addon-google_apis-google-22\maps.jar

then essentially follow: http://www.vogella.com/tutorials/AndroidGoogleMaps/article.html (replace the imports with


import android.app
import android.os
import android.view

import com.google.android.gms.maps
import com.google.android.gms.maps.model

Thanks, still having problems though. If I add a map fragment to the layout, as per the vogella page, do I need to use v4 compatibility and inherit from FragmentActivity, or with a min SDK of 17, can I continue to use Activity?

For some reason Visual Studio 2015 RC is crashing on me when I try it.

Can you send us more details on that crash? What are there exact steps, and do toys get a crash report in Event Viewer?

thanx!

The only way I can get it working is with a FragmentActivity, see attached testcase:org.me.androidapplication1.zip (168.3 KB)

Thank you, thank you!

I have my API key loaded and have your testcase app working. But, the map looks like it’s being rendered at the wrong resolution. Compared to Google Maps, it’s blurry?

Compare the one on the left which is Google Maps with the app rendering - the fonts are not clear for example.

This sounds like a key issue. Check the output of adb logcat.

I’m seeing nothing in logcat that would suggest anything other than a successful execution. Are you able to run your test code and have a clear map rendering?

On a different note, I’m finding that VS2015RC hangs frequently - often after the first build/run cycle it locks up with first ‘loading project’ and then ‘waiting for an internal operation to complete’. It just came back after about 10 minutes.
EDIT: No, it’s still locked - now seems to be stuck in a build cycle

Are there known performance issues with VS? Anything I can do to speed it?

No my map looks exactly like that, but i’m not familiar enough with these apis to know what if anything could cause it (for all I know, Maps just has different logic)

Do you have any steps that show this? We hadn’t noticed anything that causes that.

I’ll continue with the map as is - you might be correct that the API has changed since I developed the same in Xamarin over a year ago.

I’ve been trying to reproduce the VS issue and, of course, now cannot. Although the app does take 95s to build which seems a really long time for something so simple. Is that expected?

That does seem excessive. Can you turn the logging level to Diagnostic and see which task(s)( take long?

It’s been a few months, thought I’d have another try. The map is still blurry, and VS2015 still incredibly unstable - it takes an extraordinary amount of time to get to a point where the application will run, if at all. Switching on more verbose logging shows that the build goes through many lines of resolving Google libraries, then Swift libraries. Often it will then not run, VS2015 showing 'MapsSample (Running) - MS Visual Studio (Not Responding). At that point a Task Manager end process is all that will resolve.

I want to like this product, but if I can’t even get a basic maps app running without having to jump through hoops of fire …

There doesn’t seem to be much traffic to this forum. Does that mean I’m one of the few having issues, or are not many people using Elements-Silver?

Oke that is very strange. Using the latest (8.2) Elements? I can’t reproduce the lockup.

Traffic is spread over this this and all the sub forums. There’s quite a bit of traffic in the Elements group.

The upcoming 8.3 beta can do incremental builds of the .dex part. (the slow part basically)

Looking for a Beta install for 8.3 I noticed that I wasn’t running the latest code in VS2015 despite the version check saying I had the latest. Downloaded 8.2.89.1899 and happy to say that VS2015 stability is vastly improved - nice job!

Still having ‘problems’ with a blurry map, but at least I can now edit and debug without the previous frustration. Regarding the blurriness, I wonder if there is some auto-sizing going on that is causing the map to be rendered at a sub-optimal resolution. I’m tethered to a Note 4 for debugging - my layout is set to ‘fill parent’ but wonder if there’s a way I can specify the exact window size and see if that might make a difference?

1 Like

I have resolved the issue of the blurry map and wanted to share the solution as it also is relevant to another issue.

The problem was indeed as I suggested, in that the resolution being used was incorrect. Running with android.util.DisplayMetrics I found my Note 4 was showing a 320x569 screen resolution. The device was upscaling to the correct 1440 which results in the blurred map.

The solution is to explicitly set the min and target SDK in the manifest:

<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="23"/>

The map then looks correct. Image upload appears not to be working, or I would upload. You can see it here: http://www.ratsey.com/stuff/Screenshot_2015-12-09-17-35-42.png

In the VS2015 project properties dialog, under the Android settings, there’s a ‘Target platform;’ field - I have this set and would expect it to update the manifest.

Similarly, I’ve noticed that even though I have the package name set in the manifest, it’s not that property that is used in building the APK, it’s the ‘Default namespace’ from the Application settings.

When setting these properties in VS2015 I would expect the manifest to be updated. Is that a reasonable expectation or am I completely off course?

1 Like

Thanks, logged as bugs://73866

that does indeed sound like a reasonable expectation. I’m going to look into fixing that. I’m glad you managed to solve your issue though.

bugs://73866 got closed with status fixed.

Android should now automatically update that tag when the min/current version is set. Note this happens in the temp file in obj/ it doesn’t touch the manifest in the source dir.

1 Like