scottyab / safetynethelper

SafetyNet Helper wraps the Google Play Services SafetyNet.API and verifies Safety Net API response with the Android Device Verification API.
333 stars 79 forks source link

Failed resolution of: Lcom/google/android/gms/safetynet/SafetyNetApi$AttestationResult #47

Closed ghena closed 3 years ago

ghena commented 3 years ago

Hi, I'm using a safetynetlib-release-v0.3.aar

this is my implementation:

` private void checkSafetyNet() {

    final SafetyNetHelper safetyNetHelper = new SafetyNetHelper("myapikey");

    safetyNetHelper.requestTest(this, new SafetyNetHelper.SafetyNetWrapperCallback() {
        @Override
        public void error(int errorCode, String msg) {
            //handle and retry depending on errorCode
            Log.e(TAG, msg);
        }

        @Override
        public void success(boolean ctsProfileMatch, boolean basicIntegrity) {
            if (ctsProfileMatch) {
                Log.e(TAG, "ProfileMatch");
                //profile of the device running your app matches the profile of a device that has passed Android compatibility testing.
            } else if (basicIntegrity) {
                //then the device running your app likely wasn't tampered with, but the device has not necessarily passed Android compatibility testing.
                Log.e(TAG, "basicIntegrity");
            } else {
                //handle fail, maybe warn user device is unsupported or in compromised state? (this is up to you!)
                Log.e(TAG, "FAILED");
            }
        }
    });

    }`

But I get:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.myapp, PID: 9697 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/safetynet/SafetyNetApi$AttestationResult; at com.scottyab.safetynet.SafetyNetHelper$1.onResult(SafetyNetHelper.java:121) at com.google.android.gms.common.api.internal.BasePendingResult$CallbackHandler.handleMessage(Unknown Source:10) at android.os.Handler.dispatchMessage(Handler.java:106) at com.google.android.gms.internal.base.zap.dispatchMessage(Unknown Source:8) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6711) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.safetynet.SafetyNetApi$AttestationResult" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.myappSnawgpdOpiE20CcOc0oO_Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-SnawgpdOpiE20CcOc0oO_Q==/lib/arm64, /data/app/com.myapp-SnawgpdOpiE20CcOc0oO_Q==/base.apk!/lib/arm64-v8a, /system/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

Regards.

ghena commented 3 years ago

Solved generating a new release aar.