我正在开发一个应用程序,每当我尝试访问该位置时,我都会收到异常。我查看了其他答案,并且始终要么他们要么没有将位置权限放在清单文件中,要么拼写错误。但是,在复制并粘贴这些示例的几个部分之后,我仍然遇到同样的问题。它在以下功能中。
public void startLocationUpdates()
{
try
{
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
int a = 0;
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
这是我的整个AndroidManifest.xml文件,因为我可能会将权限标记放在错误的位置。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sample.app" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".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>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>
编辑: 我对Android Studio界面并不熟悉,所以我不确定我应该放置哪些LogCat部分。但是,以下情况不断涌现。
09-30 13:58:47.974 1274-1287/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
09-30 13:58:48.989 1274-1287/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
09-30 13:58:49.429 1274-1287/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
09-30 13:58:50.722 1274-1287/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
09-30 13:58:50.807 1274-1287/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
09-30 13:58:50.810 1274-1287/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
09-30 13:58:50.921 1274-1287/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
09-30 13:58:50.924 1274-1287/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
09-30 13:58:50.927 1274-1287/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
09-30 13:58:50.931 1274-1287/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
09-30 13:58:50.932 1274-1287/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
这对任何人都意味着什么吗?
- 编辑 更新以显示拼写错误的“权限”不是原因。 -编辑 这是“信息”日志文件。它是在模拟的Nexus 4上运行的。我正在使用模拟器,因为我的手机有问题,但如果你们真的认为这是问题,我可以买另一部手机。是的,wifi和gps在模拟设备上打开。
10-01 10:09:35.609 1296-1309/system_process W/GpsLocationProvider﹕ Could not open GPS configuration file /etc/gps.conf
10-01 10:09:35.610 1296-1309/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
10-01 10:09:36.587 1296-1309/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
10-01 10:09:40.549 1296-1309/system_process W/GpsLocationProvider﹕ Could not open GPS configuration file /etc/gps.conf
10-01 10:09:40.549 1296-1309/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
10-01 10:09:40.550 1296-1309/system_process W/GpsLocationProvider﹕ Could not open GPS configuration file /etc/gps.conf
10-01 10:09:40.550 1296-1309/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
10-01 10:09:40.551 1296-1309/system_process W/GpsLocationProvider﹕ Could not open GPS configuration file /etc/gps.conf
10-01 10:09:40.551 1296-1309/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
10-01 10:09:40.572 1296-1309/system_process W/GpsLocationProvider﹕ Could not open GPS configuration file /etc/gps.conf
10-01 10:09:40.572 1296-1309/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
10-01 10:09:40.576 1296-1309/system_process W/GpsLocationProvider﹕ Could not open GPS configuration file /etc/gps.conf
10-01 10:09:40.576 1296-1309/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
10-01 10:09:40.577 1296-1309/system_process W/GpsLocationProvider﹕ Could not open GPS configuration file /etc/gps.conf
10-01 10:09:40.577 1296-1309/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
10-01 10:09:41.400 1296-1309/system_process W/GpsLocationProvider﹕ Could not open GPS configuration file /etc/gps.conf
10-01 10:09:41.400 1296-1309/system_process E/GpsLocationProvider﹕ no AGPS interface in set_agps_server
它并没有真正给我一个堆栈跟踪。在Exception对象中,这是堆栈跟踪的值: java.lang.StackTraceElement中[0] @ 4145