0

Well, hey all !

So having a less than a friendly start with Android Google Maps API v2 developpement, I thought I could gain some wisdom by posting on the result of my trial and get some feedback, hopefully you'll be able and genereous enough to give me some guidance.

So, here we go !

First, code of my Activity :

    package com.example.ok;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

@SuppressLint("NewApi")
public class MainActivity extends Activity {
    static final LatLng HAMBURG = new LatLng(53.558, 9.927);
    static final LatLng KIEL = new LatLng(53.551, 9.993);
    private GoogleMap map;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
                .getMap();
        Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
                .title("Hamburg"));
        Marker kiel = map.addMarker(new MarkerOptions()
                .position(KIEL)
                .title("Kiel")
                .snippet("Kiel is cool")
                .icon(BitmapDescriptorFactory
                        .fromResource(R.drawable.ic_launcher)));

        // Move the camera instantly to hamburg with a zoom of 15.
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));

        // Zoom in, animating the camera.
        map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

Second, code for the Manifest :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ok"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <permission
        android:name="com.example.ok.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <uses-permission android:name="com.example.ok.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <uses-library android:name="com.google.android.gms.maps" />

        <activity
            android:name="com.example.ok.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="I Got it and I had to change debug keystore for it and ... long story but I really think it's a good apikey" />
    </application>

</manifest>

Third, code for the layout XML :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >


    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.MapFragment" />



</RelativeLayout>

So as you would notice, nothing more than a standard code for a beginner to start with and roll on to more and deeper stuff...Still, it doesn't work !

Now, having done my research, I've got to assess few eventual causes of my hardship, here's what I've come through :

1- Emulator does not generally deal with this, that's being the case since openGL es 2.0 is not well supported by these virtual machines yet,

2- apiKey is not good, in fact having tried to do the code with api v1 at first, I got into all sorts of problems because of it (deprecated..), I now shifted into coding with v2, I've deleted debug keystore file and then rebuild on eclipse, got a new one and then used the SHA-1 code with the package name to generate new apiKey code on Google Console... So I don't think this is the source of the evil for me,

3- tried a device, I've downloaded few demos of openGL es 2.0 and it's doing fine, so must not be openGL (but who knows ?). When I try to install the apk, it at declare that the application must have permission to use internat and location data and such, I click on install but... Sorry, "Application is not installed" !

4- I've brought into my project libraries the necessary stuff, meaning : android-support-v4.jar and google-play-services.jar amongst others...

5-made sure the project build target is google apis 17 (compatible with a 4.2 platform, while writing this I've noticed that my device is on a 4.0.2 Android version, could that be it ?).

So, that was long, hope you could still find it in you to indicate whatever potential solution might be usefull in my case.

Thanks in advance !

Here I add the last (and repeated part) of my logcat, only took the error :

04-11 17:11:15.289: E/StrictMode(700): null
04-11 17:11:15.289: E/StrictMode(700): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d195d0 that was originally bound here
04-11 17:11:15.289: E/StrictMode(700):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
04-11 17:11:15.289: E/StrictMode(700):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
04-11 17:11:15.289: E/StrictMode(700):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
04-11 17:11:15.289: E/StrictMode(700):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
04-11 17:11:15.289: E/StrictMode(700):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
04-11 17:11:15.289: E/StrictMode(700):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
04-11 17:11:15.289: E/StrictMode(700):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
04-11 17:11:15.289: E/StrictMode(700):  at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
04-11 17:11:15.289: E/StrictMode(700):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
04-11 17:11:15.289: E/StrictMode(700):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
04-11 17:11:15.289: E/StrictMode(700):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
04-11 17:11:15.289: E/StrictMode(700):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-11 17:11:15.289: E/StrictMode(700):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-11 17:11:15.289: E/StrictMode(700):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-11 17:11:15.289: E/StrictMode(700):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-11 17:11:15.289: E/StrictMode(700):  at java.lang.Thread.run(Thread.java:856)
Akheloes
  • 1,352
  • 3
  • 11
  • 28
  • I see you followed Vogella's tutorial, where exactly did you get stuck? – Tim Apr 11 '13 at 16:43
  • Just posted the Vogella version of code I tried, I tried many others but with no change in result. Where I got stuck is at running the application : when I compile it on emulator, it just does not show, when I take the apk on my device and try to install it, it first starts but stoppes on an error... – Akheloes Apr 11 '13 at 16:46
  • What is the error that shows? – Tim Apr 11 '13 at 16:51
  • On emulator : none, it just does not show anything, it starts as if of nothing at all. On my device : it first asks (trying to translate this correctly from french) "Would you like to install this application ? Authorize the application acces to : your position, storage, ... I click install, a second or two and then : "application is not installed". – Akheloes Apr 11 '13 at 16:57
  • What error does the logcat show? – Tim Apr 11 '13 at 17:00
  • Can you edit that in your post so its easier to read? :p – Tim Apr 11 '13 at 17:17
  • Yeah totally, gosh pardon bro ! Doing it right away :p – Akheloes Apr 11 '13 at 17:21
  • Check this post, its about the same error http://stackoverflow.com/questions/13765122/various-android-logcat-errors – Tim Apr 11 '13 at 17:28
  • Ok, took a look, went ahead and created a new emulator device, tried it out and nothing changed. I checked the "Use Host GPU" and unchecked it, still the app will not apprear on my emulator :( – Akheloes Apr 11 '13 at 18:02
  • Did you also try that other thing that got 11 upvotes? – Tim Apr 11 '13 at 18:03
  • Just tried that as well, problem is I don't even get the app to show up on the apps panel ! That is to say, I can't even get to install it on the emulator device :S – Akheloes Apr 11 '13 at 18:30
  • Did you set it up with the right sdk versions etc? – Tim Apr 11 '13 at 19:09
  • Right SDK version ? Well, the same one with which I compiled my project anyhow. I have come accross some internet posts that mentionned the impossiblity to emulate the Google Maps API v2, couldn't that just be it ? Too bad I don't have the right device, that would've saved me some time I think. – Akheloes Apr 11 '13 at 19:35
  • Could be, im not sure about that. I made a maps project myself last week but i only tested on a device :/ – Tim Apr 11 '13 at 20:01
  • Yeah, guess that must be it, thanks anyway Mr Tim :) – Akheloes Apr 11 '13 at 20:19

0 Answers0