• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Why a very simple google map application doesn't work

madsum

Lurker
Oct 24, 2012
4
0
Hello,

I am try to make Google map v2 application. I found lots of example and looks simple and strength forward. But unfortunately none of them work for me. I wasted couple of days and couldn't do make launch a map application yet. I configured prerequisites such as enable service Map 2 in google api console, Google Maps API key, download google-play-services_lib and import it in work space, etc. But always get FATAL EXCEPTION as soon as I call

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

Please help to figure out my problem. I think one has to examine my project configuration to answer this question. So please get the complete project as zip as attachment. I also added a file named Google APIs Console.pdf where I took print google api console to show my api key is correct as well.

Please guys help me!
 

Attachments

  • AndroidMapsV2.zip
    2.7 MB · Views: 51
Problem solved. Android introduces new meta data as follows. So we need it along with api key. So it should be in the AndroidManifest.xml inside <application > node as follows:-

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="your application key form google api console"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />


<activity
android:name="com.example.myapp.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>
</application>
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones