J
jameslover2014
Neues Mitglied
- 0
Wenn ich eine app im emulator öffne steht da immer: Unfotionally app stopped working. Ich habe keine ahnung. Ich würde mich sehr über antworten freuen. Danke schohn mal im vorraus.!!!!
Hir ist die LogCat:
MainActivity:
Android Manifest:
Hir ist die LogCat:
Code:
07-14 15:17:40.091: E/AndroidRuntime(1916): FATAL EXCEPTION: main 07-14 15:17:40.091: E/AndroidRuntime(1916): Process: com.example.testing, PID: 1916 07-14 15:17:40.091: E/AndroidRuntime(1916): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testing/com.example.testing.MainActivity}: java.lang.NullPointerException 07-14 15:17:40.091: E/AndroidRuntime(1916): at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2195) 07-14 15:17:40.091: E/AndroidRuntime(1916): at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2245) 07-14 15:17:40.091: E/AndroidRuntime(1916): at android.app.ActivityThread.access$800(ActivityThre ad.java:135) 07-14 15:17:40.091: E/AndroidRuntime(1916): at android.app.ActivityThread$H.handleMessage(Activit yThread.java:1196) 07-14 15:17:40.091: E/AndroidRuntime(1916): at android.os.Handler.dispatchMessage(Handler.java:10 2) 07-14 15:17:40.091: E/AndroidRuntime(1916): at android.os.Looper.loop(Looper.java:136) 07-14 15:17:40.091: E/AndroidRuntime(1916): at android.app.ActivityThread.main(ActivityThread.jav a:5017) 07-14 15:17:40.091: E/AndroidRuntime(1916): at java.lang.reflect.Method.invokeNative(Native Method) 07-14 15:17:40.091: E/AndroidRuntime(1916): at java.lang.reflect.Method.invoke(Method.java:515) 07-14 15:17:40.091: E/AndroidRuntime(1916): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:779) 07-14 15:17:40.091: E/AndroidRuntime(1916): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:595) 07-14 15:17:40.091: E/AndroidRuntime(1916): at dalvik.system.NativeStart.main(Native Method) 07-14 15:17:40.091: E/AndroidRuntime(1916): Caused by: java.lang.NullPointerException 07-14 15:17:40.091: E/AndroidRuntime(1916): at com.example.testing.MainActivity.onCreate(MainActi vity.java:36) 07-14 15:17:40.091: E/AndroidRuntime(1916): at android.app.Activity.performCreate(Activity.java:5 231) 07-14 15:17:40.091: E/AndroidRuntime(1916): at android.app.Instrumentation.callActivityOnCreate(I nstrumentation.java:1087) 07-14 15:17:40.091: E/AndroidRuntime(1916): at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2159) 07-14 15:17:40.091: E/AndroidRuntime(1916): ... 11 more
MainActivity:
Code:
package com.example.testing;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.os.Build;
public class MainActivity extends ActionBarActivity {
int counter;
Button buttonone, buttontwo;
TextView txt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
counter = 0;
buttonone = (Button) findViewById(R.id.button1);
buttontwo = (Button) findViewById (R.id.button2);
txt = (TextView) findViewById (R.id.textView1);
buttonone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter ++;
txt.setText(" " + counter);
}
});
buttontwo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter --;
txt.setText(" " + counter );
}
});
}
@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;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
return rootView;
}
}
}
Android Manifest:
<?
xml version="1.0" encoding="utf-8"?>
<
manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.testapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name= ".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name= ".Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.Menu" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</
manifest>
<?
xml version="1.0" encoding="utf-8"?>
<
manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.testapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name= ".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name= ".Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.Menu" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</
manifest>
Ich würde mich echt über jede Hilfe Freuen!!!