我试图通过将cookie值设置为新的API调用来从API响应中检索Cookie值以维护后端会话,以防APP关闭:
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) 我正在尝试为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 ×2
android-ndk ×1
cookies ×1
gradle ×1
okhttp3 ×1
react-native ×1
retrofit2 ×1
signed-apk ×1