0

As I used Volley Lib. in my project with dependencies

compile 'com.mcxiaoke.volley:library:1.0.19'

this dependency allow me to use

RequestQueue requestQueue;

which is not allowed in google Volley lib dependency.

But Android Studio build.gradle warning message is NOTE: Do not place your application dependencies .... Configuration 'compile' is obsolete and has been replaced with 'implementation'. It will be removed at the end of 2018. Java compile error.

So, I'm searching for alternative of these dependency or Volley lib dependencies in androidTestImplementation

Here is my code. which is working absolutely fine but I need an alternate of this lib.

public class LoginActivity extends AppCompatActivity {

    private Button admin_login;
    private EditText admin_mob, admin_pass;
    private RequestQueue requestQueue;
    private static final String URL = "https://indinity.com/json_data.php";
    private StringRequest request;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        admin_login = findViewById(R.id.button);
        admin_mob = findViewById(R.id.editText);
        admin_pass = findViewById(R.id.editText2);

        requestQueue = Volley.newRequestQueue(this);

        admin_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                request = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {
                            JSONObject jsonObject = new JSONObject(response);
                            if(jsonObject.names().get(0).equals("success"))
                            {
                                Toast.makeText(getApplicationContext(),"Success "+jsonObject.getString("success"),Toast.LENGTH_LONG).show();
                                startActivity(new Intent(getApplicationContext(),OptionActivity.class));
                            } else {
                                Toast.makeText(getApplicationContext(),"Error "+jsonObject.getString("error"),Toast.LENGTH_SHORT).show();
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }


                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {

                    }
                }){
                            @Override
                            protected Map<String, String> getParams() throws AuthFailureError {
                            HashMap<String, String> hashMap = new HashMap<String, String>();
                            hashMap.put("adminmob", admin_mob.getText().toString());
                            hashMap.put("password", admin_pass.getText().toString());
                            return hashMap;

                    }
                };

                requestQueue.add(request);
            }
        });



    }
}
Animesh Bhardwaj
  • 709
  • 4
  • 14
  • That isn't the real volley. You're using some random fork of Volley instead. The correct library is com.android.volley:volley – Gabe Sechan Apr 19 '18 at 20:42

1 Answers1

0

just change

compile 'com.mcxiaoke.volley:library:1.0.19'

to

implementation 'com.mcxiaoke.volley:library:1.0.19'

See : Migrate to Android Plugin for Gradle 3.0.0

Arpan Sarkar
  • 2,301
  • 2
  • 13
  • 24