Код работал нормально, но после того, как я добавил строки для реализации кэша в клиентском классе Apollo, я получаю эту ошибку, и приложение не может скомпилировать.
Когда я удалил строки длякеш, он начал компилироваться и работать просто отлично.Я думаю, что я не настроил кэш должным образом.
Я попытался сделать недействительными кэш и перезапуск и удалил сгенерированные файлы, думая, что проблема может быть решена путем воссоздания класса, но проблема все еще существует.
Это клиент:
public class MyApolloClient {
private static final String BASE_URL = "http://192.168.43.33:4444/";
private static ApolloClient apolloClient = null;
public static ApolloClient getApolloClient(Context context) {
if (apolloClient != null) {
return apolloClient;
} else {
//Directory where cached responses will be stored
File file = new File(context.getApplicationContext().getCacheDir().toString());
//Size in bytes of the cache
int size = 1024 * 1024;
//Create the http response cache store
DiskLruHttpCacheStore cacheStore = new DiskLruHttpCacheStore(file, size);
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient okHttpClient = new OkHttpClient.Builder().build();
apolloClient = ApolloClient.builder().serverUrl(BASE_URL).httpCache(new ApolloHttpCache(cacheStore)).okHttpClient(okHttpClient).build();
return apolloClient;
}
}
}
И это единственный раз, когда он используется:
MyApolloClient.getApolloClient(this).mutate(
LoginMutation.builder().email(emailEditText.text.toString())
.password(passwordEditText.text.toString())
.build()
).enqueue(object : ApolloCall.Callback<LoginMutation.Data>() {
override fun onResponse(response: Response<LoginMutation.Data>) {
/*val intent = Intent(this@LoginActivity, MainActivity::class.java)
startActivity(intent)*/
Log.e("success",response.data().toString())
}
override fun onFailure(e: ApolloException) {
Log.e("failed", e.toString())
}
})
Спасибо.