0

After integrating my app with Facebook SDK to measure Facebook Mobile Ad results, some users are getting this error:

java.lang.NullPointerException: println needs a message
at android.util.Log.println_native(Native Method)
at android.util.Log.d(Log.java:138)
at com.facebook.internal.Utility.logd(Utility.java:287)
at com.facebook.Settings.publishInstallAndWait(Settings.java:291)
at com.facebook.Settings$2.run(Settings.java:218)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:864)

Here is code snippet regarding Facebook SDK from my Activity:

import com.facebook.Settings;
import com.facebook.*;

public class MainActivity extends Activity {

public void onCreate(Bundle savedInstanceState) {

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

// You need to add this code to launch activity.java for Facebook integration:
    Settings.publishInstallAsync(getApplicationContext(), getString(R.string.app_id));

    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    android.net.NetworkInfo wifi = cm
            .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    android.net.NetworkInfo datac = cm
            .getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    if ((wifi != null & datac != null)
            && (wifi.isConnected() | datac.isConnected())) {        
        this.finish();
        Intent intent = new Intent(this, MainOnlineActivity.class);
        this.startActivity(intent);
    }
    else {
        this.finish();
        Intent intent = new Intent(this, MainOfflineActivity.class);
        this.startActivity(intent);
    }

}
} 

Please help me to fix it.

Art
  • 276
  • 1
  • 2
  • 17

1 Answers1

0

The error you're seeing occurs when a Log method is passed in a null message. It looks like it was a known issue with the Facebook SDK and has been fixed as of version 3.0.1.

ggmathur
  • 833
  • 5
  • 12
  • As I'm new to this I'm not sure what you mean by "Log method is passed in a null message". What user has to do to get this error? Please explain. – Art Aug 21 '13 at 17:26
  • In Android, you can call `Log` from any class to log output to adb logcat. You can read more about it [here](http://developer.android.com/reference/android/util/Log.html). The NPE in your stack trace was due to a call such as `Log.d("example tag", null);`. This was done by the *Facebook* SDK, and has been resolved as of version 3.0.1. I'm not entirely sure what they were doing, as I didn't sift through the Facebook code, but all *you* need to do is upgrade your Facebook SDK. – ggmathur Aug 22 '13 at 18:39