• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Server Error Occured in Android App

I have a android app that takes the values from user for student, such as FirstName, LastName and Class. When the user inputs the values and clicks on button, it calls the API and stores the values into database.
I am using Yii framework and REST API. Here when I run, there is error as com.android.volley.ServerError.
But the values get stored in the database. Following is the code.

What should I do? I test it using Postman, there also the values are getting saved in table but the response is not working as needed.

Code:
package com.example.anitaa.studentadd;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;

import java.util.HashMap;
import java.util.Map;

public class MainActivity extends AppCompatActivity {

    EditText FirstName, LastName, Class;
    Button button;
    String url1="http://192.168.1.3/student/web/studentrecords";



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate ( savedInstanceState );
        setContentView ( R.layout.activity_main );
        FirstName= (EditText) findViewById(R.id.firstname);
        LastName= (EditText) findViewById(R.id.lastname);
        Class= (EditText) findViewById(R.id.studentclass);
        button = (Button) findViewById(R.id.studentinformation);
        button.setOnClickListener ( new View.OnClickListener () {
            @Override
            public void onClick(View v) {
                final String fname,lname,class2;
                fname = FirstName.getText().toString();
                lname = LastName.getText().toString();
                class2 = Class.getText().toString();
                StringRequest stringRequest1 = new StringRequest ( Request.Method.POST, url1, new Response.Listener<String> () {
                    @Override
                    public void onResponse(String response) {

                        Toast.makeText(MainActivity.this,response.toString (),Toast.LENGTH_SHORT).show();
                    }
                }, new Response.ErrorListener () {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(MainActivity.this,error.toString (),Toast.LENGTH_SHORT).show();
                        error.printStackTrace();

                    }
                } ){
                    @Override
                    protected Map<String, String> getParams() throws AuthFailureError {
                        Map<String, String> params = new HashMap<String, String> ();
                        params.put("FirstName",fname);
                        params.put("LastName",lname);
                        params.put("Class",class2);
                        return params;
                    }
                };

                MySingleton.getInstance ( MainActivity.this ).addToRequestque ( stringRequest1 );

            }
        } );


    }
    }
 
You don't have to post all. Just 5 or 6 lines is enough.
Code:
2019-07-18 21:06:59.632 1686-3836/? I/ActivityManager: Force stopping com.example.anitaa.student appid=10081 user=0: from pid 5673
2019-07-18 21:06:59.632 1686-3836/? I/ActivityManager: Killing 5601:com.example.anitaa.student/u0a81 (adj 0): stop com.example.anitaa.student
2019-07-18 21:06:59.637 1686-3836/? W/ActivityManager: Force removing ActivityRecord{8b4e41b u0 com.example.anitaa.student/.MainActivity t171}: app died, no saved state
2019-07-18 21:06:59.642 1686-3836/? I/WindowManager: Failed to capture screenshot of Token{a6789b8 ActivityRecord{8b4e41b u0 com.example.anitaa.student/.MainActivity t171 f}} appWin=Window{e9fecd7 u0 com.example.anitaa.student/com.example.anitaa.student.MainActivity} drawState=4
2019-07-18 21:06:59.730 1686-1712/? W/ActivityManager: setHasOverlayUi called on unknown pid: 5601
2019-07-18 21:07:00.670 2972-5282/? E/ActivityThread: Failed to find provider info for com.google.android.apps.gsa.testing.ui.audio.recorded
2019-07-18 21:07:06.052 2972-5282/? E/ActivityThread: Failed to find provider info for com.google.android.apps.gsa.testing.ui.audio.recorded
2019-07-18 21:07:07.083 1686-1809/? D/PackageInstaller: Inherited files: [/data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/base.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/split_lib_dependencies_apk.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/split_lib_resources_apk.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/split_lib_slice_0_apk.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/split_lib_slice_1_apk.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/split_lib_slice_2_apk.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/split_lib_slice_3_apk.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/split_lib_slice_4_apk.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/split_lib_slice_5_apk.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/split_lib_slice_7_apk.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/split_lib_slice_8_apk.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/split_lib_slice_9_apk.apk, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/oat/x86/base.odex, /data/app/com.example.anitaa.student-OoBCK78E3d51JqZHwIDBTg==/oat/x86/base.vdex]
2019-07-18 21:07:07.141 1686-1809/? D/PackageInstaller: Linked 14 files into /data/app/vmdl428671333.tmp
 
Upvote 0
The post you posted doesn't looked like an exception. Exception normally looked like this

lrwvdXk.png
 
  • Like
Reactions: Deleted User
Upvote 0
The post you posted doesn't looked like an exception. Exception normally looked like this

lrwvdXk.png

The result I included in the code is only present. But there are some red colors statements too. such as:
Code:
2019-07-18 21:07:00.670 2972-5282/? E/ActivityThread: Failed to find provider info for com.google.android.apps.gsa.testing.ui.audio.recorded
2019-07-18 21:07:06.052 2972-5282/? E/ActivityThread: Failed to find provider info for com.google.android.apps.gsa.testing.ui.audio.recorded
2019-07-23 18:06:25.147 1427-1427/? E/adbd: failed to connect to socket 'localabstract:com.example.anitaa.studentadd': Connection refused
2019-07-23 18:06:28.870 1545-5738/? E/AudioFlinger: not enough memory for AudioTrack size=131296
2019-07-23 18:06:33.953 1545-5738/? E/AudioFlinger: createRecordTrack_l() initCheck failed -12; no control block?
2019-07-23 18:06:33.960 2972-11042/? E/ActivityThread: Failed to find provider info for com.google.android.apps.gsa.testing.ui.audio.recorded
2019-07-23 18:06:34.127 1549-1549/? E/installd: Failed to delete /data/app/vmdl1168025173.tmp: No such file or directory

What should I do? When I try it using Postman then also some errors are there.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones