Android app doesn't work after published it by

2019-04-16 08:30发布

问题:

I create an app and it work on emulator. It works on debug apk on device, but when I build it with generate signed app it doesn't work? what is wrong and how I can debug it on device on signed sate?

回答1:

In my project doesn't run signed app. I changed minifyEnabled value from true to false then problem is solve . this bad solution. I'm looking for a better way.

build.gradle :

buildTypes {
        release {
            shrinkResources true
            minifyEnabled false //true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
        }
    }


回答2:

I found the problem and solved it. I must keep models form obfuscating that use retrofit. After use below code my app work properly in minifyEnabled enabled:

-keep com.xxx.xxx.models.** { *; }

retrofit need to know class properties for filling by values.

Thanks every body try to help me.



回答3:

I found progard has problem with retrofit interfce

Sample of interface:

import java.util.List;

import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;


public interface AClient {
    // For register device for specific package
    @GET("/api/initiate/{packageId}")
    Call<InitiateModel> GetInitiateInfo(
            @Path("packageId") int packageId
    );
  }

I add -dontwarn retrofit2.** in progard file. What is wrong?