标签: retrofit2

无法解决 Retrofit2 的依赖关系

我尝试将改造库导入到我的 gradle 文件中,但不幸的是,我面临太多错误。

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
Run Code Online (Sandbox Code Playgroud)

编辑 这是我的应用程序 build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.example.practice"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes { …
Run Code Online (Sandbox Code Playgroud)

android gradle retrofit2

-1
推荐指数
1
解决办法
9438
查看次数

使用UI线程改进2个回调问题

我正在制作一个简单的材料设计登录屏幕,显示进度对话框,同时改造正在获取数据.

我最近升级到改装2,所以我对此很新.

我的LoginActivity代码:

private void login(){
        Log.d(TAG, "Attempting login");

        if(!validate()){
            onLoginFailure();
            return;
        }

        login_button.setEnabled(false);

        progressDialog = new ProgressDialog(LoginActivity.this, R.style.AppTheme_Dark_Dialog);
        progressDialog.setIndeterminate(true);
        progressDialog.setMessage("Authenticating...");
        progressDialog.show();

        String username = _usernameText.getText().toString().toLowerCase(); //all usernames are lowercase only
        String password = _passwordText.getText().toString();

        //here we handle the NWL section.

        startTime = System.currentTimeMillis();
        NWL.login(username, password, this); //This runs async to UI anyway.
    }
Run Code Online (Sandbox Code Playgroud)

和LoginActivity中的其他功能:

@BindView(R.id.login_button)
Button login_button;

 public void loginOK() {
        progressDialog.dismiss();
        login_button.setEnabled(true);
        toastCreator.showToastLong("Login OK");
        Log.d(TAG, "Total time: " + (System.currentTimeMillis()-startTime));
 }
Run Code Online (Sandbox Code Playgroud)

我的NetworkLogic(NWL)类的代码:

public void login(String username, String password, …
Run Code Online (Sandbox Code Playgroud)

android ui-thread android-handler retrofit2

-2
推荐指数
1
解决办法
3229
查看次数

如何在 Retrofit 2.0 中传递动态标头授权?

我想在改造中使用 jwt 传递动态标头,我使用 GET api 接收令牌,并且令牌已使用共享首选项保存,我需要将令牌作为标头传递以在我登录时接收用户详细信息。在此之前,我使用了 volley 库,在改造中只是令人困惑,请帮助我!

android retrofit2

-2
推荐指数
1
解决办法
905
查看次数

改进动态URL问题

我是Retrofit 2的新手,我正在尝试在我的应用中集成Google Place API.我的问题是如何在使用Retrofit 2.0时继续使用这种动态URL.

网址:

  https://maps.googleapis.com/maps/api/place/autocomplete/json?input="{Place Name}"&location="{Lat,long}"&key="{API KEY}"
Run Code Online (Sandbox Code Playgroud)

我的模型类名称是:

1)PlaceAutoComplete

2)PlacePredictions

public class PlaceAutoComplete {

private String place_id;
private String description;

public String getPlaceDesc() {
    return description;
}

public void setPlaceDesc(String placeDesc) {
    description = placeDesc;
}

public String getPlaceID() {
    return place_id;
}

public void setPlaceID(String placeID) {
    place_id = placeID;
}

}
Run Code Online (Sandbox Code Playgroud)

public class PlacePredictions {

  public ArrayList<PlaceAutoComplete> getPlaces() {
    return predictions;
}

  public void setPlaces(ArrayList<PlaceAutoComplete> places) {
    this.predictions = places;
}

  private ArrayList<PlaceAutoComplete> predictions;
} …
Run Code Online (Sandbox Code Playgroud)

android retrofit2

-2
推荐指数
1
解决办法
2439
查看次数

标签 统计

android ×4

retrofit2 ×4

android-handler ×1

gradle ×1

ui-thread ×1