致命信号11-每次退出android谷歌地图活动时崩溃
我在Android Studio中创建了一个带有谷歌地图活动的新测试应用程序。我所有的项目都是由向导创建的,唯一需要修改的文件是build.gradle,以修复一些版本号。我在模拟器中运行它(Google api level 19,android 4.4.2,x86系统映像),应用程序运行正常,api键正确,地图显示。但是,每当我退出活动(应用程序)时,它就会崩溃:致命信号11-每次退出android谷歌地图活动时崩溃,android,crash,google-maps-android-api-2,Android,Crash,Google Maps Android Api 2,我在Android Studio中创建了一个带有谷歌地图活动的新测试应用程序。我所有的项目都是由向导创建的,唯一需要修改的文件是build.gradle,以修复一些版本号。我在模拟器中运行它(Google api level 19,android 4.4.2,x86系统映像),应用程序运行正常,api键正确,地图显示。但是,每当我退出活动(应用程序)时,它就会崩溃: 10-02 20:55:21.550 8300-8375/android.example.com.map A/libc﹕ F
10-02 20:55:21.550 8300-8375/android.example.com.map A/libc﹕ Fatal signal 11 (SIGSEGV) at 0x006f0069 (code=1), thread 8375 (Thread-369)
10-02 20:55:21.680 931-931/? I/DEBUG﹕ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-02 20:55:21.680 931-931/? I/DEBUG﹕ Build fingerprint: 'generic_x86/google_sdk_x86/generic_x86:4.4.2/KK/1314097:eng/test-keys'
10-02 20:55:21.680 931-931/? I/DEBUG﹕ Revision: '0'
10-02 20:55:21.680 931-931/? I/DEBUG﹕ pid: 8300, tid: 8375, name: Thread-369 >>> android.example.com.map <<<
10-02 20:55:21.680 931-931/? I/DEBUG﹕ signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 006f0069
10-02 20:55:21.820 931-931/? I/DEBUG﹕ memory map around fault addr 006f0069:
10-02 20:55:21.820 931-931/? I/DEBUG﹕ (no map below)
10-02 20:55:21.820 931-931/? I/DEBUG﹕ (no map for address)
10-02 20:55:21.830 931-931/? I/DEBUG﹕ a4d68000-a4d81000 r-- /system/fonts/Roboto-Italic.ttf
10-02 20:55:21.870 1272-1294/system_process I/BootReceiver﹕ Copying /data/tombstones/tombstone_04 to DropBox (SYSTEM_TOMBSTONE)
10-02 20:55:21.880 934-934/? D/Zygote﹕ Process 8300 terminated by signal (11)
10-02 20:55:21.880 1272-1416/system_process I/ActivityManager﹕ Process android.example.com.map (pid 8300) has died.
MapsActivity.java:
package android.example.com.map;
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();
}
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"));
}
}
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=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
谷歌地图api.xml:
<resources>
<string name="google_maps_key_instructions" templateMergeStrategy="replace"></string>
<string name="google_maps_key" templateMergeStrategy="preserve">AIza...</string>
</resources>
艾扎。。。
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.example.com.map" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps" >
<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.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/google_maps_key" />
</application>
<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" />
</manifest>
我最近也遇到了同样的问题,但对我来说是由BluetoothSocket生成的:我当时正试图读取与套接字关联的InputStream,这时它已经关闭。像这样的硬崩溃表明设备或模拟器中存在错误,比您的代码中更严重。如果您没有使用NDK,那么Java级别上没有任何东西会导致SIGSEGV
。如果您可以创建一个复制错误的示例项目,那么您可能希望在“地图问题跟踪器”上提交一个bug。您可能还希望查看硬件是否崩溃,或者这是否只是模拟器的问题。我只是这样做了:如果其他人有类似的问题,请在那里添加详细信息,不要忘记单击星形图标以表明您也对重新解决的问题感兴趣
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.example.com.map" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps" >
<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.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/google_maps_key" />
</application>
<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" />
</manifest>