16648

Unable to resolve Static method?

I'm new to android and heard about retrofit. But when I tried to implement this, I'm getting this error:

11-07 10:57:59.969 8036-8291/com.example.first.servicefirst W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljava/nio/file/Path;) 11-07 10:57:59.969 8036-8291/com.example.first.servicefirst W/dalvikvm﹕ VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;) 11-07 10:57:59.969 8036-8291/com.example.first.servicefirst I/dalvikvm﹕ Could not find method java.nio.file.Files.newInputStream, referenced from method okio.Okio.source 11-07 10:57:59.969 8036-8291/com.example.first.servicefirst W/dalvikvm﹕ VFY: unable to resolve static method 18524: Ljava/nio/file/Files;.newInputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/InputStream;

I'm really confused where did I go wrong.

This is my main activity:

package com.example.first.servicefirst; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.squareup.okhttp.Interceptor; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; import java.io.IOException; import retrofit.Call; import retrofit.Callback; import retrofit.GsonConverterFactory; import retrofit.Response; import retrofit.Retrofit; public class MainActivity extends Activity { public EditText password,userName; Button login,resister; ProgressBar progressbar; TextView tv; String TAG="Fails"; String url="http://172.16.7.203/sfAppServices/SF_UserLogin.svc"; private ModelLogin Result; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); password=(EditText) findViewById(R.id.password); userName=(EditText) findViewById(R.id.txtEmployeeCode); login=(Button) findViewById(R.id.btnsignin); userName.setBackgroundResource(R.drawable.colorfoucs); //progess_msz.setVisibility(View.GONE); ConnectivityManager cn=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo nf=cn.getActiveNetworkInfo(); if(nf != null && nf.isConnected()==true ) { Toast.makeText(this, "Network Available", Toast.LENGTH_LONG).show(); } else { showAlertDialog(MainActivity.this,"No Network","Please Check Your Network Connectivity",true); } final ConnectionDetector cd = new ConnectionDetector(getApplicationContext()); login.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { progressbar = (ProgressBar) findViewById(R.id.progressBar); progressbar.setVisibility(View.VISIBLE); String s1 = userName.getText().toString(); String s2 = password.getText().toString(); if (s1.equals("")) { userName.setError("Enter User Name"); } if (s2.equals("")) { password.setError("Enter Password"); } try{ OkHttpClient client = new OkHttpClient(); client.interceptors().add(new Interceptor() { @Override public com.squareup.okhttp.Response intercept(Chain chain) throws IOException { Request original = chain.request(); // Customize the request Request request = original.newBuilder() .header("Accept", "application/json") .header("Authorization", "auth-token") .method(original.method(), original.body()) .build(); com.squareup.okhttp.Response response = chain.proceed(request); // Customize or return the response return response; } }); Retrofit retro = new Retrofit.Builder().baseUrl(url).addConverterFactory(GsonConverterFactory.create()).build(); RetrofitRest retrofitRest = retro.create(RetrofitRest.class); Call<ModelLogin>call=retrofitRest.getResult(s1, s2); // Call<ModelLogin> callget=retrofitRest.verify(result); call.enqueue(new Callback<ModelLogin>() { @Override public void onResponse(Response<ModelLogin> response, Retrofit retrofit) { ModelLogin modelLogin=new ModelLogin(); modelLogin.getLoginResult(); if(modelLogin.equals(2)) { Intent intent=new Intent(getApplicationContext(),Main2Activity.class); startActivity(intent); } } @Override public void onFailure(Throwable t) { Toast.makeText(getApplicationContext(),"Fails",Toast.LENGTH_LONG).show(); } }); // call.enqueue(new Callback<ModelLogin>() { // @Override // public void onResponse(Response<ModelLogin> response, Retrofit retrofit) { // } // @Override // public void onFailure(Throwable t) { // Log.d(TAG,"Error"); // } //}); }catch (Exception e){ throw e; } } }); } public void showAlertDialog(Context context, String title, String message, Boolean status) { AlertDialog alertDialog = new AlertDialog.Builder(context).create(); // Setting Dialog Title alertDialog.setTitle(title); // Setting Dialog Message alertDialog.setMessage(message); // Setting alert dialog icon // Setting OK Button alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); // Showing Alert Message alertDialog.show(); } }

This is my interface:

package com.example.first.servicefirst; import retrofit.Call; import retrofit.http.POST; import retrofit.http.Path; public interface RetrofitRest { @POST("SF_UserLogin.svc/rest/login/{EMPLOYEECODE}/{PASSWORD}") public Call<ModelLogin>getResult(@Path("EMPLOYEECODE")String empcode,@Path("PASSWORD")String passwrd); }

My json response will be like this:

{"loginResult":"{\"Result\":2,\"UserID\":0,\"ModuleID\":1,\"ModuleName\":\"CRM\"}"}

This is my logcat:

