datatheorem / TrustKit-Android

Easy SSL pinning validation and reporting for Android.
MIT License
584 stars 87 forks source link

java.lang.IllegalStateException: TrustKit has already been initialized #21

Closed evollu closed 6 years ago

evollu commented 7 years ago

When app is closed though "back" button and resume, onCreate will be called again. If I put TrustKit.initializeWithNetworkSecurityConfiguration inside onCreate as readme shows it throws TrustKit has already been initialized error.

shall I add a try catch around it to avoid the crash?

jobot0 commented 6 years ago

Hey @evollu are you calling Trustkit. initializeWithNetworkSecurityConfiguration in the onCreate of your app or an activity? It should work if you use it inside the one of your application.

public class MyApp extends Application {
  @Override
  public void onCreate() {
    Trustkit.initializeWithNetworkSecurityConfiguration(this);
  }
}
evollu commented 6 years ago

ah I'm calling it in Activity.

Lynnette1 commented 5 years ago

Can you clarify this statement.

Hey @evollu are you calling Trustkit. initializeWithNetworkSecurityConfiguration in the onCreate of your app or an activity? It should work if you use it inside the one of your application.