我found由于某些Native crash,应用程序因没有logcat条目而崩溃。与在Android Studio 2.3.3中一样,logcat默认设置了详细和无过滤器选项:那么解决本机崩溃的方法是什么?识别这些崩溃?
我的应用程序在打开MapsActivity
两次以上时崩溃,即第三次(编辑:现在第四次)点击打开使其崩溃。
这是MapsActivity
我从Location List
收到MainActivity
并在地图上添加标记。
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.location.Location;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.UiSettings;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
ArrayList<Location> locs = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
Bundle bundle = getIntent().getExtras();
String jsonString = bundle.getString("KEY_LOCATIONS");
Gson gson = new Gson();
Type listOfLocationType = new TypeToken<List<Location>>() {
}.getType();
locs = gson.fromJson(jsonString, listOfLocationType);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
setUpMap();
}
public void setUpMap() {
mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;}
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(true);
mMap.getUiSettings().setCompassEnabled(true);
addMarkeratLocation();
}
public void addMarkeratLocation() {
int i;
double lt=0.0,lg=0.0;
BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.mipmap.dottt);
LatLng addpoint = new LatLng(0.0, 0.0);
for (i = 0; i < locs.size(); i++) {
lt=locs.get(i).getLatitude();
lg=locs.get(i).getLongitude();
addpoint = new LatLng(lt,lg );
mMap.addMarker(new MarkerOptions().position(addpoint).icon(icon));
}
mMap.moveCamera(CameraUpdateFactory.newLatLng(addpoint));
LatLng camloc= new LatLng(lt,lg);
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(camloc, 15));
}
}
这是MainActivity
MapsActivity
被解雇的地方。
direction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getBaseContext(), "Showing directions", Toast.LENGTH_LONG).show();
TinyDB tinydb = new TinyDB(MainActivity.this);
olati=tinydb.getDouble("destination_lati",lati);
olongi=tinydb.getDouble("destination_longi",longi);
Gson gson = new Gson();
String jsonString = gson.toJson(locs);
Intent intent = new Intent(MainActivity.this,MapsActivity.class);
intent.putExtra("KEY_LOCATIONS",jsonString);
startActivity(intent);
}
});
我不知道Logt会发布什么。我该如何解决?提前谢谢。
编辑:添加了错误Logcat
这是应用程序崩溃的地方
12-06 00:12:06.190 18296-18307 / com.example.acer.mylocationmap A / libc:致命信号11(SIGSEGV),代码1,故障地址0x40 in tid 18307(FinalizerDaemon) 12-06 00:12:07.800 3624-3624 /? E / audit:type = 1701 msg = audit(1512499327.795:2175):auid = 4294967295 uid = 10495 gid = 10495 ses = 4294967295 subj = u:r:untrusted_app:s0 pid = 18307 comm =“FinalizerDaemon”reason =“memory violation” “sig = 11 12-06 00:12:07.845 2845-20348 /? E / android.os.Debug:ro.product_ship = true 12-06 00:12:07.845 2845-20348 /? E / android.os.Debug:ro.debug_level = 0x4f4c 12-06 00:12:07.930 2845-2925 /? E / InputDispatcher:channel~频道无法恢复,将被处理掉! 12-06 00:12:07.930 2845-2925 /? E / InputDispatcher:channel~频道无法恢复,将被处理掉! 12-06 00:12:07.990 20349-20349 /? E / Zygote:MountEmulatedStorage() 12-06 00:12:07.990 20349-20349 /? E / Zygote:v2 12-06 00:12:07.995 20349-20349 /? E / Zygote:accessInfo:0 12-06 00:12:07.995 20349-20349 /? E / SELinux:[DEBUG] get_category:变量seinfo:默认灵敏度:NULL,cateogry:NULL 12-06 00:12:15.020 2845-2889 /? E / ViewRootImpl:sendUserActionEvent()mView == null
答案 0 :(得分:0)
检查构建变量在build.gradle文件中将debug设置为true
在应用程序的发布版本中,这通常设置为false,因为它是发布到Play商店的必要条件。