title: Didn't find class on path: DexPathList for KeyGenParameterSpec$Builder
body: <p>I am using KeyGenParameterSpec to define my key specification. When I run the application I get the below error in logs:</p>
  
  <blockquote>
    <p>Caused by: java.lang.ClassNotFoundException: Didn't find class
    "android.security.keystore.KeyGenParameterSpec$Builder" on path:
    DexPathList[[zip file
    "/data/app/com.rsa.mobile.transactionsigningsdk-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64,
    /system/lib64]]</p>
  </blockquote>
  
  <p>Below is my MainActivity.java:</p>
  
  <pre><code> package com.rsa.mobile.transactionsigningsdk;
  import android.os.Bundle;
  import android.support.design.widget.FloatingActionButton;
  import android.support.design.widget.Snackbar;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.util.Log;
  import android.view.View;
  import android.view.Menu;
  import android.view.MenuItem;
  
  import com.rsa.mobile.transactionsigningsdk.enrollment.DeviceEnrollmentHelper;
  
  public class MainActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      Log.i("Testing message", "App started");
      DeviceEnrollmentHelper deh =new DeviceEnrollmentHelper();
      deh.enroll();
      Log.i("Testing message", "Job Done");
  
  
      FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                      .setAction("Action", null).show();
          }
      });
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Below is the code being called from the MainActivity.java:</p>
  
  <pre><code> public DeviceEnrollmentResponse enroll() {
  
      if(isEnrolled()) {
          return new DeviceEnrollmentResponse(null,StatusReasonCode.DEVICE_ALREADY_ENROLLED);
      }
      else{
          try {
              KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(
                      "RSA", "AndroidKeyStore");
  
              /*KeyPairGeneratorSpec spec = new KeyPairGeneratorSpec.Builder(android.content.Context this)
                      .setAlias("trsdk")
                      .setSubject(new X500Principal("CN=Sample Name, O=Android Authority"))
                      .setSerialNumber(BigInteger.ONE)
                      .setKeySize(KEY_SIZE)
                      .build();*/
              keyPairGenerator.initialize(
                      new KeyGenParameterSpec.Builder(
                              "trsdk",
                              KeyProperties.PURPOSE_SIGN)
                              .setAlgorithmParameterSpec(new ECGenParameterSpec("secp256r1"))
                              .setDigests(KeyProperties.DIGEST_SHA256,
                                      KeyProperties.DIGEST_SHA384,
                                      KeyProperties.DIGEST_SHA512)
                              .setUserAuthenticationRequired(true)
                              .build());
              KeyPair keyPair = keyPairGenerator.generateKeyPair();
              //Get the public key from the KeyPair
              PublicKey pk=keyPair.getPublic();
              //remove
              Log.i("Testing Message","Inside Enroll()");
              Log.i("Testing Message", String.valueOf(pk));
  
              //To Ask
              if (pk==null){
                  return new DeviceEnrollmentResponse(null, StatusReasonCode.UNKNOWN_ERR);
              }
              else{
                  return new DeviceEnrollmentResponse(pk, StatusReasonCode.DEVICE_SUCCESSFULLY_ENROLLED);
              }
  
              } catch (InvalidAlgorithmParameterException e) {
                  e.printStackTrace();
              } catch (NoSuchAlgorithmException e) {
                  e.printStackTrace();
              } catch (NoSuchProviderException e) {
                  e.printStackTrace();
              }
          }
      //To Ask
      return null;
  }
  </code></pre>
  
  <p>Below is my AndroidMaifest.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@style/AppTheme.NoActionBar" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>Below is the app build.gradle:</p>
  
  <blockquote>
    <p>apply plugin: 'com.android.application'</p>
    
    <p>android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"</p>
  
  <pre><code>defaultConfig {
      applicationId "com.rsa.mobile.transactionsigningsdk"
      minSdkVersion 14
      targetSdkVersion 23
      versionCode 1
      versionName "1.0"
  }
  buildTypes {
      release {
          minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
  } }
  </code></pre>
    
    <p>dependencies {</p>
  
  <pre><code>compile ('com.thoughtworks.xstream:xstream:1.4.7'){
          exclude group: 'xmlpull'
  }
  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
  compile 'com.android.support:appcompat-v7:23.1.0'
  compile 'com.android.support:design:23.1.0' }
  </code></pre>
  </blockquote>
  
  <p>Below is the stacktrace of the errors:</p>
  
  <blockquote>
    <p>11-24 11:07:52.485 27882-27882/? E/AndroidRuntime: Process:
    com.rsa.mobile.transactionsigningsdk, PID: 27882 11-24 11:07:52.485
    27882-27882/? E/AndroidRuntime: java.lang.NoClassDefFoundError: Failed
    resolution of: Landroid/security/keystore/KeyGenParameterSpec$Builder;
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    com.rsa.mobile.transactionsigningsdk.enrollment.DeviceEnrollmentHelper.enroll(DeviceEnrollmentHelper.java:82)
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    com.rsa.mobile.transactionsigningsdk.MainActivity.onCreate(MainActivity.java:27)
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.Activity.performCreate(Activity.java:6088) 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2416)
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.ActivityThread.access$900(ActivityThread.java:154) 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322)
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.os.Handler.dispatchMessage(Handler.java:102) 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.os.Looper.loop(Looper.java:135) 11-24 11:07:52.485
    27882-27882/? E/AndroidRuntime:     at
    android.app.ActivityThread.main(ActivityThread.java:5290) 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    java.lang.reflect.Method.invoke(Native Method) 11-24 11:07:52.485
    27882-27882/? E/AndroidRuntime:     at
    java.lang.reflect.Method.invoke(Method.java:372) 11-24 11:07:52.485
    27882-27882/? E/AndroidRuntime:     at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699) 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:  Caused by:
    java.lang.ClassNotFoundException: Didn't find class
    "android.security.keystore.KeyGenParameterSpec$Builder" on path:
    DexPathList[[zip file
    "/data/app/com.rsa.mobile.transactionsigningsdk-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64,
    /system/lib64]] 11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:<br>
    at
    dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    java.lang.ClassLoader.loadClass(ClassLoader.java:511) 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    java.lang.ClassLoader.loadClass(ClassLoader.java:469) 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    com.rsa.mobile.transactionsigningsdk.enrollment.DeviceEnrollmentHelper.enroll(DeviceEnrollmentHelper.java:82) 
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    com.rsa.mobile.transactionsigningsdk.MainActivity.onCreate(MainActivity.java:27) 
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.Activity.performCreate(Activity.java:6088)  11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2416) 
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.ActivityThread.access$900(ActivityThread.java:154)  11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322) 
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.os.Handler.dispatchMessage(Handler.java:102)  11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    android.os.Looper.loop(Looper.java:135)  11-24 11:07:52.485
    27882-27882/? E/AndroidRuntime:     at
    android.app.ActivityThread.main(ActivityThread.java:5290)  11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    java.lang.reflect.Method.invoke(Native Method)  11-24 11:07:52.485
    27882-27882/? E/AndroidRuntime:     at
    java.lang.reflect.Method.invoke(Method.java:372)  11-24 11:07:52.485
    27882-27882/? E/AndroidRuntime:     at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) 
    11-24 11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)  11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:  Suppressed:
    java.lang.ClassNotFoundException:
    android.security.keystore.KeyGenParameterSpec$Builder 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    java.lang.Class.classForName(Native Method) 11-24 11:07:52.485
    27882-27882/? E/AndroidRuntime:     at
    java.lang.BootClassLoader.findClass(ClassLoader.java:781) 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    java.lang.BootClassLoader.loadClass(ClassLoader.java:841) 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:     at
    java.lang.ClassLoader.loadClass(ClassLoader.java:504) 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:          ... 16 more 11-24
    11:07:52.485 27882-27882/? E/AndroidRuntime:  Caused by:
    java.lang.NoClassDefFoundError: Class not found using the boot class
    loader; no stack available 11-24 11:07:52.485 32736-32736/?
    D/AsyncTaskServiceImpl: Submit a task: k 11-24 11:07:52.487
    27882-27882/? D/AppTracker: App Event: crash 11-24 11:07:52.487
    1092-22412/? W/ActivityManager: getRunningAppProcesses: caller 10156
    does not hold REAL_GET_TASKS; limiting output 11-24 11:07:52.489
    1092-10061/? W/ActivityManager: getRunningAppProcesses: caller 10156
    does not hold REAL_GET_TASKS; limiting output 11-24 11:07:52.490
    32736-27837/? D/k: Processing package:
    com.rsa.mobile.transactionsigningsdk 11-24 11:07:52.490 32736-32736/?
    D/ChimeraCfgMgr: Loading module com.google.android.gms.vision from APK
    com.google.android.gms 11-24 11:07:52.492 1092-4065/? D/WifiService:
    Client connection lost with reason: 4 11-24 11:07:52.503 1092-4736/?
    W/ActivityManager:   Force finishing activity 1
    com.rsa.mobile.transactionsigningsdk/.MainActivity 11-24 11:07:52.505
    13111-13111/? E/NetworkScheduler.SchedulerReceiver: Invalid parameter
    app 11-24 11:07:52.505 13111-13111/?
    E/NetworkScheduler.SchedulerReceiver: Invalid package name : Perhaps
    you didn't include a PendingIntent in the extras? 11-24 11:07:52.520
    1092-27935/? D/DropBoxManagerService: file ::
    /data/system/dropbox/data_app_crash@1448343472518.txt 11-24
    11:07:52.535 1092-1169/? W/ActivityManager:  Dismiss app error dialog
    : com.rsa.mobile.transactionsigningsdk 11-24 11:07:52.537
    27882-27882/? I/Process: Sending signal. PID: 27882 SIG: 9 11-24
    11:07:52.549 32736-27837/? D/GassUtils: Found app info for package
    com.rsa.mobile.transactionsigningsdk:1. Hash:
    b6b6c7a4a5de3ea7df9c51284188b1040033e02a491ec95fee9371f7817bc00c 11-24
    11:07:52.549 32736-27837/? D/k: Found info for package
    com.rsa.mobile.transactionsigningsdk in db. 11-24 11:07:52.562
    1092-10061/? I/ActivityManager: Start proc 27936:com.yatra.base/u0a143
    for broadcast com.yatra.base/com.moe.pushlibrary.AppUpdateReceiver
    11-24 11:07:52.562 367-367/? E/lowmemorykiller: Error writing
    /proc/27882/oom_score_adj; errno=22 11-24 11:07:52.581 1092-22411/?
    I/ActivityManager: Process com.rsa.mobile.transactionsigningsdk (pid
    27882) has died 11-24 11:07:52.582 1092-1163/? V/ActivityManager:
    killProcessGroupAsync took 0 ms for PID 27882 on thread 16 11-24
    11:07:52.587 27936-27936/? W/ResourcesManager: Asset path
    '/system/framework/com.google.android.maps.jar' does not exist or
    contains no resources. 11-24 11:07:52.601 27936-27936/? I/MultiDex: VM
    with version 2.1.0 has multidex support 11-24 11:07:52.601
    27936-27936/? I/MultiDex: install 11-24 11:07:52.601 27936-27936/?
    I/MultiDex: VM has multidex support, MultiDex support library is
    disabled. 11-24 11:07:52.601 27936-27936/? I/MultiDex: install 11-24
    11:07:52.601 27936-27936/? I/MultiDex: VM has multidex support,
    MultiDex support library is disabled. 11-24 11:07:52.614 27936-27936/?
    D/MoEngage_v510: MoEController:Context is null cannot bind service
    now. 11-24 11:07:52.616 1092-1181/? W/WindowManager: Failed looking up
    window 11-24 11:07:52.616 1092-1181/? W/WindowManager:
    java.lang.IllegalArgumentException: Requested window
    android.view.ViewRootImpl$W@35e88e7 does not exist 11-24 11:07:52.616
    1092-1181/? W/WindowManager:     at
    com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8708)
    11-24 11:07:52.616 1092-1181/? W/WindowManager:     at
    com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8699)
    11-24 11:07:52.616 1092-1181/? W/WindowManager:     at
    com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2620)
    11-24 11:07:52.616 1092-1181/? W/WindowManager:     at
    com.android.server.wm.Session.remove(Session.java:187) 11-24
    11:07:52.616 1092-1181/? W/WindowManager:     at
    android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:3015)
    11-24 11:07:52.616 1092-1181/? W/WindowManager:     at
    android.view.ViewRootImpl.doDie(ViewRootImpl.java:5502) 11-24
    11:07:52.616 1092-1181/? W/WindowManager:     at
    android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3321)
    11-24 11:07:52.616 1092-1181/? W/WindowManager:     at
    android.os.Handler.dispatchMessage(Handler.java:102) 11-24
    11:07:52.616 1092-1181/? W/WindowManager:     at
    android.os.Looper.loop(Looper.java:135) 11-24 11:07:52.616 1092-1181/?
    W/WindowManager:     at
    android.os.HandlerThread.run(HandlerThread.java:61) 11-24 11:07:52.616
    1092-1181/? W/WindowManager:     at
    com.android.server.ServiceThread.run(ServiceThread.java:46) 11-24
    11:07:52.618 27936-27936/? I/MoEngage_v510: MoEUtils: SDK initialized.
    MoEngage SDK version: 510 11-24 11:07:52.618 1092-22411/?
    W/InputMethodManagerService: Window already focused, ignoring focus
    gain of:
    com.android.internal.view.IInputMethodClient$Stub$Proxy@34f79c48
    attribute=null, token = android.os.BinderProxy@132d42ec</p>
  </blockquote>
  
  <p>Can anyone help out please: I have tried out cleaning the project, re-importing it as suggested in related questions.
  Thanks in advance!</p>