11-09 11:17:34.670 18964-18964/com.example.first.servicefirst D/dalvikvm﹕ Late-enabling CheckJNI 11-09 11:17:34.770 18964-18964/com.example.first.servicefirst I/libthemeutils﹕ Theme: libthemeutil.so load success 11-09 11:17:34.830 18964-18964/com.example.first.servicefirst D/dalvikvm﹕ GetMethodID: not returning s tatic method Landroid/os/Process;.getTotalMemory ()J 11-09 11:17:34.830 18964-18964/com.example.first.servicefirst D/dalvikvm﹕ GetMethodID: not returning static method Landroid/os/Process;.getFreeMemory ()J 11-09 11:17:34.980 18964-18964/com.example.first.servicefirst W/Toast﹕ From com.example.first.servicefirst, go ahead. 11-09 11:17:35.070 18964-18964/com.example.first.servicefirst I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LNX.LA.3.5.2.2.2_RB1.04.04.04.154.004_msm8226_LNX.LA.3.5.2.2.2_RB1__release_AU () OpenGL ES Shader Compiler Version: E031.24.00.15 Build Date: 08/06/14 Wed Local Branch: mybranch4057433 Remote Branch: quic/LNX.LA.3.5.2.2.2_rb1 Local Patches: NONE Reconstruct Branch: AU_LINUX_ANDROID_LNX.LA.3.5.2.2.2_RB1.04.04.04.154.004 + NOTHING 11-09 11:17:35.240 18964-18964/com.example.first.servicefirst D/OpenGLRenderer﹕ Enabling debug mode 0 11-09 11:17:35.410 18964-18964/com.example.first.servicefirst I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@424badd8 time:61392269 11-09 11:17:41.420 18964-19350/com.example.first.servicefirst W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljava/nio/file/Path;) 11-09 11:17:41.420 18964-19350/com.example.first.servicefirst W/dalvikvm﹕ VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;) 11-09 11:17:41.420 18964-19350/com.example.first.servicefirst I/dalvikvm﹕ Could not find method java.nio.file.Files.newOutputStream, referenced from method okio.Okio.sink 11-09 11:17:41.420 18964-19350/com.example.first.servicefirst W/dalvikvm﹕ VFY: unable to resolve static method 18520: Ljava/nio/file/Files;.newOutputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/OutputStream; 11-09 11:17:41.420 18964-19350/com.example.first.servicefirst D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x000a 11-09 11:17:41.420 18964-19350/com.example.first.servicefirst W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljava/nio/file/Path;) 11-09 11:17:41.420 18964-19350/com.example.first.servicefirst W/dalvikvm﹕ VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;) 11-09 11:17:41.420 18964-19350/com.example.first.servicefirst I/dalvikvm﹕ Could not find method java.nio.file.Files.newInputStream, referenced from method okio.Okio.source 11-09 11:17:41.420 18964-19350/com.example.first.servicefirst W/dalvikvm﹕ VFY: unable to resolve static method 18519: Ljava/nio/file/Files;.newInputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/InputStream; 11-09 11:17:41.420 18964-19350/com.example.first.servicefirst D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x000a

Answer1:

Your parsing of response is not correct. Check with this code

call.enqueue(new Callback<ModelLogin>() { @Override public void onResponse(Response<ModelLogin> response, Retrofit retrofit) { if(response.getLoginResult().getResult().equals("2") { Intent intent=new Intent(getApplicationContext(),Main2Activity.class); startActivity(intent); } }

Recommend

  • Need help for retrofit login example?
  • Facebook Like Button doesn't increment
  • Tiny Images, No Rotation, but still get OutOfMemoryError: bitmap size exceeds VM budget
  • Android custom dialog linearlayout size same as dialogs bg image
  • Android ripple for button not working
  • Listview with multiple strings
  • How to provide objects of the same type? Dagger2
  • ant copy copying order
  • Android how to set a transparent image resource of a view? or Remove the image?
  • NLog Configuration API: Using Layouts stored in variables
  • Change Design Support Navigation View Header Title Programmatically
  • Set indent on view in Zend Framework
  • how to swap Image in jquery
  • onLeScan never gets called android
  • Store additional information during registration with Firebase in Android
  • How to use getFilter form Listadapter
  • How to add an item to a ListView with each Button click
  • Background not visible in surface view
  • Visual Studio 2008 and JavaScript brackets formatting
  • Unable to use dot layout (graphviz as a library)
  • OnItemSelectedListener for Spinner that was added programmatically does not trigger
  • How do i disable a text box within an iframe
  • write text on image and show it to a imageview
  • I have two activity.I want to Send the data from second activity to previous activity.First activity
  • Custom WebViewPage inject code when razor template is rendering
  • Unable to resolve Static method?
  • Activity overlaying. WindowManager.LayoutParams
  • How to get listview position?
  • Syntax error on tokens, AnnotationName expected instead - error on query
  • WPF version of .ScaleControl?
  • Android Activity.onWindowFocusChanged doesn't get called from within TabHost
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • jquery mobile loadPage not working
  • align graphs with different xlab
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How to stop GridView from loading again when I press back button?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize