The project for Android when compiling throws out such an action:

A/art: art/runtime/thread.cc:1329] Throwing new exception 'length=79; index=1337' with unexpected pending exception: java.lang.ArrayIndexOutOfBoundsException: length=79; index=1337 A/art: art/runtime/thread.cc:1329] at void ua.avk.moicar.activity.view.LoginActivity.allCarTask2(java.lang.String) (LoginActivity.java:687) A/art: art/runtime/thread.cc:1329] at java.lang.Boolean ua.avk.moicar.activity.view.LoginActivity$UserLoginTask.doInBackground(java.lang.Void[]) (LoginActivity.java:430) A/art: art/runtime/thread.cc:1329] at java.lang.Object ua.avk.moicar.activity.view.LoginActivity$UserLoginTask.doInBackground(java.lang.Object[]) (LoginActivity.java:399) A/art: art/runtime/thread.cc:1329] at java.lang.Object android.os.AsyncTask$2.call() (AsyncTask.java:295) A/art: art/runtime/thread.cc:1329] at void java.util.concurrent.FutureTask.run() (FutureTask.java:237) A/art: art/runtime/thread.cc:1329] at void android.os.AsyncTask$SerialExecutor$1.run() (AsyncTask.java:234) A/art: art/runtime/thread.cc:1329] at void java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) (ThreadPoolExecutor.java:1113) A/art: art/runtime/thread.cc:1329] at void java.util.concurrent.ThreadPoolExecutor$Worker.run() (ThreadPoolExecutor.java:588) A/art: art/runtime/thread.cc:1329] at void java.lang.Thread.run() (Thread.java:818) A/art: art/runtime/thread.cc:1329] 

Why does it behave like this and how to fix it? Here is the code:

 public interface UserClient { @FormUrlEncoded @POST("login/") Call<JsonObject> getUser2(@Field("grant_type") String grantType, @Field("username") String userName, @Field("password") String password ); } 

And there is a challenge:

 ... Retrofit.Builder builder = new Retrofit.Builder() .baseUrl("http://localhost:8080/api/") .addConverterFactory(GsonConverterFactory.create()); Retrofit retrofit = builder.build(); UserClient userClient = retrofit.create(UserClient.class); Call<JsonObject> call = userClient.getUser2("sectet", "user", "password"); try { retrofit2.Response response = call.execute(); if (response.isSuccessful()) { Log.i("USER -> ", "TRUE"); } else { Log.i("USER -> ", "FALSE"); } } catch (IOException e) { e.printStackTrace(); } ... 

I found a solution online - but it did not help

    1 answer 1

    Found a solution ( original solution )

    In general, in AndroidStudio we go to

     File->Settings->Instant Run 

    and remove the check mark from

     Enable Instant Run to hot swap code/resource changes on deploy (default enabled) 

    It helped me, I hope that it will also help you.

    PS / I understand that the ekzepshn speaks about a problem with an array. But the solution to this problem was exactly that. In the network I found even more banal options, for example, to create a new class or rewrite the block. (there are no links anymore because I myself did not take such decisions seriously).

    • one
      For those who disagree - please express your opinion and decision ... - Alex