I am a beginner to android ... i am creating an app to load Google map v2.But it is not loading and keeps crashing every time with a message Unfortunatelyhas closed.Please help me to resolve the error..Thanks in advance..I am a regular follower stack overflow..
**my code**
**Main activity.java**
package com.mypack.test;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import android.os.Bundle;
import android.app.Activity;
import android.widget.Toast;
public class MainActivity extends Activity {
// Google Map
private GoogleMap googleMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* function to load map. If map is not created it will create it for you
* */
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
#Override
protected void onResume() {
super.onResume();
initilizeMap();
}
}
Test manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypack.test"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.mypack.test.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.mypack.test.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<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.mypack.test.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>
<!-- Goolge API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDnHxpS7Pb6YeKBmyWjV_Slj9mIjo6M1FM" />
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Logcat
09-19 09:23:08.785: E/Trace(803): error opening trace file: No such file or directory (2)
09-19 09:23:09.515: W/dalvikvm(803): VFY: unable to resolve static field 1065 (MapAttrs) in Lcom/google/android/gms/R$styleable;
09-19 09:23:09.515: D/dalvikvm(803): VFY: replacing opcode 0x62 at 0x000e
09-19 09:23:09.525: D/AndroidRuntime(803): Shutting down VM
09-19 09:23:09.525: W/dalvikvm(803): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
09-19 09:23:09.535: E/AndroidRuntime(803): FATAL EXCEPTION: main
09-19 09:23:09.535: E/AndroidRuntime(803): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
09-19 09:23:09.535: E/AndroidRuntime(803): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
09-19 09:23:09.535: E/AndroidRuntime(803): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.app.Activity.onCreateView(Activity.java:4716)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
09-19 09:23:09.535: E/AndroidRuntime(803): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.app.Activity.setContentView(Activity.java:1881)
09-19 09:23:09.535: E/AndroidRuntime(803): at com.mypack.test.MainActivity.onCreate(MainActivity.java:17)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.app.Activity.performCreate(Activity.java:5104)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.os.Handler.dispatchMessage(Handler.java:99)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.os.Looper.loop(Looper.java:137)
09-19 09:23:09.535: E/AndroidRuntime(803): at android.app.ActivityThread.main(ActivityThread.java:5041)
09-19 09:23:09.535: E/AndroidRuntime(803): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 09:23:09.535: E/AndroidRuntime(803): at java.lang.reflect.Method.invoke(Method.java:511)
09-19 09:23:09.535: E/AndroidRuntime(803): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-19 09:23:09.535: E/AndroidRuntime(803): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-19 09:23:09.535: E/AndroidRuntime(803): at dalvik.system.NativeStart.main(Native Method)
new logcat after editing the previous code..and loading playservice and v4.jar
09-19 14:04:10.644: D/dalvikvm(1930): GC_CONCURRENT freed 1650K, 22% free 6514K/8284K, paused 76ms+19ms, total 279ms
09-19 14:04:10.644: D/dalvikvm(1930): WAIT_FOR_CONCURRENT_GC blocked 51ms
09-19 14:04:11.121: I/Choreographer(1930): Skipped 51 frames! The application may be doing too much work on its main thread.
09-19 14:04:13.281: I/Choreographer(1930): Skipped 170 frames! The application may be doing too much work on its main thread.
09-19 14:05:14.910: D/dalvikvm(1930): GC_CONCURRENT freed 85K, 7% free 7779K/8284K, paused 71ms+5ms, total 151ms
09-19 14:05:14.910: D/dalvikvm(1930): WAIT_FOR_CONCURRENT_GC blocked 64ms
09-19 14:05:15.040: E/MediaPlayer(1930): prepareAsync called in state 8
09-19 14:05:15.040: W/System.err(1930): java.lang.IllegalStateException
09-19 14:05:15.040: W/System.err(1930): at android.media.MediaPlayer.prepare(Native Method)
09-19 14:05:15.050: W/System.err(1930): at androassist.mypack.splash.onCreate(splash.java:38)
09-19 14:05:15.050: W/System.err(1930): at android.app.Activity.performCreate(Activity.java:5104)
09-19 14:05:15.060: W/System.err(1930): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-19 14:05:15.060: W/System.err(1930): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
09-19 14:05:15.060: W/System.err(1930): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
09-19 14:05:15.060: W/System.err(1930): at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-19 14:05:15.060: W/System.err(1930): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
09-19 14:05:15.060: W/System.err(1930): at android.os.Handler.dispatchMessage(Handler.java:99)
09-19 14:05:15.060: W/System.err(1930): at android.os.Looper.loop(Looper.java:137)
09-19 14:05:15.060: W/System.err(1930): at android.app.ActivityThread.main(ActivityThread.java:5041)
09-19 14:05:15.071: W/System.err(1930): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 14:05:15.071: W/System.err(1930): at java.lang.reflect.Method.invoke(Method.java:511)
09-19 14:05:15.071: W/System.err(1930): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-19 14:05:15.080: W/System.err(1930): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-19 14:05:15.080: W/System.err(1930): at dalvik.system.NativeStart.main(Native Method)
09-19 14:05:20.561: I/Choreographer(1930): Skipped 39 frames! The application may be doing too much work on its main thread.
09-19 14:05:21.551: I/Choreographer(1930): Skipped 222 frames! The application may be doing too much work on its main thread.
09-19 14:05:22.491: I/Choreographer(1930): Skipped 225 frames! The application may be doing too much work on its main thread.
09-19 14:05:26.330: W/IInputConnectionWrapper(1930): showStatusIcon on inactive InputConnection
09-19 14:05:28.770: D/Notice(1930): Entering log
09-19 14:05:28.920: D/Key(1930): key matched
09-19 14:05:32.620: I/Choreographer(1930): Skipped 783 frames! The application may be doing too much work on its main thread.
09-19 14:05:33.422: I/Choreographer(1930): Skipped 174 frames! The application may be doing too much work on its main thread.
09-19 14:05:35.290: I/Choreographer(1930): Skipped 55 frames! The application may be doing too much work on its main thread.
09-19 14:05:59.101: D/Notice(1930): Entering log
09-19 14:05:59.831: I/Choreographer(1930): Skipped 48 frames! The application may be doing too much work on its main thread.
09-19 14:06:00.600: I/MyApp(1930): Silent mode
09-19 14:06:00.710: I/Choreographer(1930): Skipped 115 frames! The application may be doing too much work on its main thread.
09-19 14:06:01.280: I/Choreographer(1930): Skipped 48 frames! The application may be doing too much work on its main thread.
09-19 14:06:15.223: D/Notice(1930): Entering log
09-19 14:06:15.900: I/Choreographer(1930): Skipped 54 frames! The application may be doing too much work on its main thread.
09-19 14:06:16.712: I/MyApp(1930): Silent mode
09-19 14:06:16.930: I/Choreographer(1930): Skipped 187 frames! The application may be doing too much work on its main thread.
09-19 14:06:17.620: I/Choreographer(1930): Skipped 92 frames! The application may be doing too much work on its main thread.
09-19 14:06:26.514: D/Notice(1930): Entering log
09-19 14:06:27.103: I/Choreographer(1930): Skipped 50 frames! The application may be doing too much work on its main thread.
09-19 14:06:28.241: D/GPS(1930): GPS Enabled
09-19 14:06:28.265: D/loc message:(1930): fmygpslo(0.00.0)
09-19 14:06:28.731: I/Choreographer(1930): Skipped 381 frames! The application may be doing too much work on its main thread.
09-19 14:06:34.700: I/Choreographer(1930): Skipped 177 frames! The application may be doing too much work on its main thread.
Thank you for spending your valuable time.I got the solution...it was my mistake...
As Reghunandan and Patrik said.It is problem with referencing google playstore services..my app references google playstore services from SDK directory,not from the loaded version of google playstore in my workspace.So the above errors are cleared..While running app the map is not loading..I checked it with the following code
package myapp.mypack;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.Toast;
public class MapActivity extends FragmentActivity {
String msgtype,sendernum;
// Google Map
private GoogleMap googleMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(check())
{
setContentView(R.layout.app_main);
Toast.makeText(this, "In Google play service.", Toast.LENGTH_LONG).show();
initFun();
}
else
{
Toast.makeText(this, "Google play service not available.", Toast.LENGTH_LONG).show();
}
}
private Boolean check()
{
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if(status==ConnectionResult.SUCCESS)
{
return true;
}
return false;
}
public void initFun()
{
SupportMapFragment sp = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
googleMap = sp.getMap();
googleMap.setMyLocationEnabled(true);
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.map, menu);
return true;
}
}
Android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myapp.mypack"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="myapp.mypack.googlemapsv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="myapp.mypack.googlemapsv2.permission.MAPS_RECEIVE"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
</uses-permission>
<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<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="myapp.mypack.MapActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Goolge API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDnHxpS7Pb6YeKBmyWjV_Slj9mIjo6M1FM" />
</application>
</manifest>
But my map is loading...Instead it gives a while screen and displays
"Google play service not available." as specified in the code..but i checked my project>properties>android. google playstore library is there with a green tick mark.
So think it is the problem with my playstore version..*i run the app in my galaxy s3 mini.But it also shows the same white screen..my playstore build version in phone is:4.3.11.The only solution i have is to update playstore and rerun my app.The logcat also shows my mobile phone's playsore version need to be updated..Guys please have a look at my queries..Is it the problem with my phone's playstore version..*
logcat
09-20 01:19:51.980: E/Trace(26515): error opening trace file: No such file or directory (2)
09-20 01:19:52.020: W/GooglePlayServicesUtil(26515): Google Play services out of date. Requires 3264100 but found 3225134
09-20 01:19:52.190: D/libEGL(26515): loaded /system/lib/egl/libEGL_mali.so
09-20 01:19:52.210: D/libEGL(26515): loaded /system/lib/egl/libGLESv1_CM_mali.so
09-20 01:19:52.210: D/libEGL(26515): loaded /system/lib/egl/libGLESv2_mali.so
09-20 01:19:52.240: D/OpenGLRenderer(26515): Enabling debug mode 0
**Please help me to find a solution?**
private void initilizeMap() {
if (googleMap == null) {
MapFragment mapFragment = (MapFragment)getFragmentManager().findFragmentById(R.id.map);
googleMap = mapFragment.getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
run it on device..
Related
I want to use Google Maps in my android app, but I get this error every time I run the app and no map is showing
E/Google Maps Android API﹕ Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
I have tried every solution on the internet,
I changed the API_Key, uninstalled the app before I run, Added all possible tags to manifest, yet google maps not showing.
When I downloaded a sample from the internet and got it run, but when try to add activity into my original app I get same error with no maps showing.
I have attached code in the manifest, build.gradle, and the map activity.
I also attached the Logcat and pic of the phone
I hope someone can put me on the right direction
Thanks
//Logcat
03-25 12:18:33.569 1877-1877/com.comp.roadmap.dev I/art﹕ Not late-enabling -Xcheck:jni (already on)
03-25 12:18:33.917 1877-1889/com.comp.roadmap.dev I/art﹕ Background sticky concurrent mark sweep GC freed 1760(106KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 729KB/729KB, paused 2.270ms total 114.494ms
03-25 12:18:34.323 1877-1896/com.comp.roadmap.dev D/OpenGLRenderer﹕ Render dirty regions requested: true
03-25 12:18:34.325 1877-1877/com.comp.roadmap.dev D/﹕ HostConnection::get() New Host Connection established 0xa6d9fa00, tid 1877
03-25 12:18:34.332 1877-1877/com.comp.roadmap.dev D/Atlas﹕ Validating map...
03-25 12:18:34.423 1877-1897/com.comp.roadmap.dev D/Exception﹕ java.net.UnknownHostException: Unable to resolve host "webservice.pollsdb.com": No address associated with hostname
--------- beginning of crash
03-25 12:18:34.423 1877-1897/com.comp.roadmap.dev E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.comp.roadmap.dev, PID: 1877
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at java.io.StringReader.<init>(StringReader.java:47)
at com.comp.roadmap.app.login$CheckLoginWSTask.doInBackground(login.java:330)
at com.comp.roadmap.app.login$CheckLoginWSTask.doInBackground(login.java:295)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
03-25 12:18:34.428 1877-1896/com.comp.roadmap.dev D/﹕ HostConnection::get() New Host Connection established 0xa6d9fd80, tid 1896
03-25 12:18:34.454 1877-1896/com.comp.roadmap.dev I/OpenGLRenderer﹕ Initialized EGL, version 1.4
03-25 12:18:34.482 1877-1896/com.comp.roadmap.dev D/OpenGLRenderer﹕ Enabling debug mode 0
03-25 12:18:34.502 1877-1896/com.comp.roadmap.dev W/EGL_emulation﹕ eglSurfaceAttrib not implemented
03-25 12:18:34.502 1877-1896/com.comp.roadmap.dev W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa6db56e0, error=EGL_SUCCESS
03-25 12:18:34.573 1877-1896/com.comp.roadmap.dev W/EGL_emulation﹕ eglSurfaceAttrib not implemented
03-25 12:18:34.573 1877-1896/com.comp.roadmap.dev W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa6db5700, error=EGL_SUCCESS
03-25 12:18:34.734 1877-1889/com.comp.roadmap.dev I/art﹕ Background sticky concurrent mark sweep GC freed 961(70KB) AllocSpace objects, 0(0B) LOS objects, 10% free, 1521KB/1704KB, paused 726us total 123.706ms
03-25 12:18:34.932 1877-1889/com.comp.roadmap.dev I/art﹕ Background partial concurrent mark sweep GC freed 692(36KB) AllocSpace objects, 0(0B) LOS objects, 25% free, 1492KB/2004KB, paused 1.413ms total 112.221ms
03-25 12:18:35.308 1877-1877/com.comp.roadmap.dev I/Choreographer﹕ Skipped 41 frames! The application may be doing too much work on its main thread.
03-25 12:18:35.815 1877-1877/com.comp.roadmap.dev E/WindowManager﹕ android.view.WindowLeaked: Activity com.comp.roadmap.app.login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{1f1f0dc6 V.E..... R......D 0,0-684,322} that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:363)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:261)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:298)
at com.comp.roadmap.app.login$CheckLoginWSTask.onPreExecute(login.java:447)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
at android.os.AsyncTask.execute(AsyncTask.java:535)
at com.comp.roadmap.app.login.LogMeIn(login.java:282)
at com.comp.roadmap.app.login.onCreate(login.java:145)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
03-25 12:18:47.249 1877-1897/com.comp.roadmap.dev I/Process﹕ Sending signal. PID: 1877 SIG: 9
03-25 12:18:59.919 2114-2126/com.comp.roadmap.dev I/art﹕ Background sticky concurrent mark sweep GC freed 2967(141KB) AllocSpace objects, 2(32KB) LOS objects, 0% free, 1254KB/1254KB, paused 1.542ms total 158.227ms
03-25 12:19:00.023 2114-2130/com.comp.roadmap.dev D/OpenGLRenderer﹕ Render dirty regions requested: true
03-25 12:19:00.028 2114-2114/com.comp.roadmap.dev D/﹕ HostConnection::get() New Host Connection established 0xa60ed060, tid 2114
03-25 12:19:00.046 2114-2114/com.comp.roadmap.dev D/Atlas﹕ Validating map...
03-25 12:19:00.142 2114-2130/com.comp.roadmap.dev D/﹕ HostConnection::get() New Host Connection established 0xa60a4a60, tid 2130
03-25 12:19:00.160 2114-2130/com.comp.roadmap.dev I/OpenGLRenderer﹕ Initialized EGL, version 1.4
03-25 12:19:00.198 2114-2130/com.comp.roadmap.dev D/OpenGLRenderer﹕ Enabling debug mode 0
03-25 12:19:00.238 2114-2130/com.comp.roadmap.dev W/EGL_emulation﹕ eglSurfaceAttrib not implemented
03-25 12:19:00.238 2114-2130/com.comp.roadmap.dev W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa60c5200, error=EGL_SUCCESS
03-25 12:19:00.313 2114-2130/com.comp.roadmap.dev W/EGL_emulation﹕ eglSurfaceAttrib not implemented
03-25 12:19:00.313 2114-2130/com.comp.roadmap.dev W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa60c5220, error=EGL_SUCCESS
03-25 12:19:00.653 2114-2114/com.comp.roadmap.dev I/Choreographer﹕ Skipped 34 frames! The application may be doing too much work on its main thread.
03-25 12:19:00.732 2114-2126/com.comp.roadmap.dev I/art﹕ Background sticky concurrent mark sweep GC freed 3217(193KB) AllocSpace objects, 0(0B) LOS objects, 10% free, 1609KB/1801KB, paused 12.515ms total 36.928ms
03-25 12:19:01.149 2114-2130/com.comp.roadmap.dev W/EGL_emulation﹕ eglSurfaceAttrib not implemented
03-25 12:19:01.149 2114-2130/com.comp.roadmap.dev W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa60c5200, error=EGL_SUCCESS
03-25 12:19:01.339 2114-2114/com.comp.roadmap.dev I/zzx﹕ Making Creator dynamically
03-25 12:19:01.372 2114-2114/com.comp.roadmap.dev W/ResourcesManager﹕ Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
03-25 12:19:01.372 2114-2114/com.comp.roadmap.dev W/ResourcesManager﹕ Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
03-25 12:19:01.448 2114-2114/com.comp.roadmap.dev I/Google Maps Android API﹕ Google Play services client version: 7095000
03-25 12:19:01.499 2114-2126/com.comp.roadmap.dev W/art﹕ Suspending all threads took: 48.763ms
03-25 12:19:01.549 2114-2126/com.comp.roadmap.dev I/art﹕ Background sticky concurrent mark sweep GC freed 126(7KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 2MB/2MB, paused 86.924ms total 168.922ms
03-25 12:19:01.587 2114-2114/com.comp.roadmap.dev I/Google Maps Android API﹕ Google Play services package version: 7097470
03-25 12:19:02.333 2114-2126/com.comp.roadmap.dev I/art﹕ Background sticky concurrent mark sweep GC freed 10597(597KB) AllocSpace objects, 1(16KB) LOS objects, 4% free, 11MB/12MB, paused 3.255ms total 206.012ms
03-25 12:19:02.476 2114-2126/com.comp.roadmap.dev I/art﹕ Background partial concurrent mark sweep GC freed 14992(666KB) AllocSpace objects, 2(1015KB) LOS objects, 15% free, 10MB/12MB, paused 2.601ms total 128.036ms
03-25 12:19:02.605 2114-2138/com.comp.roadmap.dev E/Google Maps Android API﹕ Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
03-25 12:19:02.664 2114-2138/com.comp.roadmap.dev E/Google Maps Android API﹕ In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: AIzaSyDe8mb_u5CJ7D55Z2sohIoy9iT6SP_WM2A
Android Application (<cert_fingerprint>;<package_name>): A9:DC:CA:C8:90:F6:FA:44:1C:8F:5A:BC:EB:71:57:E8:6C:E5:3B:37;com.comp.roadmap.dev
03-25 12:19:02.667 2114-2138/com.comp.roadmap.dev I/Google Maps Android API﹕ Failed to contact Google servers. Another attempt will be made when connectivity is established.
03-25 12:19:02.792 2114-2130/com.comp.roadmap.dev W/EGL_emulation﹕ eglSurfaceAttrib not implemented
03-25 12:19:02.793 2114-2130/com.comp.roadmap.dev W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa4e7cf00, error=EGL_SUCCESS
03-25 12:19:04.727 2114-2149/com.comp.roadmap.dev D/﹕ HostConnection::get() New Host Connection established 0x9f4e91f0, tid 2149
03-25 12:19:04.758 2114-2114/com.comp.roadmap.dev I/Choreographer﹕ Skipped 122 frames! The application may be doing too much work on its main thread.
03-25 12:19:05.279 2114-2114/com.comp.roadmap.dev E/WindowManager﹕ android.view.WindowLeaked: Activity com.comp.roadmap.app.login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{f60576c V.E..... R....... 0,0-684,388} that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:363)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:261)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:298)
at android.app.AlertDialog$Builder.show(AlertDialog.java:987)
at com.comp.roadmap.app.login.Alert(login.java:271)
at com.comp.roadmap.app.login.access$300(login.java:36)
at com.comp.roadmap.app.login$CheckLoginWSTask.onPostExecute(login.java:378)
at com.comp.roadmap.app.login$CheckLoginWSTask.onPostExecute(login.java:295)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
03-25 12:19:17.719 2114-2150/com.comp.roadmap.dev E/Google Maps Android API﹕ Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
//Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.comp.roadmap.app" >
<permission android:name="com.comp.roadmap.app.permission.MAPS_RECEIVE"
android:protectionLevel="signature">
</permission>
<uses-permission android:name="com.comp.roadmap.app.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<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" />
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-feature android:glEsVersion="0x00020000" android:required="true"></uses-feature>
<application
android:name=".PubVar"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name=".add_msg"
android:label="#string/title_activity_add_msg" >
</activity>
<activity
android:name=".ItemDetail"
android:label="#string/title_activity_item_detail" >
</activity>
<activity
android:name=".ListFilter"
android:label="#string/title_activity_list_filter" >
</activity>
<activity
android:name=".login"
android:label="#string/title_activity_login" >
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".test1"
android:label="#string/title_activity_test1" >
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDe8mb_u5CJ7D55Z2sohIoy9iT6SP_WM2A" />
<activity
android:name=".MapsActivity"
android:label="#string/title_activity_maps" >
</activity>
</application>
</manifest>
// build.gradle
apply plugin: 'android'
android {
compileSdkVersion 22
buildToolsVersion '21.1.2'
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionCode 7
versionName "0.1.65"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
dev {
applicationId "com.roadmap.schlogger.dev"
}
prod {
applicationId "com.roadmapb.schlogger.app"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/ftp4j-1.7.2.jar')
compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
}
//MapsActivity.java
package com.comp.roadmap.app;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity {
private GoogleMap mMap; // Might be null if Google Play services APK is not available.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
setUpMapIfNeeded();
}
#Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
/**
* Sets up the map if it is possible to do so (i.e., the Google Play services APK is correctly
* installed) and the map has not already been instantiated.. This will ensure that we only ever
* call {#link #setUpMap()} once when {#link #mMap} is not null.
* <p/>
* If it isn't installed {#link SupportMapFragment} (and
* {#link com.google.android.gms.maps.MapView MapView}) will show a prompt for the user to
* install/update the Google Play services APK on their device.
* <p/>
* A user can return to this FragmentActivity after following the prompt and correctly
* installing/updating/enabling the Google Play services. Since the FragmentActivity may not
* have been completely destroyed during this process (it is likely that it would only be
* stopped or paused), {#link #onCreate(Bundle)} may not be called again so we should call this
* method in {#link #onResume()} to guarantee that it will be called.
*/
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
setUpMap();
}
}
}
/**
* This is where we can add markers or lines, add listeners or move the camera. In this case, we
* just add a marker near Africa.
* <p/>
* This should only be called once and when we are sure that {#link #mMap} is not null.
*/
private void setUpMap() {
mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}
}
//activity_maps.xml
<fragment 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" android:id="#+id/map"
tools:context="com.comp.roadmap.app.MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
If you are using emulator maybe you dont have Google Play Services installed, and even if you have google play services installed check if you have the latest version.
According your exception:
Caused by: java.lang.NullPointerException:
Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at java.io.StringReader.(StringReader.java:47)
at com.comp.roadmap.app.login$CheckLoginWSTask.doInBackground(login.java:330)
at com.comp.roadmap.app.login$CheckLoginWSTask.doInBackground(login.java:295)
In line doInBackground(login.java:295) you are asking for a lenght of a null String variable.
Also, which API are you using?
Ensure that the "Google Maps Android API v2" is enabled.
And:
Ensure that the following Android Key exists: API Key: AIzaSyDe8mb_u5CJ7D55Z2sohIoy9iT6SP_WM2A
You downloaded API and registered to be able to use maps api?
I just started to study Android.
I made an app for simple test using PhoneGap, but the deviceready event wasn't fired.
So, I read LogCat and found some errors.
02-24 21:10:18.110: D/dalvikvm(8584): GC_FOR_ALLOC freed 93K, 21% free 9617K/12168K, paused 20ms, total 20ms
02-24 21:10:18.110: I/dalvikvm-heap(8584): Grow heap (frag case) to 12.861MB for 1127536-byte allocation
02-24 21:10:18.130: D/dalvikvm(8584): GC_FOR_ALLOC freed <1K, 20% free 10718K/13272K, paused 18ms, total 18ms
02-24 21:10:18.145: I/webclipboard(8584): clipservice: android.sec.clipboard.ClipboardExManager#4322ffe0
02-24 21:10:18.200: I/CordovaLog(8584): Changing log level to DEBUG(3)
02-24 21:10:18.200: I/CordovaLog(8584): Found preference for useBrowserHistory=true
02-24 21:10:18.200: D/CordovaLog(8584): Found preference for useBrowserHistory=true
02-24 21:10:18.200: I/CordovaLog(8584): Found preference for exit-on-suspend=false
02-24 21:10:18.200: D/CordovaLog(8584): Found preference for exit-on-suspend=false
02-24 21:10:18.205: D/JsMessageQueue(8584): Set native->JS mode to 2
02-24 21:10:18.210: D/DroidGap(8584): DroidGap.init()
02-24 21:10:18.225: D/CordovaWebView(8584): >>> loadUrl(file:///android_asset/www/index.html)
02-24 21:10:18.225: D/PluginManager(8584): init()
02-24 21:10:18.230: D/CordovaWebView(8584): >>> loadUrlNow()
02-24 21:10:18.235: D/WebView(8584): loadUrlImpl: called
02-24 21:10:18.235: D/DroidGap(8584): Resuming the App
02-24 21:10:18.285: D/SoftKeyboardDetect(8584): Ignore this event
02-24 21:10:18.325: V/webkit(8584): BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {43227980}
02-24 21:10:18.335: D/webcore(8584): CORE loadUrl: called
02-24 21:10:18.335: D/webkit(8584): Firewall not null
02-24 21:10:18.345: D/webkit(8584): euler: isUrlBlocked = false
02-24 21:10:18.360: D/libEGL(8584): loaded /system/lib/egl/libEGL_mali.so
02-24 21:10:18.370: D/libEGL(8584): loaded /system/lib/egl/libGLESv1_CM_mali.so
02-24 21:10:18.450: D/libEGL(8584): loaded /system/lib/egl/libGLESv2_mali.so
02-24 21:10:18.455: E/(8584): Device driver API match
02-24 21:10:18.455: E/(8584): Device driver API version: 23
02-24 21:10:18.455: E/(8584): User space API version: 23
02-24 21:10:18.455: E/(8584): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Fri Nov 29 14:18:37 KST 2013
02-24 21:10:18.535: D/OpenGLRenderer(8584): Enabling debug mode 0
02-24 21:10:18.540: D/WebView(8584): onSizeChanged - w:720 h:1230
02-24 21:10:18.570: D/DroidGap(8584): onMessage(onPageStarted,file:///android_asset/www/index.html)
02-24 21:10:18.570: D/SoftKeyboardDetect(8584): Ignore this event
02-24 21:10:19.005: D/CordovaLog(8584): onload event
02-24 21:10:19.005: D/CordovaLog(8584): file:///android_asset/www/index.html: Line 50 : onload event
02-24 21:10:19.005: I/Web Console(8584): onload event:50
02-24 21:10:19.010: I/GATE(8584): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
02-24 21:10:19.010: D/Cordova(8584): onPageFinished(file:///android_asset/www/index.html)
02-24 21:10:19.010: D/WebView(8584): loadUrlImpl: called
02-24 21:10:19.010: D/webcore(8584): CORE loadUrl: called
02-24 21:10:19.010: D/webkit(8584): Firewall not null
02-24 21:10:19.010: D/webkit(8584): euler: isUrlBlocked = false
02-24 21:10:19.015: D/DroidGap(8584): onMessage(onNativeReady,null)
02-24 21:10:19.015: D/DroidGap(8584): onMessage(onPageFinished,file:///android_asset/www/index.html)
02-24 21:10:19.060: E/SQLiteLog(8584): (14) cannot open file at line 32516 of [00bb9c9ce4]
02-24 21:10:19.060: E/SQLiteLog(8584): (14) os_unix.c:32516: (2) open(/CachedGeoposition.db) -
02-24 21:10:19.060: D/WebKit(8584): ERROR:
02-24 21:10:19.060: D/WebKit(8584): SQLite database failed to load from /CachedGeoposition.db
02-24 21:10:19.060: D/WebKit(8584): Cause - unable to open database file
02-24 21:10:19.060: D/WebKit(8584): external/webkit/Source/WebCore/platform/sql/SQLiteDatabase.cpp(71) : bool WebCore::SQLiteDatabase::open(const WTF::String&, bool)
02-24 21:10:21.015: D/DroidGap(8584): onMessage(spinner,stop)
02-24 21:10:21.050: D/TilesManager(8584): Starting TG #0, 0x4225c580
02-24 21:10:21.050: D/TilesManager(8584): new EGLContext from framework: 421dcb88
02-24 21:10:21.050: D/GLWebViewState(8584): Reinit shader
02-24 21:10:21.050: D/GLWebViewState(8584): Reinit transferQueue
I think Device driver API Match error is problem..
And here's Manifest.xml file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ex5"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<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_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.ex5.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>
</manifest>
index.html File
<!DOCTYPE html>
<html>
<head>
<title>index</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src="cordova-2.2.0.js"></script>
<script type="text/javascript">
function onDeviceReady() {
console.log("deviceready");
alert('test');
}
function init() {
console.log('onload event');
document.addEventListener("deviceready", onDeviceReady, false);
}
</script>
</head>
<body onload="init();">
</body>
</html>
And MainActivity.java File
package com.example.ex5;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
I tested on Galaxy S3 Android Version is 4.3.
But, test on Galaxy S2 Android Version 4.0.3 worked well.
I don't know what are the problems of my sources or my Galaxy S3 Device or Android Version.
Please let me know what are the things I should fix.
That error was fun! I reseted the usb keys today on my S3 and after got that error. When I tried to run my another app, the error was gone :D
My Project has a map activity with other activities linked using intent. However all other activities are been seen; Map just shows a blank white screen on phone and error" update google play services" on the emulator. please help
ActivityMap.java
package com.example.bloodbankmap;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gms.maps.SupportMapFragment;
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.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class ActivityMap extends FragmentActivity {
// Google Map
private GoogleMap googleMap;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* function to load map. If map is not created it will create it for you
* */
private void initilizeMap() {
if (googleMap == null) {
// googleMap = ((MapFragment) getFragmentManager().findFragmentById(
//R.id.map)).getMap();
googleMap = ((SupportMapFragment)(getSupportFragmentManager().findFragmentById(R.id.map))).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
#Override
protected void onResume() {
super.onResume();
initilizeMap();
}
}
map.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!-- <Button
android:id="#+id/button10"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="View Complete Stock " /> -->
</RelativeLayout>
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bloodbankmap"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.example.bloodbankmap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.bloodbankmap.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<!-- Requires OpenGL ES version 2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/blood"
android:label="#string/app_name">
<activity
android:name="com.example.bloodbankmap.Launcher"
android:label="#string/app_name"
android:theme="#style/AppBaseTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.bloodbankmap.List"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.bloodbankmap.ActivityMap"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.bloodbankmap.Registration"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.bloodbankmap.Area"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.bloodbankmap.Disp_bb"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.bloodbankmap.Nearest_BB"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.bloodbankmap.Notifications"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.bloodbankmap.Notify"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.bloodbankmap.SByBlgrp"
android:label="#string/app_name" >
</activity>
<!-- Goolge API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyD-0S4belIQQUFoYL26Y_fimoS6FZ4udpE" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
my logcat
02-20 06:07:15.317: D/dalvikvm(1022): GC_CONCURRENT freed 272K, 15% free 2489K/2904K, paused 17ms+3ms, total 62ms
02-20 06:07:15.317: D/dalvikvm(1022): WAIT_FOR_CONCURRENT_GC blocked 46ms
02-20 06:07:15.327: I/dalvikvm-heap(1022): Grow heap (frag case) to 3.254MB for 721184-byte allocation
02-20 06:07:15.377: D/dalvikvm(1022): GC_FOR_ALLOC freed 1K, 12% free 3191K/3612K, paused 48ms, total 49ms
02-20 06:07:15.557: I/Choreographer(1022): Skipped 44 frames! The application may be doing too much work on its main thread.
02-20 06:07:15.597: D/gralloc_goldfish(1022): Emulator without GPU emulation detected.
02-20 06:07:52.841: D/dalvikvm(1161): GC_FOR_ALLOC freed 251K, 14% free 2489K/2884K, paused 36ms, total 38ms
02-20 06:07:52.841: I/dalvikvm-heap(1161): Grow heap (frag case) to 3.253MB for 721184-byte allocation
02-20 06:07:52.901: D/dalvikvm(1161): GC_FOR_ALLOC freed 2K, 12% free 3191K/3592K, paused 49ms, total 49ms
02-20 06:07:52.961: D/dalvikvm(1161): GC_CONCURRENT freed <1K, 12% free 3191K/3592K, paused 5ms+25ms, total 65ms
02-20 06:07:53.101: I/Choreographer(1161): Skipped 33 frames! The application may be doing too much work on its main thread.
02-20 06:07:53.151: D/gralloc_goldfish(1161): Emulator without GPU emulation detected.
02-20 06:07:55.442: I/Choreographer(1161): Skipped 57 frames! The application may be doing too much work on its main thread.
02-20 06:07:55.811: I/Choreographer(1161): Skipped 399 frames! The application may be doing too much work on its main thread.
02-20 06:07:55.841: D/dalvikvm(1161): GC_CONCURRENT freed 731K, 24% free 2858K/3732K, paused 6ms+43ms, total 163ms
02-20 06:07:57.901: I/Choreographer(1161): Skipped 2434 frames! The application may be doing too much work on its main thread.
02-20 06:07:58.231: I/Choreographer(1161): Skipped 70 frames! The application may be doing too much work on its main thread.
02-20 06:07:58.392: I/Choreographer(1161): Skipped 175 frames! The application may be doing too much work on its main thread.
02-20 06:07:58.571: I/Choreographer(1161): Skipped 42 frames! The application may be doing too much work on its main thread.
02-20 06:07:59.131: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.181: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.241: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.281: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.321: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.351: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.391: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.422: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.461: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.651: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.681: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.781: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.821: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.902: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:07:59.961: W/GooglePlayServicesUtil(1161): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:08:00.021: D/dalvikvm(1161): GC_CONCURRENT freed 317K, 20% free 2993K/3732K, paused 15ms+58ms, total 255ms
02-20 06:08:00.081: I/Choreographer(1161): Skipped 157 frames! The application may be doing too much work on its main thread.
02-20 06:08:00.351: I/Choreographer(1161): Skipped 128 frames! The application may be doing too much work on its main thread.
02-20 06:08:00.641: I/Choreographer(1161): Skipped 30 frames! The application may be doing too much work on its main thread.
02-20 06:56:51.331: E/Trace(1652): error opening trace file: No such file or directory (2)
02-20 06:56:51.991: D/dalvikvm(1652): GC_FOR_ALLOC freed 262K, 14% free 2489K/2892K, paused 87ms, total 89ms
02-20 06:56:52.001: I/dalvikvm-heap(1652): Grow heap (frag case) to 3.253MB for 721184-byte allocation
02-20 06:56:52.061: D/dalvikvm(1652): GC_FOR_ALLOC freed 2K, 12% free 3191K/3600K, paused 54ms, total 54ms
02-20 06:56:52.131: D/dalvikvm(1652): GC_CONCURRENT freed <1K, 12% free 3191K/3600K, paused 5ms+4ms, total 71ms
02-20 06:56:52.301: I/Choreographer(1652): Skipped 38 frames! The application may be doing too much work on its main thread.
02-20 06:56:52.331: D/gralloc_goldfish(1652): Emulator without GPU emulation detected.
02-20 06:56:54.451: I/Choreographer(1652): Skipped 43 frames! The application may be doing too much work on its main thread.
02-20 06:56:54.801: I/Choreographer(1652): Skipped 382 frames! The application may be doing too much work on its main thread.
02-20 06:56:54.821: D/dalvikvm(1652): GC_CONCURRENT freed 731K, 24% free 2858K/3732K, paused 5ms+22ms, total 146ms
02-20 06:56:55.001: I/Choreographer(1652): Skipped 44 frames! The application may be doing too much work on its main thread.
02-20 06:56:55.651: I/Choreographer(1652): Skipped 45 frames! The application may be doing too much work on its main thread.
02-20 06:56:56.032: I/Choreographer(1652): Skipped 99 frames! The application may be doing too much work on its main thread.
02-20 06:57:03.691: I/Choreographer(1652): Skipped 105 frames! The application may be doing too much work on its main thread.
02-20 06:57:04.301: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:04.351: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:04.411: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:04.441: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:04.491: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:04.531: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:04.581: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:04.611: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:04.651: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:04.881: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:04.931: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:05.082: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:05.131: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:05.231: D/dalvikvm(1652): GC_CONCURRENT freed 292K, 20% free 2987K/3732K, paused 6ms+38ms, total 256ms
02-20 06:57:05.241: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:05.291: W/GooglePlayServicesUtil(1652): Google Play services out of date. Requires 4242000 but found 3136130
02-20 06:57:05.371: I/Choreographer(1652): Skipped 71 frames! The application may be doing too much work on its main thread.
02-20 06:57:05.681: I/Choreographer(1652): Skipped 114 frames! The application may be doing too much work on its main thread.
02-20 06:57:07.101: I/Choreographer(1652): Skipped 70 frames! The application may be doing too much work on its main thread.
02-20 06:57:07.271: I/Choreographer(1652): Skipped 45 frames! The application may be doing too much work on its main thread.
02-20 06:57:14.221: I/Choreographer(1652): Skipped 55 frames! The application may be doing too much work on its main thread.
02-20 06:57:14.971: I/Choreographer(1652): Skipped 51 frames! The application may be doing too much work on its main thread.
02-20 06:57:15.516: I/Choreographer(1652): Skipped 87 frames! The application may be doing too much work on its main thread.
02-20 06:57:16.541: I/Choreographer(1652): Skipped 30 frames! The application may be doing too much work on its main thread.
02-20 06:57:17.311: I/Choreographer(1652): Skipped 48 frames! The application may be doing too much work on its main thread.
02-20 07:35:21.421: D/dalvikvm(1811): GC_CONCURRENT freed 281K, 15% free 2491K/2916K, paused 17ms+6ms, total 105ms
02-20 07:35:21.421: D/dalvikvm(1811): WAIT_FOR_CONCURRENT_GC blocked 33ms
02-20 07:35:21.442: I/dalvikvm-heap(1811): Grow heap (frag case) to 3.256MB for 721184-byte allocation
02-20 07:35:21.492: D/dalvikvm(1811): GC_FOR_ALLOC freed 4K, 12% free 3191K/3624K, paused 46ms, total 46ms
02-20 07:35:21.751: I/Choreographer(1811): Skipped 43 frames! The application may be doing too much work on its main thread.
02-20 07:35:21.781: D/gralloc_goldfish(1811): Emulator without GPU emulation detected.
02-20 07:35:23.801: I/Choreographer(1811): Skipped 61 frames! The application may be doing too much work on its main thread.
02-20 07:35:24.181: D/dalvikvm(1811): GC_CONCURRENT freed 731K, 24% free 2854K/3728K, paused 6ms+70ms, total 146ms
02-20 07:35:24.201: I/Choreographer(1811): Skipped 462 frames! The application may be doing too much work on its main thread.
02-20 07:35:24.391: I/Choreographer(1811): Skipped 36 frames! The application may be doing too much work on its main thread.
02-20 07:35:24.941: I/Choreographer(1811): Skipped 35 frames! The application may be doing too much work on its main thread.
02-20 07:35:25.351: I/Choreographer(1811): Skipped 101 frames! The application may be doing too much work on its main thread.
02-20 07:35:25.982: I/Choreographer(1811): Skipped 62 frames! The application may be doing too much work on its main thread.
02-20 07:35:26.501: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:26.551: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:26.581: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:26.631: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:26.671: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:26.711: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:26.751: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:26.781: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:26.821: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:26.981: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:27.001: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:27.241: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:27.281: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:27.361: D/dalvikvm(1811): GC_CONCURRENT freed 276K, 20% free 3003K/3728K, paused 69ms+48ms, total 281ms
02-20 07:35:27.372: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:27.411: W/GooglePlayServicesUtil(1811): Google Play services out of date. Requires 4242000 but found 3136130
02-20 07:35:27.502: I/Choreographer(1811): Skipped 87 frames! The application may be doing too much work on its main thread.
02-20 07:35:27.771: I/Choreographer(1811): Skipped 99 frames! The application may be doing too much work on its main thread.
02-20 07:35:29.351: I/Choreographer(1811): Skipped 30 frames! The application may be doing too much work on its main thread.
02-20 07:35:30.241: D/AndroidRuntime(1811): Shutting down VM
02-20 07:35:30.251: W/dalvikvm(1811): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
02-20 07:35:30.271: E/AndroidRuntime(1811): FATAL EXCEPTION: main
02-20 07:35:30.271: E/AndroidRuntime(1811): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.google.android.gms flg=0x80000 pkg=com.android.vending }
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.app.Activity.startActivityForResult(Activity.java:3370)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.app.Activity.startActivityForResult(Activity.java:3331)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.app.Activity.startActivity(Activity.java:3566)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.app.Activity.startActivity(Activity.java:3534)
02-20 07:35:30.271: E/AndroidRuntime(1811): at com.google.android.gms.dynamic.a$5.onClick(Unknown Source)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.view.View.performClick(View.java:4204)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.view.View$PerformClick.run(View.java:17355)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.os.Handler.handleCallback(Handler.java:725)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.os.Handler.dispatchMessage(Handler.java:92)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.os.Looper.loop(Looper.java:137)
02-20 07:35:30.271: E/AndroidRuntime(1811): at android.app.ActivityThread.main(ActivityThread.java:5041)
02-20 07:35:30.271: E/AndroidRuntime(1811): at java.lang.reflect.Method.invokeNative(Native Method)
02-20 07:35:30.271: E/AndroidRuntime(1811): at java.lang.reflect.Method.invoke(Method.java:511)
02-20 07:35:30.271: E/AndroidRuntime(1811): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-20 07:35:30.271: E/AndroidRuntime(1811): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-20 07:35:30.271: E/AndroidRuntime(1811): at dalvik.system.NativeStart.main(Native Method)
02-20 07:35:33.941: D/dalvikvm(1825): GC_CONCURRENT freed 250K, 14% free 2589K/2984K, paused 74ms+4ms, total 156ms
02-20 07:35:34.101: I/Choreographer(1825): Skipped 127 frames! The application may be doing too much work on its main thread.
02-20 07:35:34.111: D/gralloc_goldfish(1825): Emulator without GPU emulation detected.
02-20 07:35:34.373: I/Choreographer(1825): Skipped 213 frames! The application may be doing too much work on its main thread.
02-20 07:35:35.283: I/Choreographer(1825): Skipped 88 frames! The application may be doing too much work on its main thread.
02-20 07:35:36.031: I/Choreographer(1825): Skipped 92 frames! The application may be doing too much work on its main thread.
02-20 07:35:36.081: I/Choreographer(1825): Skipped 43 frames! The application may be doing too much work on its main thread.
02-20 07:35:36.191: I/Choreographer(1825): Skipped 32 frames! The application may be doing too much work on its main thread.
02-20 07:35:36.281: I/Choreographer(1825): Skipped 36 frames! The application may be doing too much work on its main thread.
02-20 07:35:36.684: I/Choreographer(1825): Skipped 88 frames! The application may be doing too much work on its main thread.
02-20 07:35:36.831: I/Choreographer(1825): Skipped 98 frames! The application may be doing too much work on its main thread.
Either your api key has been generated using a SHA1 fingerprint , which has not been generated from your computer i.e a fingerprint mismatch is occuring.
Or you are providing a wrong api key.
Also update your Google Play Services in sdk.
You cannot emulate google maps on the emulator you just need a real device for working with maps, since adt emulator don't have google play services installed, just make sure google services are updated your api key is not wrong and go test your app on a real device , however this must be known I searched and found this Link go see it they describe how you car run the Google Maps in the emulator.
I have updated my answer and showed my code it is little different from yours but may it help you
public class MainActivity extends FragmentActivity {
private static final int GPS_ERRORDIALOG_REQUEST = 9001;
GoogleMap mMap;
MapView mMapView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (servicesOK()) {
Toast.makeText(this, "Ready to map!", Toast.LENGTH_SHORT).show();
setContentView(R.layout.activity_mapview);
// 1- get reference to MapView
mMapView = (MapView)findViewById(R.id.map);
// 2- MapView has the same life cycles as the Activity
mMapView.onCreate(savedInstanceState);
}else {
setContentView(R.layout.activity_main);
}
}
#Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
#Override
protected void onPause() {
super.onPause();
mMapView.onPause();
}
#Override
protected void onResume() {
super.onResume();
mMapView.onResume();
}
#Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
#Override
protected void onStart() {
super.onStart();
}
#Override
protected void onStop() {
super.onStop();
}
#Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
/**
* Test and check if Google Play Services is available
* #return boolean
*/
public boolean servicesOK() {
int isAvailable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (isAvailable == ConnectionResult.SUCCESS) {
return true;
}
else if (GooglePlayServicesUtil.isUserRecoverableError(isAvailable)) {
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(isAvailable, this, GPS_ERRORDIALOG_REQUEST);
dialog.show();
}
else {
Toast.makeText(this, "Can't connect to Google Play services", Toast.LENGTH_SHORT).show();
}
return false;
}
}
activity_mapview.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Adds a mapView to the layout -->
<com.google.android.gms.maps.MapView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.google.android.gms.maps.MapView>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="com.example.gmapsapp.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-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.example.gmapsapp.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="YOUR_API_KEY_IS_NOT_PUBLIC"/>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
see the following link too here
from ur logcat I see
02-20 07:35:30.271: E/AndroidRuntime(1811):
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=android.intent.action.VIEW dat=market://details?
Actually, the problem relates to Gingerbread and older phones using the wrong URI if they don't already have the Play Store installed. This isn't a safe assumption. Most out-of-the-box Gingerbread phones don't come with it, and Google updates don't necessarily install it. See the discussion
https://code.google.com/p/android/issues/detail?id=42543
U can get answer for this link
Try replacing fill_parent with match_parent in your layout, fill_parent has been deprecated after android 2.2 Also, try regenerating the api key.
what device are you testing on?
Think the problem Is SHA1 Key ,
1.Get The API Key And Update it your google_maps_api.xml file.
https://developers.google.com/maps/documentation/android-api/start#step_4_get_a_google_maps_api_key
2.Generate Sha1
>Open Android Studio.
>Open Your Project.
>Click on Gradle (From Right Side Panel, you will see Gradle Bar)
>Click on Refresh (Click on Refresh from Gradle Bar , you will see List
Gradle scripts of your Project)
>Click on Your Project (Your Project Name form List(root))
>Click on Tasks
>Click on android
>Double Click on signingReport (You will get SHA1 and MD5 in Run Bar)
How to get the SHA-1 fingerprint certificate in Android Studio for debug mode?
clean project
in android studio
menu > build > clean project
4.Run application on your phone or emulator
I am tring to implement google maps using the new google maps api v2 and for some reason i don't see a map.
I think that the problem is those two lines of error when i run it on the emulator:
E/ActivityThread( 1373): Failed to find provider info for com.google.settings
E/ActivityThread( 1373): Failed to find provider info for com.google.android.gsf
.gservices
when i run the application on the device the following error is produced:
Could not find class 'maps.j.k', referenced from method map.y.ae.a
My problem looks the same as in this link: http://android-er.blogspot.co.il/2012/12/google-maps-android-api-v2-with-blank.html
There it's says that the problem may be my key so i went and reproduced it using the following tutorial: http://android-er.blogspot.co.il/2012/12/displaying-sha1-certificate-fingerprint.html. but this still didn't helped me.
the support files are of course add to the project as well as the Google play services lib.
I see the same result on the emulator (after adding manually the two file that allow using the google map v2 on the emulator) as well as on the motorola Defy running android 2.2.
Maybe I am using the wrong debug.keystore? I am using the one in my User.android folder.If so then how do i find the right file?
EDIT: My eclipse says that my debug key is in the default folder. So i renamed the debug.keystore file and ran the Eclipse to recreate it all over again. That resulted in producing a new SHA1 key. I used it to create a new Google Maps API v2 key but the result is still the same. I'm still unable to see the map.
EDIT2: Stupid me, I chose Google Map API V2 instead of Google Maps Android API V2.
This question can be closed. Thanks.
Here are all the code files:
xml:
<?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
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraBearing="112.5"
map:cameraTargetLat="-33.796923"
map:cameraTargetLng="150.922433"
map:cameraTilt="30"
map:cameraZoom="13"
map:mapType="normal"
map:uiCompass="false"
map:uiRotateGestures="true"
map:uiScrollGestures="false"
map:uiTiltGestures="true"
map:uiZoomGestures="true" />
</LinearLayout>
Map Fragmentactivity class:
package com.eadesign.skygiraffefinalv2;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import android.os.Bundle;
import com.google.android.gms.maps.*;
import android.widget.ImageView;
import android.widget.TextView;
public class Map extends android.support.v4.app.FragmentActivity
{
private GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()) == 0)
{
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
// map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
}
}}
manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.eadesign.skygiraffefinalv2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>
<permission android:name="com.eadesign.skygiraffefinalv2.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.eadesign.skygiraffefinalv2.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<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" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/sgicon90"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen">
<activity
android:name=".Map"
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="My key"/>
</application>
log from logcat:
ent.category.LAUNCHER] flg=0x10000000 cmp=com.eadesign.skygiraffefinalv2/.Map u=
0} from pid 1362
W/WindowManager( 148): Failure taking screenshot for (246x410) to layer 21010
D/AndroidRuntime( 1362): Shutting down VM
I/ActivityManager( 148): Start proc com.eadesign.skygiraffefinalv2 for activity
com.eadesign.skygiraffefinalv2/.Map: pid=1373 uid=10046 gids={3003, 1015, 1028}
D/dalvikvm( 1373): Not late-enabling CheckJNI (already on)
D/dalvikvm( 1362): GC_CONCURRENT freed 99K, 77% free 483K/2048K, paused 1ms+1ms,
total 13ms
D/jdwp ( 1362): Got wake-up signal, bailing out of select
D/dalvikvm( 1362): Debugger has detached; object registry had 1 entries
E/jdwp ( 1373): Failed sending reply to debugger: Broken pipe
D/dalvikvm( 1373): Debugger has detached; object registry had 2 entries
E/Trace ( 1373): error opening trace file: No such file or directory (2)
D/dalvikvm( 1373): GC_CONCURRENT freed 204K, 3% free 8264K/8519K, paused 89ms+6m
s, total 161ms
D/dalvikvm( 1373): WAIT_FOR_CONCURRENT_GC blocked 33ms
E/ActivityThread( 1373): Failed to find provider info for com.google.settings
E/ActivityThread( 1373): Failed to find provider info for com.google.settings
D/dalvikvm( 1373): GC_CONCURRENT freed 312K, 5% free 8471K/8839K, paused 82ms+10
5ms, total 268ms
E/ActivityThread( 1373): Failed to find provider info for com.google.android.gsf
.gservices
E/ActivityThread( 1373): Failed to find provider info for com.google.android.gsf
.gservices
D/dalvikvm( 1373): GC_CONCURRENT freed 227K, 4% free 8797K/9095K, paused 91ms+11
0ms, total 300ms
D/libEGL ( 1373): Emulator without GPU support detected. Fallback to software r
enderer.
I/Choreographer( 1373): Skipped 54 frames! The application may be doing too muc
h work on its main thread.
D/gralloc_goldfish( 1373): Emulator without GPU emulation detected.
D/libEGL ( 1373): loaded /system/lib/egl/libGLES_android.so
I/ActivityManager( 148): Displayed com.eadesign.skygiraffefinalv2/.Map: +3s545ms
I/Choreographer( 1373): Skipped 75 frames! The application may be doing too muc
h work on its main thread.
In my case I chose Google Maps API V2 instead of Google Maps Android API V2. After changing that the problem was gone. So this code is perfectly fine to create a full screen Google map and the question can be closed.
Thanks.
I have created an android application which plays music from the Internet.
It is working properly when I run it from eclipse, but when I try to start the application from emulator by clicking icon on emulator, it shows a Toast, saying "Application is not installed on your phone".
I don't understand the reason. Can someone help me out?
07-27 18:40:17.543: DEBUG/AndroidRuntime(537): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
07-27 18:40:17.543: DEBUG/AndroidRuntime(537): CheckJNI is ON
07-27 18:40:19.543: DEBUG/AndroidRuntime(537): Calling main entry com.android.commands.pm.Pm
07-27 18:40:19.683: DEBUG/AndroidRuntime(537): Shutting down VM
07-27 18:40:19.703: INFO/AndroidRuntime(537): NOTE: attach of thread 'Binder Thread #4' failed
07-27 18:40:19.715: DEBUG/dalvikvm(537): GC_CONCURRENT freed 100K, 72% free 296K/1024K, external 0K/0K, paused 2ms+4ms
07-27 18:40:19.715: DEBUG/jdwp(537): Got wake-up signal, bailing out of select
07-27 18:40:19.715: DEBUG/dalvikvm(537): Debugger has detached; object registry had 1 entries
07-27 18:40:20.283: DEBUG/AndroidRuntime(548): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
07-27 18:40:20.283: DEBUG/AndroidRuntime(548): CheckJNI is ON
07-27 18:40:21.193: DEBUG/AndroidRuntime(548): Calling main entry com.android.commands.am.Am
07-27 18:40:21.233: INFO/ActivityManager(61): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.nine.patch/.Patch } from pid 548
07-27 18:40:21.303: DEBUG/AndroidRuntime(548): Shutting down VM
07-27 18:40:21.383: INFO/AndroidRuntime(548): NOTE: attach of thread 'Binder Thread #3' failed
07-27 18:40:21.799: DEBUG/dalvikvm(548): GC_CONCURRENT freed 102K, 69% free 319K/1024K, external 0K/0K, paused 1ms+2ms
07-27 18:40:21.799: DEBUG/jdwp(548): Got wake-up signal, bailing out of select
07-27 18:40:21.799: DEBUG/dalvikvm(548): Debugger has detached; object registry had 1 entries
07-27 18:40:22.583: DEBUG/dalvikvm(467): GC_EXTERNAL_ALLOC freed 4K, 53% free 2564K/5379K, external 2626K/3030K, paused 67ms
07-27 18:40:22.653: DEBUG/MediaPlayer(467): Couldn't open file on client side, trying server side
07-27 18:40:22.653: INFO/StagefrightPlayer(34): setDataSource('http://www.perlgurl.org/podcast/archives/podcasts/PerlgurlPromo.mp3')
07-27 18:40:22.664: INFO/NuHTTPDataSource(34): connect to www.perlgurl.org:80/podcast/archives/podcasts/PerlgurlPromo.mp3 #0
07-27 18:40:31.286: WARN/ActivityManager(61): Launch timeout has expired, giving up wake lock!
07-27 18:40:31.356: WARN/ActivityManager(61): Activity idle timeout for HistoryRecord{407f6138 com.nine.patch/.Patch}
07-27 18:40:31.706: DEBUG/AudioSink(34): bufferCount (4) is too small and increased to 12
07-27 18:40:32.073: INFO/ActivityManager(61): Displayed com.nine.patch/.Patch: +10s81ms
07-27 18:40:32.667: WARN/AudioFlinger(34): write blocked for 87 msecs, 1437 delayed writes, thread 0xc650
07-27 18:40:34.757: INFO/NuCachedSource2(34): ERROR_END_OF_STREAM
07-27 18:40:37.223: DEBUG/dalvikvm(140): GC_EXPLICIT freed 85K, 51% free 2950K/5959K, external 6050K/7443K, paused 81ms
07-27 18:40:37.696: WARN/AudioFlinger(34): write blocked for 72 msecs, 1493 delayed writes, thread 0xc650
07-27 18:40:42.715: WARN/AudioFlinger(34): write blocked for 71 msecs, 1557 delayed writes, thread 0xc650
07-27 18:40:47.728: WARN/AudioFlinger(34): write blocked for 71 msecs, 1620 delayed writes, thread 0xc650
07-27 18:40:52.731: WARN/AudioFlinger(34): write blocked for 71 msecs, 1684 delayed writes, thread 0xc650
07-27 18:40:57.752: WARN/AudioFlinger(34): write blocked for 71 msecs, 1748 delayed writes, thread 0xc650
07-27 18:41:02.791: WARN/AudioFlinger(34): write blocked for 73 msecs, 1809 delayed writes, thread 0xc650
07-27 18:41:07.803: WARN/AudioFlinger(34): write blocked for 75 msecs, 1874 delayed writes, thread 0xc650
07-27 18:41:11.637: ERROR/MP3Extractor(34): Unable to resync. Signalling end of stream.
That's the LogCat output.
Following is my Manifest xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nine.patch"
android:installLocation="preferExternal"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" />
<application android:icon="#drawable/icon" android:label="#string/app_name" android:permission="android.permission.INTERNET" android:debuggable="false">
<activity android:name=".Patch"
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>
One thing you can do - painful but should work - is to create another application, dead simple, which does next to nothing. That should install and work. Then start looking at every last difference between your working and non-working apps. Potentially including just moving all your code over to the new one.
I've seen something like this happen when there was a desktop shortcut icon pointing to an old and no longer present version of the app.
Try trashing any desktop shortcuts and launching from the app drawer.
NOTE: this didn't work