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
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 implemented ACRA using this
I have added code in my application, log is saying that report file is uploaded
here is the log :
05-04 11:38:02.890: D/dalvikvm(3171): GC_FOR_ALLOC freed 0K, 9% free 6508K/7111K, paused 18ms, total 18ms
05-04 11:38:02.900: D/ACRA(3171): About to start ReportSenderWorker from #handleException
05-04 11:38:02.900: D/ACRA(3171): Mark all pending reports as approved.
05-04 11:38:02.900: D/ACRA(3171): Looking for error files in /data/data/com.white.xspl.sonyjive/files
05-04 11:38:02.900: D/ACRA(3171): #checkAndSendReports - start
05-04 11:38:02.900: D/ACRA(3171): Looking for error files in /data/data/com.white.xspl.sonyjive/files
05-04 11:38:02.910: I/ACRA(3171): Sending file 1399183682000-approved.stacktrace
05-04 11:38:02.930: D/dalvikvm(3171): GC_FOR_ALLOC freed 83K, 9% free 6498K/7111K, paused 19ms, total 20ms
05-04 11:38:02.930: D/ACRA(3171): Waiting for Toast + worker...
05-04 11:38:02.970: D/dalvikvm(3171): GC_FOR_ALLOC freed 82K, 9% free 6484K/7111K, paused 20ms, total 20ms
05-04 11:38:03.000: D/dalvikvm(3171): GC_FOR_ALLOC freed 16K, 9% free 6531K/7111K, paused 20ms, total 20ms
05-04 11:38:03.000: I/dalvikvm-heap(3171): Grow heap (frag case) to 6.486MB for 65552-byte allocation
05-04 11:38:03.030: D/dalvikvm(3171): GC_FOR_ALLOC freed 76K, 10% free 6519K/7239K, paused 28ms, total 28ms
05-04 11:38:03.030: D/ACRA(3171): Connect to http://mylocal.ip/reportpath
05-04 11:38:03.120: D/dalvikvm(3171): GC_CONCURRENT freed 379K, 10% free 6535K/7239K, paused 23ms+2ms, total 52ms
05-04 11:38:03.120: D/dalvikvm(3171): WAIT_FOR_CONCURRENT_GC blocked 29ms
05-04 11:38:03.150: D/dalvikvm(3171): GC_FOR_ALLOC freed 77K, 11% free 6501K/7239K, paused 22ms, total 22ms
05-04 11:38:03.160: D/ACRA(3171): Sending request to http://mylocal.ip/reportpath
05-04 11:38:03.250: D/ACRA(3171): #checkAndSendReports - finish
05-04 11:38:03.350: D/ACRA(3171): Wait for Toast + worker ended. Kill Application ? true
Don't know what going wrong please help..
This is what i added in Manifest
<application
android:name=".MyAppication"
android:allowBackup="true"
android:icon="#drawable/appicon"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
here is my Class
public class MyAppications extends Application {
#Override
public void onCreate() {
// The following line triggers the initialization of ACRA
super.onCreate();
ACRA.init(this);
}
}
I think you need to look at your server.
ACRA says that it has sent the error report to http://mylocal.ip/reportpath
What does the server that is listening at that address say in its logs?
I am working with Google Maps v2 for Android.
I need to display some View over the map's marker, so I am updating its position every 16ms to keep 60fps.
And I got a problem with that code:
Point targetPosition = getMap().getProjection()
.toScreenLocation(mTrackingMarkerPos);
Because it seems that it causes explicitly calls to the System.gc() or Runtime.getRuntime().gc().
So I got this in log output:
03-12 15:00:24.362 19135-19135/my_fake_package_name D/dalvikvm﹕ GC_EXPLICIT freed 122K, 10% free 12710K/14116K, paused 11ms+11ms, total 115ms
03-12 15:00:25.583 19135-19135/my_fake_package_name D/dalvikvm﹕ GC_EXPLICIT freed 123K, 10% free 12711K/14116K, paused 7ms+4ms, total 100ms
03-12 15:00:26.845 19135-19135/my_fake_package_name D/dalvikvm﹕ GC_EXPLICIT freed 123K, 10% free 12711K/14116K, paused 11ms+6ms, total 104ms
03-12 15:00:28.056 19135-19135/my_fake_package_name D/dalvikvm﹕ GC_EXPLICIT freed 217K, 10% free 12710K/14116K, paused 11ms+5ms, total 98ms
03-12 15:00:29.287 19135-19135/my_fake_package_name D/dalvikvm﹕ GC_EXPLICIT freed 121K, 10% free 12712K/14116K, paused 11ms+7ms, total 112ms
03-12 15:00:30.499 19135-19135/my_fake_package_name D/dalvikvm﹕ GC_EXPLICIT freed 123K, 10% free 12712K/14116K, paused 7ms+4ms, total 87ms
03-12 15:00:31.760 19135-19135/my_fake_package_name D/dalvikvm﹕ GC_EXPLICIT freed 126K, 10% free 12711K/14116K, paused 7ms+4ms, total 130ms
As you can see, GC_EXPLICIT can pause my app for about 100ms!
So my approach to keep 60fps is not achievable because of Google Maps v2 :(
If I comment that line, GC_EXPLICIT calls will disappear. I think that problem in Google Maps v2, I checked their .class files but I did not find any calls to System.gc, so may be I am wrong...
If you know how to find call to the System.gc() I will be glad to know it too, or guys from Google can help me with this issue?
P.S. Asked this on gmaps-api-issues: https://code.google.com/p/gmaps-api-issues/issues/detail?id=6483&thanks=6483&ts=1394624273
I want to receive updates from GPS, but i can't. Method onLocationChanged isn't calling. In this application i using Google Maps API, too. I don't know, maybe it is some cause of my problems.
It's code about GPS in MainActivity:
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location)
{
txtLat.setText("Latitude: " + String.valueOf((int)(location.getLatitude())) + ","
+ String.valueOf(((location.getLatitude() * 100) % 100)) + " degrees");
txtLong.setText("Longtitude: " + String.valueOf((int)(location.getLongitude())) + ","
+ String.valueOf(((location.getLongitude() * 100) % 100)) + " degrees");
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
and in Manifest i have declared these permissions:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
and other that Google Maps API v2 required
EDIT:
LogCat:
06-27 14:25:28.785: D/dalvikvm(5206): GC_FOR_ALLOC freed 42K, 8% free 2500K/2716K, paused 42ms, total 48ms
06-27 14:25:28.836: I/dalvikvm-heap(5206): Grow heap (frag case) to 6.147MB for 3712016-byte allocation
06-27 14:25:28.906: D/dalvikvm(5206): GC_FOR_ALLOC freed 2K, 4% free 6122K/6344K, paused 64ms, total 64ms
06-27 14:25:28.965: D/dalvikvm(5206): GC_CONCURRENT freed <1K, 4% free 6122K/6344K, paused 8ms+5ms, total 66ms
06-27 14:25:29.595: D/dalvikvm(5206): GC_CONCURRENT freed 3766K, 53% free 3523K/7464K, paused 24ms+46ms, total 149ms
06-27 14:25:30.025: D/dalvikvm(5206): GC_CONCURRENT freed 243K, 51% free 3681K/7464K, paused 5ms+5ms, total 52ms
06-27 14:25:30.045: E/Google Maps Android API(5206): Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above
06-27 14:25:30.385: D/dalvikvm(5206): GC_FOR_ALLOC freed 146K, 49% free 3826K/7464K, paused 39ms, total 40ms
06-27 14:25:30.685: D/dalvikvm(5206): GC_CONCURRENT freed 82K, 44% free 4234K/7464K, paused 16ms+26ms, total 133ms
06-27 14:25:31.066: D/libEGL(5206): Emulator without GPU support detected. Fallback to software renderer.
06-27 14:25:31.095: I/Choreographer(5206): Skipped 77 frames! The application may be doing too much work on its main thread.
06-27 14:25:31.115: D/libEGL(5206): loaded /system/lib/egl/libGLES_android.so
06-27 14:25:31.175: D/gralloc_goldfish(5206): Emulator without GPU emulation detected.
06-27 14:25:31.819: D/dalvikvm(5206): GC_CONCURRENT freed 402K, 41% free 4428K/7464K, paused 30ms+60ms, total 386ms
06-27 14:25:31.915: D/dalvikvm(5206): WAIT_FOR_CONCURRENT_GC blocked 428ms
06-27 14:25:32.427: D/dalvikvm(5206): GC_CONCURRENT freed 630K, 41% free 4429K/7464K, paused 31ms+18ms, total 100ms
06-27 14:25:32.427: D/dalvikvm(5206): WAIT_FOR_CONCURRENT_GC blocked 59ms
06-27 14:33:03.695: E/Trace(5381): error opening trace file: No such file or directory (2)
06-27 14:33:04.395: D/dalvikvm(5381): GC_FOR_ALLOC freed 46K, 9% free 2500K/2720K, paused 42ms, total 45ms
06-27 14:33:04.435: I/dalvikvm-heap(5381): Grow heap (frag case) to 6.147MB for 3712016-byte allocation
06-27 14:33:04.485: D/dalvikvm(5381): GC_FOR_ALLOC freed 2K, 4% free 6122K/6348K, paused 43ms, total 44ms
06-27 14:33:04.555: D/dalvikvm(5381): GC_CONCURRENT freed <1K, 4% free 6122K/6348K, paused 5ms+5ms, total 70ms
06-27 14:33:05.235: D/dalvikvm(5381): GC_CONCURRENT freed 3774K, 53% free 3500K/7448K, paused 20ms+84ms, total 157ms
06-27 14:33:05.615: D/dalvikvm(5381): GC_CONCURRENT freed 232K, 51% free 3663K/7448K, paused 72ms+5ms, total 118ms
06-27 14:33:05.645: E/Google Maps Android API(5381): Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above
06-27 14:33:05.875: D/dalvikvm(5381): GC_FOR_ALLOC freed 190K, 49% free 3847K/7448K, paused 39ms, total 40ms
06-27 14:33:06.268: D/dalvikvm(5381): GC_CONCURRENT freed 62K, 44% free 4223K/7448K, paused 71ms+77ms, total 284ms
06-27 14:33:06.815: D/libEGL(5381): Emulator without GPU support detected. Fallback to software renderer.
06-27 14:33:06.865: D/libEGL(5381): loaded /system/lib/egl/libGLES_android.so
06-27 14:33:06.906: I/Choreographer(5381): Skipped 120 frames! The application may be doing too much work on its main thread.
06-27 14:33:07.005: D/gralloc_goldfish(5381): Emulator without GPU emulation detected.
06-27 14:33:07.455: I/Choreographer(5381): Skipped 38 frames! The application may be doing too much work on its main thread.
06-27 14:33:07.545: D/dalvikvm(5381): GC_CONCURRENT freed 381K, 41% free 4427K/7448K, paused 8ms+111ms, total 349ms
06-27 14:33:07.545: D/dalvikvm(5381): WAIT_FOR_CONCURRENT_GC blocked 237ms
06-27 14:33:08.246: D/dalvikvm(5381): GC_CONCURRENT freed 630K, 41% free 4430K/7448K, paused 72ms+7ms, total 171ms
06-27 14:33:08.246: D/dalvikvm(5381): WAIT_FOR_CONCURRENT_GC blocked 32ms
If you're attempting to retrieve the location using the GPS provider, and you're inside a building or have lousy GPS reception, the onLocationChanged will never be called.
There will be no automatic fallback to Wifi or celltower.
Always check what kind of provider you are using, even when specifying criteria.
Google has released a bunch of new Location APIs through Google Play Services that offers more efficient ways of retrieving user location (improving accuracy and battery-life).
I suggest you take a look at those and follow the Retrieving the Current Location tutorial (it includes a sample app that you can download).
Can someone explain this error?
"SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length".
I think it concerns with editText. Is there a solution for it?
This is my log.
1-07 14:29:47.654: D/OpenGLRenderer(24479): Enabling debug mode 0
01-07 14:30:36.954: E/SensorManager(24479): thread start
01-07 14:30:36.959: D/SensorManager(24479): registerListener :: handle = 0 name= LSM330DLC 3-axis Accelerometer delay= 200000 Listener=
android.view.OrientationEventListener$SensorEventListenerImpl#43000e98
01-07 14:30:37.139: E/SpannableStringBuilder(24479): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
01-07 14:30:37.139: E/SpannableStringBuilder(24479): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
01-07 14:30:37.419: I/Process(24479): Sending signal. PID: 24479 SIG: 9
01-07 14:30:37.654: E/Trace(25014): error opening trace file: No such file or directory (2)
01-07 14:30:37.754: D/dalvikvm(25014): GC_FOR_ALLOC freed 108K, 6% free 12258K/12931K, paused 15ms, total 16ms
01-07 14:30:37.754: I/dalvikvm-heap(25014): Grow heap (frag case) to 14.860MB for 2457616-byte allocation
01-07 14:30:37.779: D/dalvikvm(25014): GC_CONCURRENT freed 6K, 5% free 14651K/15367K, paused 12ms+2ms, total 23ms
01-07 14:30:37.809: D/dalvikvm(25014): GC_FOR_ALLOC freed 0K, 5% free 14651K/15367K, paused 11ms, total 11ms
01-07 14:30:37.819: I/dalvikvm-heap(25014): Grow heap (frag case) to 19.018MB for 4367376-byte allocation
01-07 14:30:37.834: D/dalvikvm(25014): GC_CONCURRENT freed 0K, 4% free 18917K/19655K, paused 2ms+2ms, total 16ms
01-07 14:30:37.834: D/dalvikvm(25014): WAIT_FOR_CONCURRENT_GC blocked 3ms
01-07 14:30:37.894: D/dalvikvm(25014): GC_FOR_ALLOC freed 2660K, 17% free 17674K/21063K, paused 13ms, total 13ms
01-07 14:30:37.909: D/dalvikvm(25014): GC_FOR_ALLOC freed 688K, 14% free 18212K/21063K, paused 10ms, total 10ms
01-07 14:30:37.944: D/dalvikvm(25014): GC_FOR_ALLOC freed <1K, 11% free 18890K/21063K, paused 12ms, total 12ms
01-07 14:30:37.949: I/dalvikvm-heap(25014): Grow heap (frag case) to 20.170MB for 1235556-byte allocation
01-07 14:30:37.964: D/dalvikvm(25014): GC_FOR_ALLOC freed 0K, 10% free 20097K/22279K, paused 11ms, total 11ms
01-07 14:30:38.019: D/libEGL(25014): loaded /system/lib/egl/libEGL_mali.so
01-07 14:30:38.024: D/libEGL(25014): loaded /system/lib/egl/libGLESv1_CM_mali.so
01-07 14:30:38.024: D/libEGL(25014): loaded /system/lib/egl/libGLESv2_mali.so
01-07 14:30:38.029: D/(25014): Device driver API match
01-07 14:30:38.029: D/(25014): Device driver API version: 10
01-07 14:30:38.029: D/(25014): User space API version: 10
01-07 14:30:38.029: D/(25014): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Fri Sep 28
10:42:56 KST 2012
01-07 14:30:38.064: D/OpenGLRenderer(25014): Enabling debug mode 0
Just add this property to your edit text and your problem will definitely be resolved
android:inputType="textNoSuggestions"
Add the above property to each of your edit text used in the application, or simply where you get the error in that edit text only.
It's probably because you are using 3rd party keyboard instead of the native phone keyboard.
This often happens with SwiftKey.
Just ignore them. Its because your OS might have had some new keyboards like Swype, or some other customized keyboards, and these kind of things come popping up. So you don't have to worry.
Check if you have any element such as button or text view duplicated (copied twice) in the activity xml file that corresponds to the screen where this encounters. I did this unnoticed and had to face the same issue.
Add the android:textIsSelectable="false" in editText
For example
<EditText
android:id="#+id/edit_IONumber"
android:layout_width="0dp"
android:layout_weight="3"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:textIsSelectable="false"
android:layout_height="wrap_content"
android:background="#drawable/edit_text_shape"
android:padding="5dip" />