java抛出运行时异常

时间:2013-07-22 22:09:28

标签: android google-maps android-fragments runtimeexception

 Thread [<1> main] (Suspended (exception RuntimeException)) 
<VM does not provide monitor information>   
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2180    
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2230 
ActivityThread.access$600(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 141    
ActivityThread$H.handleMessage(Message) line: 1234  
ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
Looper.loop() line: 137 
ActivityThread.main(String[]) line: 5041    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
Method.invoke(Object, Object...) line: 511  
ZygoteInit$MethodAndArgsCaller.run() line: 793  
ZygoteInit.main(String[]) line: 560 
NativeStart.main(String[]) line: not available [native method]  

我不知道为什么它甚至无法启动活动。

这是正在推出的活动

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

 public class GymFind extends FragmentActivity {

private final LatLng LOCATION_BURNABY = new LatLng(49.27645, -122.917587);
private final LatLng LOCATION_SURRREY = new LatLng(49.187500, -122.849000);
private GoogleMap map;

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.gmaps);


      map  = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

      map.addMarker(new MarkerOptions().position(LOCATION_BURNABY).title("Find us here!"));
      map.addMarker(new MarkerOptions().position(LOCATION_SURREY).title("Find us here!"));
      map.addMarker(new 

final int RQS_GooglePlayServices = 1;
@Override
 protected void onResume() {
  // TODO Auto-generated method stub
  super.onResume();

  int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());

  if (resultCode == ConnectionResult.SUCCESS){
   Toast.makeText(getApplicationContext(), 
     "isGooglePlayServicesAvailable SUCCESS", 
     Toast.LENGTH_LONG).show();
  }else{
   GooglePlayServicesUtil.getErrorDialog(resultCode, this, RQS_GooglePlayServices);
  }

 }


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

 }

这是从

启动活动的地方
  import android.app.Activity;
  import android.os.Bundle;
  import android.widget.Button;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.content.Intent;


   public class Home extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);

     setContentView(R.layout.homie);

     Button button1 = (Button) findViewById(R.id.button1);

     Button button2 = (Button) findViewById(R.id.button2);

     button1.setOnClickListener(new OnClickListener() {
         public void onClick(View v) {

             Intent i = new Intent(Home.this,GymFind.class);
             Home.this.startActivity(i);

         }
     });
     button2.setOnClickListener(new OnClickListener() {
         public void onClick(View v) {

             Intent i = new Intent(Home.this,EmailUs.class);
             Home.this.startActivity(i);


         }
     });
 }
   }

我非常怀疑自己会不会这样做但是如果你们愿意帮助我会非常开心。

1 个答案:

答案 0 :(得分:0)

堆栈跟踪应该在底部包含“由...引起”...或者如果您在调试器中查看它,则应该有一个“cause”变量或类似的东西。我建议只是让它崩溃,然后检查android日志 - 它肯定会打印日志中堆栈跟踪下的“由...引起的”。

问题是Android无法启动您的活动。最常见的原因是: 1.您尚未在AndroidManifest.xml中声明该活动 2. onCreate(或其他覆盖方法)中的代码抛出异常 检查你的“引起的”,你会找到确切的原因。