Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: cannot find symbol .addInterceptor(OkHttp3Helper.getPinningInterceptor()) #83

Open
ys-sherzad opened this issue Feb 23, 2021 · 2 comments

Comments

@ys-sherzad
Copy link

Hi there, as the title suggests, it's complaining about not being able to find symbol OkHttp3Helper and I'm not sure what to do!

package af.myapp;
import android.os.Bundle;
import com.facebook.react.ReactActivity;
import com.zoontek.rnbootsplash.RNBootSplash;
import com.datatheorem.android.trustkit.TrustKit;
import com.datatheorem.android.trustkit.reporting.BackgroundReporter;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

import javax.net.ssl.HttpsURLConnection;

import okhttp3.OkHttpClient;

// omitted code

@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Using the default path - res/xml/network_security_config.xml
    TrustKit.initializeWithNetworkSecurityConfiguration(this);

    URL url = new URL("https://172.30.200.168");
    String serverHostname = url.getHost();

    // HttpsUrlConnection
    HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
    connection.setSSLSocketFactory(TrustKit.getInstance().getSSLSocketFactory(serverHostname));
    
    // OkHttp 3.0.x, 3.1.x and 3.2.x
    OkHttpClient client =
      new OkHttpClient.Builder()
          .sslSocketFactory(OkHttp3Helper.getSSLSocketFactory())
          .addInterceptor(OkHttp3Helper.getPinningInterceptor())
          .followRedirects(false)
          .followSslRedirects(false);

    RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); // <- display the generated bootsplash.xml drawable over our MainActivity
  }
@gabimoncha
Copy link

gabimoncha commented Jun 9, 2021

If you open the project in Android Studio, the linter will show you what class to import.
Also, according to this issue #82 it seems that the code should be added in the MainApplication file, not MainActivity

@abreuthrj
Copy link

It's been a long time, but since I just ran through this issue, here is the solution I found:

The first line of the OkHttp3Helper.java file exposes the package name (https://github.com/datatheorem/TrustKit-Android/blob/master/trustkit/src/main/java/com/datatheorem/android/trustkit/pinning/OkHttp3Helper.java),

so try adding the following line:

import com.datatheorem.android.trustkit.pinning.OkHttp3Helper;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants