2013-07-22 93 views
-1
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] 

我不知道为什么它甚至不能启动活动。java抛出运行时异常

这是正在启动

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); 


     } 
    }); 
} 
    } 

我很怀疑我将永远得到这个工作,推出的活动,但是,如果你们想帮助我真的很开心。

回答

0

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

问题是Android无法启动您的活动。最常见的原因是: 1.您尚未在您的AndroidManifest.xml中声明该活动 2.您在onCreate(或其他重写方法)中的代码发生异常 检查您的“原因”,您会发现确切的原因。

+0

引起:java.lang.ClassCastException:com.google.android.gms.maps.MapFragment无法转换为android.support.v4.app.Fragment这是什么意思? –

+0

啊,这是因为Fragment类有两个版本:一个来自Android SDK(android.app.Fragment),另一个来自Android支持库(android.support.v4.app.Fragment)。请参阅http://developer.android.com/tools/extras/support-library.html#Using我猜Maps SDK不支持支持库?或者也许有一个不同版本的片段呢?我从来没有用过它,所以我不知道。最终的原因是你使用FragmentActivity,它希望它的片段是支持库版本。 –

+0

非常感谢你的帮助到目前为止,但一旦我修复,我得到一个空指针异常引起:java.lang.NullPointerException \t at GymFind.onCreate(GymFind.java:35) \t at android.app.Activity。 (Activity.java:2104) \t at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) –