2 gongxiaoou gongxiaoou 于 2016.05.05 15:33 提问

游戏接完支付,登录第三方sdk之后报空指针异常但是找不到错误

Caused by: java.lang.NullPointerException

at com.weedong.gamesdk.utils.PreferencesUtils.getSharedPreferences(PreferencesUtils.java:23)

at com.weedong.gamesdk.utils.PreferencesUtils.getAppId(PreferencesUtils.java:83)

at com.weedong.gamesdk.base.WdSDKControl.getGameInfo(WdSDKControl.java:545)

at com.weedong.gamesdk.base.WdSDKControl.login(WdSDKControl.java:92)

at com.weedong.gamesdk.base.WdGameSDK.login(WdGameSDK.java:43)

at com.tongbulv.sdk.channels.channelmeitu.ChannelMeitu.meiTuLogin(ChannelMeitu.java:148)

at com.tongbulv.sdk.channels.channelmeitu.ChannelMeitu.login(ChannelMeitu.java:65)

at com.tongbulv.tsdk.TSDKUserCenter.login(TSDKUserCenter.java:188)

at com.zxlf.zwhx.MainActivity$6.run(MainActivity.java:776)

at android.os.Handler.handleCallback(Handler.java:733)

at android.os.Handler.dispatchMessage(Handler.java:95)

at android.os.Looper.loop(Looper.java:136)

at android.app.ActivityThread.main(ActivityThread.java:5333)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:515)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:895)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:711)

at dalvik.system.NativeStart.main(Native Method)
上面是代码
但是我的context。和WdGameSDK的实例都打印了都不是空代码如下
private void meiTuLogin(final Context context) {
// TODO Auto-generated method stub
Toast.makeText(context, WdGameSDK.getInstance().toString(), Toast.LENGTH_LONG).show();
Log.e("meiTuLogin", WdGameSDK.getInstance().toString());

    WdLoginListener wdLoginListener=new WdLoginListener() {

        @Override
        public void onCallBack(int arg0, UserInfo arg1) {
            // TODO Auto-generated method stub

        }
    };
    Toast.makeText(context, "WdLoginListener"+wdLoginListener.toString(), Toast.LENGTH_LONG).show();
    Log.e("WdLoginListener", wdLoginListener.toString());

    WdGameSDK.getInstance().login((Activity) context, new WdLoginListener() {
        @Override
        public void onCallBack(int paramInt, UserInfo paramInfo) {
            if (paramInt == WdResultCode.LOGIN_SUCCESS) {
                String uid=paramInfo.getUid();
                String access_token=paramInfo.getSessionid();
                bindUser(context,uid,access_token);
            } else if (paramInt == WdResultCode.LOGIN_CANCEL) {
                loginFailCallback("登录取消");
            } else {
                loginFailCallback("登录失败");
            }
        }
    });
}

@Override
public void login(Context context) {
    Toast.makeText(context, "login"+context, Toast.LENGTH_LONG).show();
    Log.e("login", context.toString());
    meiTuLogin(context);
}
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!