Issue
When trying to run the mapview in the emulator or on the device, the activity crashes. I feel this may be due to an import issue with the required libraries. The error will show a class not found exception. Please let me know if you need more information. I have also been following this tutorial: https://blog-emildesign.rhcloud.com/?p=435
Activity:
package com.klinetel.countydentistfinder;
import com.google.android.gms.maps.*;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class ClinicMapActivity extends FragmentActivity
{
MapView m;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_clinic_map);
}
}
Activity Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.klinetel.countydentistfinder"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="com.klinetel.countydentistfinder.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<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"/>
<permission
android:name="com.klinetel.countydentistfinder.LocationGoogleMapV2Demo.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.klinetel.countydentistfinder.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.klinetel.countydentistfinder.ClinicListingActivity"
android:label="@string/title_activity_clinic_listing"
android:parentActivityName="com.klinetel.countydentistfinder.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.klinetel.countydentistfinder.MainActivity" />
</activity>
<activity
android:name="com.klinetel.countydentistfinder.ClinicMapActivity"
android:label="@string/title_activity_clinic_map"
android:parentActivityName="com.klinetel.countydentistfinder.ClinicListingActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.klinetel.countydentistfinder.MainActivity" />
</activity>
<uses-library android:name="com.google.android.maps"></uses-library>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value=""/>
</application>
</manifest>
Logcat:
Solution
You should not add it as a external jar file.
You should reference the library project in your android map project.
http://developer.android.com/google/play-services/setup.html
Copy the google-play services_lib library project to your workspace (folder where your android map project is). The library project can be found under the following path.
<android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib library project .
Import the library project to your eclipse
Click File > Import, select Android > Existing Android Code into Workspace, and browse the workspace import the library project. You can check if it is library project. Right click on the library project. Goto properties. Click Android on the left panel. You will see Is Library checked.
Right click on your android project. Goto properties. Choose Android on the left panel. Click on Add and browse the library project. Select the same. Click ok and apply
Also make sure you have enabled google maps for android in the google api console
Answered By - Raghunandan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.