Munjal Upadhyay
Munjal Upadhyay

Reputation: 189

Unable to instantiate activity ComponentInfo after adding google map functionality

In my application , when I select the button, it will intent me on the mapView class, which shows me the current location of the user.

But, it throw

java.lang.RuntimeException: Unable to instantiate activity. ComponentInfo error

I have already added java class file in AndroidManifest file.

my xml file is as below ..

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.google.android.maps.MapView 
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="my api key"/>

</LinearLayout>

my java class is as below

package c.c.c;

import com.google.android.maps.MapActivity;
import android.app.Activity;
import android.os.Bundle;

public class MygoogleActivity extends MapActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}   

my android Manifest file is as below

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

    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission> 
    <uses-library android:name="com.google.android.maps" />
    <uses-permission android:name="android.permission.INTERNET" ></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />  

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MygoogleActivity" 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>
</manifest>

Upvotes: 2

Views: 1093

Answers (1)

code_finder
code_finder

Reputation: 1370

you need to add the google maps user library in your AndroidMainfest file

AndroidManifest.xml

<application android:icon="@drawable/icon" android:label="@string/app_name">

         <uses-library android:name="com.google.android.maps" />
          <activity>
                /**********/
          </activity>
 </application>

you need to provide internet permission also...

 <uses-permission android:name="android.permission.INTERNET"></uses-permission>

Upvotes: 2

Related Questions