This is the code i have copied from the sample map application even the sample map application is not showing the map.
So i separately copied and pasted the code with my API key. This time also its not showing the map.
Main Activity
package com.example.map;
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;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class MainActivity extends FragmentActivity {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setUpMapIfNeeded();
}
#Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
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();
}
}
}
private void setUpMap() {
mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}
}
XML FILE
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
Android Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.map"
android:versionCode="1"
android:versionName="1.0" >
<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"/>
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Maps API needs OpenGL ES 2.0. -->
<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" >
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDWHZJWlXbCOiVk4xlbmPfOGi6eMFTOCYM"/>
<activity
android:name="com.example.map.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>
OUT PUT:
http://i.stack.imgur.com/CzKs5.png
Try to add those two permissions:
<permission android:name="com.example.map.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.example.map.permission.MAPS_RECEIVE"/>
and try to test this application on a real device.
Seeing your stack-trace would be useful top.
I changed the code like this
**Manifest**
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.map"
android:versionCode="1"
android:versionName="1.0" >
<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"/>
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<permission android:name="com.example.map.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.example.map.permission.MAPS_RECEIVE"/>
<!-- Maps API needs OpenGL ES 2.0. -->
<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" >
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDWHZJWlXbCOiVk4xlbmPfOGi6eMFTOCYM"/>
<activity
android:name="com.example.map.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>
**LOGCAT**
Again the map is not showing
08-30 10:20:30.444: I/Choreographer(1166): Skipped 30 frames! The application may be doing too much work on its main thread.
08-30 10:20:30.724: D/dalvikvm(1166): GC_FOR_ALLOC freed 302K, 11% free 3645K/4056K, paused 72ms, total 95ms
08-30 10:20:31.084: D/dalvikvm(1166): GC_FOR_ALLOC freed 154K, 13% free 3655K/4188K, paused 200ms, total 201ms
08-30 10:20:31.474: D/dalvikvm(1166): GC_FOR_ALLOC freed 286K, 16% free 3524K/4188K, paused 150ms, total 174ms
08-30 10:20:31.554: D/dalvikvm(1166): GC_FOR_ALLOC freed 154K, 16% free 3522K/4188K, paused 31ms, total 31ms
08-30 10:20:31.625: D/dalvikvm(1166): GC_FOR_ALLOC freed 152K, 16% free 3522K/4188K, paused 45ms, total 45ms
08-30 10:20:31.674: D/dalvikvm(1166): GC_FOR_ALLOC freed 172K, 16% free 3523K/4188K, paused 31ms, total 32ms
08-30 10:20:31.734: D/dalvikvm(1166): GC_FOR_ALLOC freed 152K, 16% free 3523K/4188K, paused 32ms, total 33ms
08-30 10:20:31.794: D/dalvikvm(1166): GC_FOR_ALLOC freed 152K, 16% free 3523K/4188K, paused 45ms, total 46ms
08-30 10:20:31.854: D/dalvikvm(1166): GC_FOR_ALLOC freed 152K, 16% free 3523K/4188K, paused 35ms, total 37ms
**Console**
[2013-08-30 10:20:22 - MAp] ------------------------------
[2013-08-30 10:20:22 - MAp] Android Launch!
[2013-08-30 10:20:22 - MAp] adb is running normally.
[2013-08-30 10:20:22 - MAp] Performing com.example.map.MainActivity activity launch
[2013-08-30 10:20:22 - MAp] Automatic Target Mode: Unable to detect device compatibility.
Please select a target device.
[2013-08-30 10:20:25 - MAp] Application already deployed. No need to reinstall.
[2013-08-30 10:20:25 - MAp] Starting activity com.example.map.MainActivity on device
emulator-5556
[2013-08-30 10:20:27 - MAp] ActivityManager: Starting: Intent {
act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
cmp=com.example.map/.MainActivity }
Add in your manifest file -
uses-permission android:name="com.example.map.permission.MAPS_RECEIVE"
Add Api key which is given as you got in :
Key for browser apps (with referers)
on clicking from "API Access" https://code.google.com/apis/console/?pli=1#project:606531687416:access
Also check all the valid services for map. like Google Maps Android API v2 from services menu from the link.
Hope it will work.
Related
I am building a GPS application using Google Maps v2 API. The activity has SupportMapFragment and some text strings. When I run the application on my Android smartphone, it crashes. I dont understand the LogCat. Source code below.
Paramedic.java
package ie.itsligo.medication;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.support.v4.app.FragmentActivity;
public class Paramedic extends FragmentActivity {
TextView txtID;
TextView txtFName;
TextView txtLName;
TextView txtMedInfo;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_paramedic);
txtID = (TextView)findViewById(R.id.txtID);
txtFName = (TextView)findViewById(R.id.txtFName);
txtLName = (TextView)findViewById(R.id.txtLName);
txtMedInfo = (TextView)findViewById(R.id.txtMedInfo);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.paramedic, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
activity_paramedic.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:background="#drawable/background"
android:orientation="vertical" >
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="Patient Location"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="231dp"
android:layout_margin="5dp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="Patient Details"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
<TextView
android:id="#+id/txtID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Patient ID:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
<TextView
android:id="#+id/txtFName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="First Name:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
<TextView
android:id="#+id/txtLName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Last Name:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
<TextView
android:id="#+id/txtMedInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Medical Information:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ie.itsligo.medication"
android:versionCode="1"
android:versionName="1.0" >
<permission android:name="ie.itsligo.medication.permission.MAPS_RECIEVE" android:protectionLevel="signature"/>
<uses-permission android:name="ie.itsligo.medication.permission.MAPS_RECIEVE"/>
<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-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<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=".Paramedic"
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=""/>
</application>
</manifest>
LogCat
02-15 13:12:30.549: D/dalvikvm(31488): GC_CONCURRENT freed 120K, 10% free 10493K/11655K, paused 2ms+3ms, total 31ms
02-15 13:12:30.549: D/dalvikvm(31488): WAIT_FOR_CONCURRENT_GC blocked 8ms
02-15 13:12:30.909: D/dalvikvm(31488): GC_CONCURRENT freed 136K, 11% free 10821K/12039K, paused 6ms+255ms, total 291ms
02-15 13:12:30.979: I/Google Maps Android API(31488): Google Play services client version: 6587000
02-15 13:12:30.989: I/Google Maps Android API(31488): Google Play services package version: 6599034
02-15 13:12:31.299: D/dalvikvm(31488): GC_CONCURRENT freed 324K, 11% free 11375K/12743K, paused 13ms+3ms, total 53ms
02-15 13:12:31.299: D/dalvikvm(31488): WAIT_FOR_CONCURRENT_GC blocked 16ms
02-15 13:12:31.429: D/dalvikvm(31488): GC_FOR_ALLOC freed 966K, 15% free 11888K/13959K, paused 38ms, total 38ms
02-15 13:12:32.090: D/dalvikvm(31488): GC_CONCURRENT freed 1123K, 15% free 13363K/15559K, paused 3ms+28ms, total 146ms
02-15 13:12:32.090: D/dalvikvm(31488): WAIT_FOR_CONCURRENT_GC blocked 81ms
02-15 13:12:32.661: D/dalvikvm(31488): GC_CONCURRENT freed 691K, 11% free 14087K/15815K, paused 13ms+10ms, total 131ms
02-15 13:12:32.661: D/dalvikvm(31488): WAIT_FOR_CONCURRENT_GC blocked 39ms
02-15 13:12:33.131: W/ActivityThread(31488): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
02-15 13:12:33.151: D/AbsListView(31488): Get MotionRecognitionManager
02-15 13:12:34.012: D/dalvikvm(31488): GC_CONCURRENT freed 1344K, 15% free 14394K/16775K, paused 28ms+24ms, total 215ms
02-15 13:12:34.012: D/dalvikvm(31488): WAIT_FOR_CONCURRENT_GC blocked 85ms
02-15 13:12:34.032: D/dalvikvm(31488): WAIT_FOR_CONCURRENT_GC blocked 90ms
02-15 13:12:34.032: D/dalvikvm(31488): WAIT_FOR_CONCURRENT_GC blocked 79ms
02-15 13:12:34.032: E/Google Maps Android API(31488): Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
02-15 13:12:34.042: E/Google Maps Android API(31488): In the Google Developer Console (https://console.developers.google.com)
02-15 13:12:34.042: E/Google Maps Android API(31488): Ensure that the "Google Maps Android API v2" is enabled.
02-15 13:12:34.042: E/Google Maps Android API(31488): Ensure that the following Android Key exists:
02-15 13:12:34.042: E/Google Maps Android API(31488): API Key: My API Key
02-15 13:12:34.042: E/Google Maps Android API(31488): Android Application (<cert_fingerprint>;<package_name>):
My Debug Certificate
02-15 13:12:34.062: I/Google Maps Android API(31488): Failed to contact Google servers. Another attempt will be made when connectivity is established.
02-15 13:12:34.553: D/libEGL(31488): loaded /system/lib/egl/libEGL_mali.so
02-15 13:12:34.593: D/libEGL(31488): loaded /system/lib/egl/libGLESv1_CM_mali.so
02-15 13:12:34.593: D/libEGL(31488): loaded /system/lib/egl/libGLESv2_mali.so
02-15 13:12:34.693: D/OpenGLRenderer(31488): Enabling debug mode 0
02-15 13:12:34.833: I/libblt_hw(31488): Library opened (handle = 0, fd = 47)
02-15 13:12:35.253: D/dalvikvm(31488): GC_FOR_ALLOC freed 965K, 15% free 14586K/17159K, paused 202ms, total 205ms
02-15 13:12:39.347: D/dalvikvm(31488): GC_CONCURRENT freed 1651K, 16% free 14607K/17351K, paused 18ms+5ms, total 138ms
02-15 13:12:49.567: E/Google Maps Android API(31488): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
02-15 13:12:49.707: D/dalvikvm(31488): GC_CONCURRENT freed 1715K, 17% free 14605K/17415K, paused 18ms+9ms, total 187ms
Your mobile has lowe play version compared to the one you are using in program. I suggest you use a real device(update the play version of the device). If not a real device try using GenyMotion emulator.
Add this in AndroidManifest.xml
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Your code should be as below with it:
<permission android:name="ie.itsligo.medication.permission.MAPS_RECIEVE" android:protectionLevel="signature"/>
<uses-permission android:name="ie.itsligo.medication.permission.MAPS_RECIEVE"/>
<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-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Paramedic"
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=""/>
</application>
</manifest>
I have added AdMob banner into my application according to a how-to. But banner is never shown, i have made this the same way i did with another app and everything works perfectly. Cannot find a solution, checked all the related Stack questions, nothing works:(
I use a correct publisher id and i have added GoogleAdMobAdsSdk-6.4.1.jar
My xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
android:orientation="vertical"
tools:context=".MainActivity" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_gravity="center_vertical"
android:layout_weight="0.80" >
</ListView>
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="pub_id"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
</LinearLayout>
My manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.luckyyou.greatlaces"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.luckyyou.greatlaces.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>
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize| smallestScreenSize"/>
<activity
android:name="com.luckyyou.greatlaces.tab1"
android:label="#string/name1"
android:theme="#android:style/Theme.Dialog"
android:screenOrientation="portrait"> </activity>
...
<activity
android:name="com.luckyyou.greatlaces.tab12"
android:label="#string/name12"
android:theme="#android:style/Theme.Dialog"
android:screenOrientation="portrait">
</activity>
</application>
</manifest>
Here what LogCat says:
01-08 14:21:52.778: DEBUG/dalvikvm(1804): GC_EXTERNAL_ALLOC freed 52K, 51% free 2674K/5379K, external 1527K/1559K, paused 242ms
01-08 14:21:55.431: ERROR/ActivityThread(1804): Failed to find provider info for com.google.plus.platform
01-08 14:21:55.518: INFO/Ads(1804): To get test ads on this device, call adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
01-08 14:21:55.858: DEBUG/dalvikvm(1804): DexOpt: --- BEGIN 'ads-143252855.jar' (bootstrap=0) ---
01-08 14:21:56.198: DEBUG/dalvikvm(1818): DexOpt: load 64ms, verify+opt 75ms
01-08 14:21:56.378: DEBUG/dalvikvm(1804): DexOpt: --- END 'ads-143252855.jar' (success) ---
01-08 14:21:56.378: DEBUG/dalvikvm(1804): DEX prep '/data/data/com.luckyyou.greatlaces/cache/ads-143252855.jar': unzip in 34ms, rewrite 520ms
01-08 14:21:56.378: DEBUG/dalvikvm(1804): GC_EXTERNAL_ALLOC freed 217K, 50% free 2876K/5639K, external 2151K/2316K, paused 140ms
01-08 14:21:56.388: DEBUG/webviewglue(1804): nativeDestroy view: 0x91621b8
01-08 14:21:56.748: INFO/Ads(1804): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":0,"session_id":"9030672260837145206","seq_num":"1","slotname":"pub_id","u_w":320,"msid":"com.luckyyou.greatlaces","cap":"m,a","js":"afma-sdk-a-v6.4.1","bas_off":0,"net":"ed","app_name":"1.android.com.luckyyou.greatlaces","hl":"en","gnt":3,"carrier":"310260","u_audio":4,"kw":[],"u_sd":1.5,"simulator":1,"ms":"aESYziECsoJ_gzwNWoDn5OQjNPknVakDj2SrrKXxrOZsEWD6r4wsETa7CzeB3sCAwMmoFdWVd-PB3S-s381WQrdDEK_k05alE8tfJmkHWXNzJkS-Xql-6WqEEAgBc0-8cSp08YlmRv0xjgqH5yKehnOHMtOonYftI2DXsmFuMAwdjIOmWmCYaT7BjDQDlUzULzTvZRe6EvgSgalmiK-4Wfem4vJyo-QXzVRVG5Ng0WRcCebjE0LIulSyCsQyngqLWg2VhqUfHzGfiru4NxSUYV3GvxksLLXeShEv8X00-c629-Loha16sjyWYc0ecQ9gerTls_FvObQwTYyTb3jqRg","isu":"B3EEABB8EE11C2BE770B684D95219ECB","format":"320x50_mb","oar":0,"ad_pos":{"height":0,"visible":0,"y":76,"x":0,"width":0},"u_h":533,"pt":1,"bas_on":0,"ptime":0});</script></head><body></body></html>
01-08 14:21:56.918: DEBUG/dalvikvm(1804): GC_EXTERNAL_ALLOC freed 128K, 49% free 2886K/5639K, external 2438K/3005K, paused 108ms
01-08 14:21:57.550: DEBUG/dalvikvm(1804): GC_EXTERNAL_ALLOC freed <1K, 49% free 2885K/5639K, external 4395K/5489K, paused 126ms
01-08 14:21:58.507: DEBUG/gralloc_goldfish(1804): Emulator without GPU emulation detected.
01-08 14:21:59.218: INFO/ActivityManager(858): Displayed com.luckyyou.greatlaces/.MainActivity: +7s494ms
01-08 14:22:00.818: WARN/webcore(1804): Can't get the viewWidth after the first layout
01-08 14:22:00.998: WARN/Ads(1804): Invalid unknown request error: Cannot determine request type. Is your ad unit id correct?
01-08 14:22:00.998: DEBUG/webviewglue(1804): nativeDestroy view: 0x915dbd0
01-08 14:22:01.008: INFO/Ads(1804): onFailedToReceiveAd(Invalid Ad request.)
01-08 14:22:05.238: DEBUG/dalvikvm(1131): GC_EXPLICIT freed 9K, 52% free 2662K/5511K, external 1527K/1559K, paused 149ms
These look to be the relevant lines in the log.
Since your layout looks OK I suspect that you have do something funky in the theme you have applied for the application that is causing confusion with the view width. Review your #style/AppTheme config.
01-08 14:22:00.818: WARN/webcore(1804): Can't get the viewWidth after the first layout
01-08 14:22:00.998: WARN/Ads(1804): Invalid unknown request error: Cannot determine request type. Is your ad unit id correct?
The final thing: You said you are using Admob-6.4.1. Are you also using thge GooglePlayServices library? If so you might have inadvertently used some of the Admob classes from GPS. If this is the case then I suggest removing Admob-6.4.1 and going 100% with GPS.
I've looked at just about every question on here regarding this error and still haven't been able to track it down.
Here's my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.cs2110_final"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<permission
android:name="com.example.cs2110_final.TheHunt.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.cs2110_final.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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.cs2110_final.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>
<activity
android:name="com.example.cs2110_final.TheHunt"
android:label="#string/title_activity_the_hunt" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="(API key edited out)" />
</application>
</manifest>
Here's my Activity code:
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
And here's the XML reference to the Map:
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
I've gone through the entire API process three times now and no luck. Every permission that needs to be put in the manifest has been, as far as I can tell (even the sneaky GPS_Services one). Any ideas? Thanks in advance for any help!
Edit: here's the LogCat output. It's this, followed by many repetitions of "Failed to load map..."
04-19 13:59:03.108: D/dalvikvm(26070): GC_CONCURRENT freed 252K, 6% free 7534K/7940K, paused 4ms+7ms, total 29ms
04-19 13:59:03.138: D/libEGL(26070): loaded /system/lib/egl/libEGL_tegra.so
04-19 13:59:03.148: D/libEGL(26070): loaded /system/lib/egl/libGLESv1_CM_tegra.so
04-19 13:59:03.168: D/libEGL(26070): loaded /system/lib/egl/libGLESv2_tegra.so
04-19 13:59:03.198: D/OpenGLRenderer(26070): Enabling debug mode 0
04-19 13:59:05.968: D/dalvikvm(26070): GC_CONCURRENT freed 301K, 6% free 7654K/8108K, paused 3ms+3ms, total 21ms
04-19 13:59:06.048: D/dalvikvm(26070): GC_CONCURRENT freed 216K, 5% free 7877K/8248K, paused 3ms+2ms, total 29ms
04-19 13:59:06.128: D/dalvikvm(26070): GC_CONCURRENT freed 309K, 6% free 8079K/8540K, paused 3ms+3ms, total 26ms
04-19 13:59:06.128: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 5ms
04-19 13:59:06.128: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 5ms
04-19 13:59:06.128: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 6ms
04-19 13:59:06.128: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 6ms
04-19 13:59:06.198: D/dalvikvm(26070): GC_CONCURRENT freed 250K, 5% free 8330K/8736K, paused 2ms+2ms, total 24ms
04-19 13:59:06.198: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 8ms
04-19 13:59:06.258: D/dalvikvm(26070): GC_CONCURRENT freed 317K, 6% free 8527K/8996K, paused 2ms+3ms, total 25ms
04-19 13:59:06.258: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 10ms
04-19 13:59:06.258: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 10ms
04-19 13:59:06.378: D/dalvikvm(26070): GC_CONCURRENT freed 271K, 5% free 8689K/9128K, paused 2ms+6ms, total 31ms
04-19 13:59:06.378: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 13ms
04-19 13:59:06.398: D/dalvikvm(26070): GC_FOR_ALLOC freed 283K, 8% free 8558K/9260K, paused 23ms, total 23ms
04-19 13:59:06.438: D/dalvikvm(26070): GC_FOR_ALLOC freed 303K, 8% free 8566K/9260K, paused 26ms, total 26ms
04-19 13:59:06.478: D/dalvikvm(26070): GC_FOR_ALLOC freed 325K, 8% free 8567K/9260K, paused 25ms, total 25ms
04-19 13:59:06.518: D/dalvikvm(26070): GC_FOR_ALLOC freed 304K, 8% free 8568K/9260K, paused 25ms, total 25ms
04-19 13:59:06.538: E/Google Maps Android API(26070): Failed to load map. Could not contact Google servers.
04-19 13:59:06.598: D/dalvikvm(26070): GC_CONCURRENT freed 381K, 8% free 8579K/9260K, paused 6ms+4ms, total 51ms
Did you check the correct services are enabled? Once I had a similar problem, and my issue was I accidentally enabled Google Maps API v2 in place of Google Maps Android API v2.
Please check that you are enabled the correct Google map API service for android, which is Google Maps Android API v2.
As it looks your problem is those two permissions:
<permission
android:name="com.example.cs2110_final.TheHunt.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.cs2110_final.permission.MAPS_RECEIVE" />
Which should be identical from the point of your package name, meaning if in one you wrote:
com.example.cs2110_final
which is your package name, then the second one should be the same, like that:
<permission
android:name="com.example.cs2110_final.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.cs2110_final.permission.MAPS_RECEIVE" />
In addition make sure you are following all the steps of producing your API key, you can follow this guide I wrote on this topic:
Google Maps API V2 Key
Another problem I see in your code is the fact that you min target API version 8 (android:minSdkVersion="8"), So you should use the SupportMapFragment and FragmentActivity and not MapFragment and a simple Activity as you are doing right now. But as far as my knowledge goes this doesn't have to do anything with the problem you are having right now.
Still you will have to change it, you can follow this guide I wrote to do that:
Google Maps API V2
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 am testing the sample google code on an actual device having 2.3.6.I thought it might be the problem with the key ,so I created different key on a different account through Google's API Console.Still the same problem "Google Maps Android API-Authorization Failure".
Here is the log:
12-07 10:31:30.476: D/dalvikvm(17791): DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
12-07 10:31:30.484: W/dalvikvm(17791): VFY: unable to resolve instance field 24
12-07 10:31:30.484: D/dalvikvm(17791): VFY: replacing opcode 0x52 at 0x0012
12-07 10:31:30.484: D/dalvikvm(17791): VFY: dead code 0x0014-0018 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (Landroid/content/res/Resources;)Z
12-07 10:31:30.718: D/dalvikvm(17791): GC_CONCURRENT freed 197K, 46% free 3063K/5639K, external 408K/517K, paused 3ms+4ms
12-07 10:31:30.789: W/dalvikvm(17791): Unable to resolve superclass of Lmaps/a/du; (411)
12-07 10:31:30.789: W/dalvikvm(17791): Link of class 'Lmaps/a/du;' failed
12-07 10:31:30.789: W/dalvikvm(17791): Unable to resolve superclass of Lmaps/a/ej; (2363)
12-07 10:31:30.789: W/dalvikvm(17791): Link of class 'Lmaps/a/ej;' failed
12-07 10:31:30.789: W/dalvikvm(17791): Unable to resolve superclass of Lmaps/j/k; (2379)
12-07 10:31:30.789: W/dalvikvm(17791): Link of class 'Lmaps/j/k;' failed
12-07 10:31:30.789: E/dalvikvm(17791): Could not find class 'maps.j.k', referenced from method maps.y.ae.a
12-07 10:31:30.789: W/dalvikvm(17791): VFY: unable to resolve new-instance 3571 (Lmaps/j/k;) in Lmaps/y/ae;
12-07 10:31:30.789: D/dalvikvm(17791): VFY: replacing opcode 0x22 at 0x007d
12-07 10:31:30.820: D/dalvikvm(17791): VFY: dead code 0x007f-008f in Lmaps/y/ae;.a (Landroid/view/LayoutInflater;Lcom/google/android/gms/maps/GoogleMapOptions;Z)Lmaps/y/ae;
12-07 10:31:31.281: D/dalvikvm(17791): GC_CONCURRENT freed 297K, 46% free 3222K/5959K, external 408K/517K, paused 3ms+4ms
12-07 10:31:31.523: D/dalvikvm(17791): GC_EXTERNAL_ALLOC freed 227K, 45% free 3397K/6087K, external 431K/517K, paused 52ms
12-07 10:31:31.648: I/System.out(17791): 0
12-07 10:31:31.734: D/dalvikvm(17791): GC_CONCURRENT freed 188K, 43% free 3531K/6151K, external 544K/1029K, paused 5ms+4ms
12-07 10:31:32.125: D/libEGL(17791): loaded /system/lib/egl/libGLES_hgl.so
12-07 10:31:32.132: D/BRCM_EGL(17791): eglCreateContext() context: 0xd7090, VC context 1, Thread 17810
12-07 10:31:32.148: D/BRCM_EGL(17791): eglCreateWindowSurface() surface: 0xd70d0, VC surface: 1, Thread: 17810
12-07 10:31:32.148: D/BRCM_EGL(17791): eglMakeCurrent(0xd7090, 0xd70d0, 0xd70d0) Thread: 17810
12-07 10:31:32.859: E/Google Maps Android API(17791): Authorization failure.
Here's is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.smartapps4u.googlemapslib"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<permission
android:name="com.smartapps4u.googlemapslib.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.smartapps4u.googlemapslib.permission.MAPS_RECEIVE"/>
<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.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-library android:name="com.google.android.maps" />
<application
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="My API key"/>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Any help would be appreciated.
Solved it.Very stupid mistake on my part.Used wrong api key.Was using the api key for the signed app.Replaced it with api key for debug keystore and solved the problem.
Had the same problem and #Sunkenglory 's answer is right, just to add some info for newbies like myself when I was looking for a solution.
On mac osX, my debug keystore was located here:
~/.android/debug.keystore
Go to that folder and run the following
keytool -list -v -keystore debug.keystore
That gave me the correct sha1 that I entered in the google console, and now it works.