Genymotion连接到Localhost

时间:2016-03-31 04:41:05

标签: android retrofit genymotion

我使用genymotion作为我的android模拟器。尝试连接localhost。 我在浏览器中收到来自http://192.168.10.109/api/v1/attendence/get的回复。当我在android中尝试它时,它说的是无效路径。 在genymotion的情况下,我也试过http://10.0.3.2/api/v1/attendence/get。但同样的情况。 Logcat输出:

03-31 00:38:51.581    2160-2160/com.itccheckinchekout E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process:itccheckinchekout, PID: 2160
    java.lang.ExceptionInInitializerError
            at com.itccheckinchekout.MainActivity.getUsers(MainActivity.java:81)
            at com.itccheckinchekout.MainActivity.onCreate(MainActivity.java:42)
            at android.app.Activity.performCreate(Activity.java:5990)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
     Caused by: java.lang.IllegalArgumentException: Illegal URL: 192.168.56.1:8080/api/
            at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:437)
            at com.itccheckinchekout.util.ApiUtils.<clinit>(ApiUtils.java:31)
            at com.itccheckinchekout.MainActivity.getUsers(MainActivity.java:81)
            at com.itccheckinchekout.MainActivity.onCreate(MainActivity.java:42)
            at android.app.Activity.performCreate(Activity.java:5990)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

0 个答案:

没有答案