小编Anu*_*nna的帖子

okhttp如何从响应改造中检索cookie?

我试图通过将cookie值设置为新的API调用来从API响应中检索Cookie值以维护后端会话,以防APP关闭:

PostMan RestClient对API调用的响应: 在此处输入图片说明

RetrofitClient.java

public static Retrofit getClient() {

    if (checkClient()) {
        return getRetrofit();
    }

    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    CookieHandler cookieHandler = new CookieManager();

    okhttp3.OkHttpClient client = new okhttp3.OkHttpClient.Builder().addNetworkInterceptor(interceptor)
            .cookieJar(new JavaNetCookieJar(cookieHandler))
            .connectTimeout(10, TimeUnit.SECONDS)
            .writeTimeout(10, TimeUnit.SECONDS)
            .readTimeout(30, TimeUnit.SECONDS)
            .build();

    Gson gson = new GsonBuilder()
            .setLenient()
            .create();

    retrofit = new Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .client(client)
            .build();
    return retrofit;
}
Run Code Online (Sandbox Code Playgroud)

API调用

private void userLogin(String username, String password) {
    Retrofit retrofit = RetrofitClient.getClient();

    final LoginServices loginServices = retrofit.create(LoginServices.class);
    Call<LoginResponse> call = loginServices.userLogin(username, …
Run Code Online (Sandbox Code Playgroud)

cookies android session-cookies retrofit2 okhttp3

6
推荐指数
3
解决办法
8410
查看次数

React Native:生成Release Build APK错误:app:mergeReleaseAssets失败

我正在尝试为React Native应用程序创建签名的APK。调试应用程序运行正常。我正在按照React本机指南创建签名的APK。

我已将密钥库添加到应用程序并设置gradle变量,但无法进行签名的apk。

以下是assembleRelease构建的错误

./gradlew assembleRelease --stacktrace

    NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /home/anuragdhunna/Android/Sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to …
Run Code Online (Sandbox Code Playgroud)

android gradle android-ndk react-native signed-apk

5
推荐指数
1
解决办法
1431
查看次数