Included in the project proguard, apk is going, everything is fine, but the application does not work)
Proguard-rules.pro
-keepattributes InnerClasses -keepattributes EnclosingMethod -keepattributes *Annotation* -dontoptimize # Keep Butterknife -keep class butterknife.** { *; } -dontwarn butterknife.internal.** -keep class **$$ViewBinder { *; } -keepclasseswithmembernames class * { @butterknife.* <fields>; } -keepclasseswithmembernames class * { @butterknife.* <methods>; } # Keep Jackson stuff -dontwarn com.fasterxml.jackson.databind.** -keep class org.codehaus.** { *; } -keep class com.fasterxml.jackson.annotation.** { *; } # Keep Retrofit -dontwarn okio.** -dontwarn retrofit2.Platform$Java8 -keep class retrofit.** { *; } -keepclasseswithmembers class * { @retrofit.** *; } -keepclassmembers class * { @retrofit.** *; } # Keep Picasso -dontwarn com.squareup.picasso.** -keep class com.squareup.picasso.** { *; } -keepclasseswithmembers class * { @com.squareup.picasso.** *; } -keepclassmembers class * { @com.squareup.picasso.** *; } #Keep Usafe -dontwarn sun.misc.Unsafe #Keep Moxy -keep class **$$PresentersBinder -keep class **$$State -keep class **$$ParamsHolder -keep class **$$ViewStateClassNameProvider -keepnames class * extends com.arellomobile.mvp.* #Keep Anotations -keep class javax.inject.** { *; } -keep class javax.annotation.** { *; } Error occurs in the presenter
@InjectViewState public class MainPresenter extends MvpPresenter<MainView> { @Inject Service service; public MainPresenter() { CamApp.getAppComponent().inject(this); } public void goLoginActivity(){ getViewState().goLoginActivity(); } public void goListCamerasActivity(){ isAvailableServer(); } private void isAvailableServer(){ Observable<Response> observable = RxUtils.wrapRetrofitCallIsAvailableServer(service.isAvailableServer("")); RxUtils.wrapAsync(observable) .subscribe(server -> { List<String> cookie = server.headers().values("Set-Cookie"); AuthUtils.setSessionId(cookie.get(0).split(";")[0].split("=")[1]); AuthUtils.setToken(cookie.get(1).split(";")[0].split("=")[1]); requestLoginDemo(); }, exception -> getViewState().showError(R.string.unknown_error)); } Writes that the service field - No such instance field: 'service'. With the proguard turned off, everything is working fine.
service
public class Service { private CamAPI mCamApi; public Service(CamAPI mCamApi) { this.mSpaceCamApi = mSpaceCamApi; } public Call<BackendData> passwordRecovery(String cookie, String token, String email){ return mCamApi.passwordRecovery(cookie, token, email); } public Call<Response<ResponseBody>> getArchiveLink(String devCode, String date){ return mCamApi.getArchiveLink(devCode, date); } public Call<BackendData> isAvailableServer(String cookie){ return TextUtils.isEmpty(cookie) ? mCamApi.isAvailableServer() : mCamApi.isAvailableServer(cookie); } public Call<BackendData> login(String cookie, String token, String username, String password, boolean remember){ return mCamApi.login(cookie, token, username, password, remember); } public Call<BackendData> getAllCameraList(String cookie, String token){ return mSpaceCamApi.getAllCameraList(cookie, token); } public Call<BackendData> getCamera(String cookie, String token, Long id, boolean isMobile){ return mCamApi.getCamera(cookie, token, id, isMobile); } public Call<BackendData> ptz(String cookie, String token, Long id, String com){ return mCamApi.ptz(cookie, token, id, com); } public Call<BackendData> logout(String cookie, String token){ return mCamApi.logout(cookie, token); } }