Android 地图的棉花糖碎片活动崩溃
我正在使用fragmentActivity进行映射。在Java类中,setContentView出现错误。我的Mapscreen.java是这样的:它在一些只显示棉花糖崩溃的设备上运行良好。或者还有其他原因吗Android 地图的棉花糖碎片活动崩溃,android,google-maps,android-fragmentactivity,Android,Google Maps,Android Fragmentactivity,我正在使用fragmentActivity进行映射。在Java类中,setContentView出现错误。我的Mapscreen.java是这样的:它在一些只显示棉花糖崩溃的设备上运行良好。或者还有其他原因吗 public class MapScreen extends FragmentActivity implements LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFai
public class MapScreen extends FragmentActivity implements LocationListener,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_screen);
....
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
googleMap = fm.getMap();
}
and my xml has fragment using SupportMapFragment as well. map_screen.xml is like :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
<ImageView
android:id="@+id/startActivityButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="44dp"
android:background="@drawable/end_meetup_btn"
/>
</RelativeLayout>
问题出在“Micro max Android one mobile”上,它是6.0棉花糖。
此设备没有足够的内部或外部内存空间。甚至没有SD卡
以下是乔治的回答:
我安装了存储卡,现在崩溃不来了
所以我发现问题出在更新的谷歌播放服务上,它需要的空间(更新的谷歌照片)在我的设备上是不够的
还有一行错误显示“由以下原因引起:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法'boolean java.io.File.mkdir()”
我决定在安装SD卡后进行检查。它成功了
<!-- EXTERNAL_STORAGE permissions are optional for Android 6.0 onwards. -->
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="22" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="22" />
将此添加到您的清单中。也许“地图”需要SD卡权限才能进行额外的缓存或其他操作。这只是我做的一个变通方法。如果下面的检查失败,我将加载一个带有错误的片段,而不是加载映射
/** Checks if external storage is available for read and write */
public boolean isExternalStorageWritable() {
String state = Environment.getExternalStorageState();
return Environment.MEDIA_MOUNTED.equals(state);
}
将SD卡权限添加到清单文件
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
/>
该问题已在Google Play Services library 9.0.83版中修复。您在清单中指定了什么?这是一个多么大的错误!是的,你是对的。我在micromax AQ4509I上遇到了同样的问题,我想捕获此错误并向最终用户显示一条消息以插入SD卡。
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
/>