OMG! Finally I found NullPointerException in Unable to resolve host "api.shephertz.com"

+1 vote

hi, sorry for annoying you, but I found some bug(maybe).

as you know, my app using app42 api(user service) in android 

and there's no error on smartphone but have some error only on tablet! (G-Pad 8.3 or Galaxy Note 7).

The error prints log "Unable to resolve host "api.shephertz.com".

But there's no problem on Wi-Fi connection and manifest permission setting.

 

and finnaly I fount NullPointerException Exception :com.shephertz.app42.paas.sdk.android.App42Exception!

here's log.

06-27 21:00:54.060 6735-11062/nahunhee.circle I/System.out:  ########## Setting Session ##########
06-27 21:00:54.070 6735-11062/nahunhee.circle I/System.out:  Json String : {"app42":{"user":{"password":"4444","userName":"4444"}}}
06-27 21:00:54.070 6735-11062/nahunhee.circle I/System.out: sortedparams: apiKey97830c4223ea683b7a3051691c25bb0b06c1a539187eea47c37d8856c882b492body{"app42":{"user":{"password":"4444","userName":"4444"}}}sessionIdc41fa989-1fa6-4250-b091-522978a3bb50timeStamp2016-06-27T12:00:54.052Zversion1.0
06-27 21:00:54.070 6735-11062/nahunhee.circle I/System.out: Post URL is https://api.shephertz.com/cloud/1.0/user/authenticateAndCreateSession?
06-27 21:00:54.070 6735-11062/nahunhee.circle I/System.out:  Setting Header value : deviceId : dc5542ad75ce220e
06-27 21:00:54.070 6735-11062/nahunhee.circle I/System.out:  Setting Header value : signature : g8WZKj8crOG0kJ7WYSUmUMqgBWI%3D
06-27 21:00:54.070 6735-11062/nahunhee.circle I/System.out:  Setting Header value : SDKName : Android
06-27 21:00:54.070 6735-11062/nahunhee.circle I/System.out:  Setting Header value : version : 1.0
06-27 21:00:54.080 6735-11062/nahunhee.circle I/System.out:  Setting Header value : sessionId : c41fa989-1fa6-4250-b091-522978a3bb50
06-27 21:00:54.080 6735-11062/nahunhee.circle I/System.out:  Setting Header value : apiKey : 97830c4223ea683b7a3051691c25bb0b06c1a539187eea47c37d8856c882b492
06-27 21:00:54.080 6735-11062/nahunhee.circle I/System.out:  Setting Header value : loggedInUser : 4444
06-27 21:00:54.080 6735-11062/nahunhee.circle I/System.out:  Setting Header value : timeStamp : 2016-06-27T12:00:54.052Z
06-27 21:00:54.080 6735-6735/nahunhee.circle I/----: onPostExecute:  true
06-27 21:00:54.601 6735-11062/nahunhee.circle I/System.out:  PostResponse is {"app42":{"response":{"success":true,"users":{"user":{"userName":"4444","accountLocked":false,"sessionId":"c41fa989-1fa6-4250-b091-522978a3bb50","email":"4444@smartmddath4444.com"}}}}}
06-27 21:00:54.601 6735-11062/nahunhee.circle I/System.out: Name : email
06-27 21:00:54.601 6735-11062/nahunhee.circle I/System.out: value : java.lang.String
06-27 21:00:54.601 6735-11062/nahunhee.circle I/System.out: Name : sessionId
06-27 21:00:54.601 6735-11062/nahunhee.circle I/System.out: value : java.lang.String
06-27 21:00:54.601 6735-11062/nahunhee.circle I/System.out: Name : userName
06-27 21:00:54.601 6735-11062/nahunhee.circle I/System.out: value : java.lang.String
06-27 21:00:54.601 6735-11062/nahunhee.circle I/System.out: Name : accountLocked
06-27 21:00:54.601 6735-11062/nahunhee.circle I/System.out: value : java.lang.Boolean
06-27 21:00:54.621 6735-11090/nahunhee.circle I/System.out:  ########## Setting Session ##########
06-27 21:00:54.631 6735-11090/nahunhee.circle I/System.out: sortedparams: apiKey97830c4223ea683b7a3051691c25bb0b06c1a539187eea47c37d8856c882b492sessionIdc41fa989-1fa6-4250-b091-522978a3bb50timeStamp2016-06-27T12:00:54.628ZuserName4444version1.0
06-27 21:00:54.631 6735-11090/nahunhee.circle I/System.out:  QueryString is ?
06-27 21:00:54.631 6735-11090/nahunhee.circle I/System.out:  Requested URL is https://api.shephertz.com/cloud/1.0/user/4444?
06-27 21:00:54.631 6735-11090/nahunhee.circle I/System.out: Policy.NETWORK_FIRST
06-27 21:00:54.641 6735-11090/nahunhee.circle I/System.out:  Exception :com.shephertz.app42.paas.sdk.android.App42Exception: java.lang.NullPointerException
06-27 21:00:54.641 6735-11090/nahunhee.circle I/----: java.lang.NullPointerException
 
The important thing is, I changed user's email address ( 4444@smartmath4444.com to 4444@smartmddath4444.com) on App42 Website, and here's email address change! ({"userName":"4444","accountLocked":false,"sessionId":"c41fa989-1fa6-4250-b091-522978a3bb50","email":"4444@smartmddath4444.com"}}}}})
 
