ActivityThread.performLaunchActivity Quelle nicht gefunden
sorry, ich verstehe nicht, warum meine app abstürzt, habe ich eine Tätigkeit mit einer mapfragment und eine Schaltfläche, so ist es sehr einfach, aber wenn ich das starten der app stürzt Sie ab und logcat sendet mir diese Fehlermeldung:
07-29 15:32:18.678: E/AndroidRuntime(6806): FATAL EXCEPTION: main
07-29 15:32:18.678: E/AndroidRuntime(6806): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.frank.nuova/com.frank.nuova.Online}: java.lang.NullPointerException
07-29 15:32:18.678: E/AndroidRuntime(6806): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-29 15:32:18.678: E/AndroidRuntime(6806): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-29 15:32:18.678: E/AndroidRuntime(6806): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-29 15:32:18.678: E/AndroidRuntime(6806): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-29 15:32:18.678: E/AndroidRuntime(6806): at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 15:32:18.678: E/AndroidRuntime(6806): at android.os.Looper.loop(Looper.java:137)
07-29 15:32:18.678: E/AndroidRuntime(6806): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-29 15:32:18.678: E/AndroidRuntime(6806): at java.lang.reflect.Method.invokeNative(Native Method)
07-29 15:32:18.678: E/AndroidRuntime(6806): at java.lang.reflect.Method.invoke(Method.java:511)
07-29 15:32:18.678: E/AndroidRuntime(6806): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-29 15:32:18.678: E/AndroidRuntime(6806): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-29 15:32:18.678: E/AndroidRuntime(6806): at dalvik.system.NativeStart.main(Native Method)
07-29 15:32:18.678: E/AndroidRuntime(6806): Caused by: java.lang.NullPointerException
07-29 15:32:18.678: E/AndroidRuntime(6806): at com.frank.nuova.Online.onCreate(Online.java:51)
07-29 15:32:18.678: E/AndroidRuntime(6806): at android.app.Activity.performCreate(Activity.java:5104)
07-29 15:32:18.678: E/AndroidRuntime(6806): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-29 15:32:18.678: E/AndroidRuntime(6806): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-29 15:32:18.678: E/AndroidRuntime(6806): ... 11 more
manifest ist ok, ich habe bereits alle Berechtigungen und API-key...ich versuche auch zu debug-app und geben Sie mir auf den ersten Schritt
ActivityThread.performLaunchActivity Quelle nicht gefunden
und zweiten Schritt
ZygoteInit$MethodAndArgsCaller.run() line: 799 source not found
ich verstehe nicht, warum mir dieser Fehler, und was ist dieser Fehler?
dies ist mein code
package com.frank.nuova;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
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.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Online extends FragmentActivity {
GoogleMap map;
Gps s;
DataSource db;
MyOpenHelper o;
LatLng adesso;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
o=new MyOpenHelper(getApplicationContext());
db=new DataSource(o);
try{
o.createDataBase();
}catch(IOException e){
e.printStackTrace();
}
try{
o.openDataBase();
}catch(SQLException e){
e.printStackTrace();
}
double lon;
double lat;
s=new Gps(getApplicationContext());
s.getLocation();
lon=s.longitudine();
lat=s.latitudine();
adesso=new LatLng(lat, lon);
map=((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.mappa)).getMap();
Marker posizione=map.addMarker(new MarkerOptions().position(adesso).title("Sei Qui"));
Button b=(Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//TODO Auto-generated method stub
List<Coordinate> b=db.vicino_online(adesso, db.vediCoordinate());
Marker[]a=new Marker[b.size()];
for(int i=0;i<a.length;i++){
String linea=b.get(i).getLinea()+"-"+b.get(i).getVia();
a[i]=map.addMarker(new MarkerOptions().position(new LatLng(b.get(i).getLatitudine(), b.get(i).getLongitudine())).title(linea));
}
}
});
}
@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;
}
}
ich auch versuchen if(map==null)
vor instatiate GoogleMap, aber ich habe denselben Fehler...
code :
package com.frank.nuova;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
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.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Online extends FragmentActivity {
GoogleMap map;
Gps s;
DataSource db;
MyOpenHelper o;
LatLng adesso;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
o=new MyOpenHelper(getApplicationContext());
db=new DataSource(o);
try{
o.createDataBase();
}catch(IOException e){
e.printStackTrace();
}
try{
o.openDataBase();
}catch(SQLException e){
e.printStackTrace();
}
double lon;
double lat;
s=new Gps(getApplicationContext());
s.getLocation();
lon=s.longitudine();
lat=s.latitudine();
adesso=new LatLng(lat, lon);
map=((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mappa)).getMap();
Button b=(Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//TODO Auto-generated method stub
List<Coordinate> b=db.vicino_online(adesso, db.vediCoordinate());
Marker[]a=new Marker[b.size()];
for(int i=0;i<a.length;i++){
String linea=b.get(i).getLinea()+"-"+b.get(i).getVia();
a[i]=map.addMarker(new MarkerOptions().position(new LatLng(b.get(i).getLatitudine(), b.get(i).getLongitudine())).title(linea));
}
}
});
}
@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;
}
}
Logcat:
07-30 11:02:16.289: E/AndroidRuntime(23018): FATAL EXCEPTION: main
07-30 11:02:16.289: E/AndroidRuntime(23018): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.frank.nuova/com.frank.nuova.Online}: java.lang.NullPointerException
07-30 11:02:16.289: E/AndroidRuntime(23018): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-30 11:02:16.289: E/AndroidRuntime(23018): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-30 11:02:16.289: E/AndroidRuntime(23018): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-30 11:02:16.289: E/AndroidRuntime(23018): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-30 11:02:16.289: E/AndroidRuntime(23018): at android.os.Handler.dispatchMessage(Handler.java:99)
07-30 11:02:16.289: E/AndroidRuntime(23018): at android.os.Looper.loop(Looper.java:137)
07-30 11:02:16.289: E/AndroidRuntime(23018): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-30 11:02:16.289: E/AndroidRuntime(23018): at java.lang.reflect.Method.invokeNative(Native Method)
07-30 11:02:16.289: E/AndroidRuntime(23018): at java.lang.reflect.Method.invoke(Method.java:511)
07-30 11:02:16.289: E/AndroidRuntime(23018): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-30 11:02:16.289: E/AndroidRuntime(23018): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-30 11:02:16.289: E/AndroidRuntime(23018): at dalvik.system.NativeStart.main(Native Method)
07-30 11:02:16.289: E/AndroidRuntime(23018): Caused by: java.lang.NullPointerException
07-30 11:02:16.289: E/AndroidRuntime(23018): at com.frank.nuova.Online.onCreate(Online.java:49)
07-30 11:02:16.289: E/AndroidRuntime(23018): at android.app.Activity.performCreate(Activity.java:5104)
07-30 11:02:16.289: E/AndroidRuntime(23018): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-30 11:02:16.289: E/AndroidRuntime(23018): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-30 11:02:16.289: E/AndroidRuntime(23018): ... 11 more
Layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/prima"
android:textAppearance="?android:attr/textAppearanceLarge" />
<fragment
android:id="@+id/mappa"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="260dp" />
<Button
android:id="@+id/button1"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:text="@string/premi" />
</LinearLayout>
- Lesen Sie Ihre stacktrace wieder. der eigentliche Fehler (der mit der Codierung beteiligt) ist
java.lang.NullPointerException 07-29 15:32:18.678: E/AndroidRuntime(6806): at com.frank.nuova.Online.onCreate(Online.java:51)
- also Fehler ist instatiate GoogleMap-aber warum? in einer anderen app funktioniert dies
- können Sie Ihre aktuelle code? was du gepostet hast kann nicht die Ursache des Problems genauen stacktrace (Linie 51 nicht dazu führen, dass eine NPE).
- du wirst post haben das layout sowie.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Haben Sie
NullPointerException
beib.setOnClickListener
,stellen Sie sicher, Sie haben
Button
mitbutton1
id inactivity_main
layout