Thursday, 15 August 2013

Unfortunately app stopped due to null ponter exception

Unfortunately app stopped due to null ponter exception

Trying to integrate facebook sdk to android app.but my application is not
starting .unfotunately app stoped error i showing.from logs i understood
it is due to null pointer exception.but didn't find the exact problem
.here i am placing the logs.suggest me how to find the error causing line
and how to fix this error.Thanks.`public class MainActivity extends
Activity {
String APP_ID = "307128189431829"; // Replace your App ID
// here
// Instance of Facebook Class
private Facebook facebook;
Button btnFbLogin = (Button) findViewById(R.id.button1);
Button postToWall = (Button) findViewById(R.id.button2);
@SuppressWarnings({ "deprecation", "unused" })
private AsyncFacebookRunner mAsyncRunner;
String FILENAME = "AndroidSSO_data";
@SuppressWarnings("unused")
private SharedPreferences mPrefs;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
postToWall.getHandler().post(new Runnable() {
public void run() {
postToWall.setVisibility(View.INVISIBLE);
}
});
facebook = new Facebook(APP_ID);
mAsyncRunner = new AsyncFacebookRunner(facebook);
btnFbLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loginToFacebook();
btnFbLogin.getHandler().post(new Runnable() {
public void run() {
btnFbLogin.setVisibility(View.INVISIBLE);
}
});
postToWall.getHandler().post(new Runnable() {
public void run() {
postToWall.setVisibility(View.VISIBLE);
}
});
}
});
}`
log details
08-15 19:13:13.354: E/AndroidRuntime(994): FATAL EXCEPTION: main
08-15 19:13:13.354: E/AndroidRuntime(994): java.lang.RuntimeException:
Unable to instantiate activity
ComponentInfo{com.sri.z4globalsoft/com.sri.z4globalsoft.MainActivity}:
java.lang.NullPointerException
08-15 19:13:13.354: E/AndroidRuntime(994): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
08-15 19:13:13.354: E/AndroidRuntime(994): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
08-15 19:13:13.354: E/AndroidRuntime(994): at
android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-15 19:13:13.354: E/AndroidRuntime(994): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
08-15 19:13:13.354: E/AndroidRuntime(994): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-15 19:13:13.354: E/AndroidRuntime(994): at
android.os.Looper.loop(Looper.java:130)
08-15 19:13:13.354: E/AndroidRuntime(994): at
android.app.ActivityThread.main(ActivityThread.java:3687)
08-15 19:13:13.354: E/AndroidRuntime(994): at
java.lang.reflect.Method.invokeNative(Native Method)
08-15 19:13:13.354: E/AndroidRuntime(994): at
java.lang.reflect.Method.invoke(Method.java:507)
08-15 19:13:13.354: E/AndroidRuntime(994): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
08-15 19:13:13.354: E/AndroidRuntime(994): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
08-15 19:13:13.354: E/AndroidRuntime(994): at
dalvik.system.NativeStart.main(Native Method)
08-15 19:13:13.354: E/AndroidRuntime(994): Caused by:
java.lang.NullPointerException
08-15 19:13:13.354: E/AndroidRuntime(994): at
android.app.Activity.findViewById(Activity.java:1647)
08-15 19:13:13.354: E/AndroidRuntime(994): at
com.sri.z4globalsoft.MainActivity.<init>(MainActivity.java:23)
08-15 19:13:13.354: E/AndroidRuntime(994): at
java.lang.Class.newInstanceImpl(Native Method)
08-15 19:13:13.354: E/AndroidRuntime(994): at
java.lang.Class.newInstance(Class.java:1409)
08-15 19:13:13.354: E/AndroidRuntime(994): at
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
08-15 19:13:13.354: E/AndroidRuntime(994): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
08-15 19:13:13.354: E/AndroidRuntime(994): ... 11 more

No comments:

Post a Comment