so I think there's some error or bug on before onPostExcute: true..
 
Plz check it : )
asked Jun 27, 2016 in Android by HunHee Na (21 points)

1 Answer

+1 vote
 
Best answer
Hi Hun,

Greetings!!!!!!

Could you please share the code snippet, that you are using to make API calls. That will really help us to trace the exact problem you are facing on Android Tablet device.

Let me know the details.

Thanks

Vishnu Garg
answered Jun 27, 2016 by Vishnu Garg (674 points) 1 flag
selected Jun 27, 2016 by HunHee Na
hi, i use app42_android_sdk_3.7.jar


mAuthTask = new UserLoginTask(name, password);
            mAuthTask.execute((Void) null);

public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {

        private final String name;
        private final String mPassword;

        UserLoginTask(String email, String password) {
            name = email;
            mPassword = password;
        }

        public boolean userLogin(final String name, final String password){
            final UserService userService = applicationClass.getUserService();
            userService.authenticate(name, password, new App42CallBack() {
                @Override
                public void onSuccess(Object o) {
                    userService.getUser(name, new App42CallBack() {
                        @Override
                        public void onSuccess(Object o) {
                            User user = (User)o;
                            User.Profile profile = user.getProfile();
                            final String isTeacher = profile.getFirstName();
                            final String collectionName = profile.getLine1();
                            final String keyName = profile.getLine2();              
                        }

                        @Override
                        public void onException(Exception e) {
                           
                            Log.i("----", e.getMessage());
                            Crashlytics.logException(e);
                            
                        }
                    });
                }
                @Override
                public void onException(Exception e){

                    if(activity == null)
                        return;

                    activity.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            progressGenerator.setStartState();
                        }
                    });

                    Log.i("----", e.getMessage());
                    Crashlytics.logException(e);
                 
                }
            });
            return true;
        }
        @Override
        protected Boolean doInBackground(Void... params) {
            return userLogin(name, mPassword);
        }

        @Override
        protected void onPostExecute(final Boolean success) {
            mAuthTask = null;
            Log.i("----", "onPostExecute:  "+success);
        }

        @Override
        protected void onCancelled() {
            mAuthTask = null;

        }
    }
and in ApplicationClass(extends Application)

App42API.initialize(this, "~~~~~~", "~~~~~~~");
        App42Log.setDebug(true);

        App42CacheManager.setPolicy(App42CacheManager.Policy.NETWORK_FIRST);

userService = App42API.buildUserService();
thank you, thank you for respose my question!!
As you are using already Async Task. So you need not require to use async API in Android. Please use sync APi for auth and getting User Detail.
As You are using async API that may be a reason for such error. Here is the code that you can use :
public boolean userLogin(final String name, final String password) {
            final UserService userService = App42API.buildUserService();
            User user = userService.authenticate(name, password);
            Log.i("----", "App42 Response :  " + user.getStrResponse());
            if (user.isResponseSuccess()) {
                user = userService.getUser(name);
                Log.i("----", "App42 Response :  " + user.getStrResponse());
                User.Profile profile = user.getProfile();
                final String isTeacher = profile.getFirstName();
                final String collectionName = profile.getLine1();
                final String keyName = profile.getLine2();
                return true;
            }
            else
                return false;
        }
um... as you write to me, I tried..
I removed Asynctask in Android.. and I call only 1 api at once(getUser only).
so my code is below.

final UserService userService = applicationClass.getUserService();
userService.getUser(name, new App42CallBack(){
@Override
            public void onSuccess(Object o) {
User user = (User)o;
                User.Profile profile = user.getProfile();
                final String isTeacher = profile.getFirstName();
                final String collectionName = profile.getLine1();
                final String keyName = profile.getLine2();
}

            @Override
            public void onException(Exception e) {
            e.printStackTrace();
}

but there is same problem appears(Exception :com.shephertz.app42.paas.sdk.android.App42Exception: java.lang.NullPointerException)

the interesting thing is, userService.authenticate works good!
but userService.getUser makes error!

could you help me? T.T

error stack below

Non-fatal Exception: com.shephertz.app42.paas.sdk.android.App42Exception: java.lang.NullPointerException
       at com.shephertz.app42.paas.sdk.android.user.UserService.getUser(UserService.java:526)
       at com.shephertz.app42.paas.sdk.android.user.UserService$6.run(UserService.java:550)
Caused by java.lang.NullPointerException
       at com.shephertz.app42.paas.sdk.android.App42API.isNetworkAvailable(App42API.java:696)
       at com.shephertz.app42.paas.sdk.android.connection.RESTConnectorCache.executeGet(RESTConnectorCache.java:170)
       at com.shephertz.app42.paas.sdk.android.user.UserService.getUser(UserService.java:520)
       at com.shephertz.app42.paas.sdk.android.user.UserService$6.run(UserService.java:550)
As you are using offline storage please provide permission for accessing Network State.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I already did it....
and I setOfflineStorage(false)....T.T
Thanks for the response. We have resolve the issue. Please download the SDK version 3.9.1 from Git.
https://github.com/shephertz/App42_ANDROID_SDK
thank you! and I'm so curious, why did it happend?

Anyway, I have a crush report about app42. http://crashes.to/s/817ef0dbee6
It will be a good source to make app42 good service!
Thanks for sharing the details.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...