title: Sign library before running Junit Android
body: <p>I'm developing unit test using <code>JUnit 4</code> on Android studio, but I need to sign the <strong>library</strong> before running tests to each function of the library to be accepted on my device. I'm trying the following:</p>
  
  <p><strong>build.gradle</strong></p>
  
  <pre><code>android {
      signingConfigs {
          config {
              keyAlias 'xxxxx'
              keyPassword 'xxxxx'
              storePassword 'xxxxxx'
              storeFile file('cert/platform.jks')
          }
      }
      compileSdkVersion 26
      buildToolsVersion '26.0.2'
      testBuildType "debug"
      defaultConfig {
          minSdkVersion 17
          targetSdkVersion 26
          versionCode 1
          versionName "1.111"
          externalNativeBuild {
              cmake {
                  cppFlags "-fexceptions"
              }
          }
          signingConfig signingConfigs.config
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  
      }
      externalNativeBuild {
          cmake {
              path "CMakeLists.txt"
          }
      }
      flavorDimensions "api"
      productFlavors {
          minApi17 {
              dimension "api"
              ndk.with {
                  moduleName = 'FAL'
                  abiFilters = ["armeabi"]
              }
              signingConfig signingConfigs.config
          }
      }
      testOptions {
          unitTests {
              includeAndroidResources = true
          }
      }
  
      buildTypes {
          debug {
              signingConfig signingConfigs.config
          }
          release {
              signingConfig signingConfigs.config
          }
      }
  }
  
  dependencies {
      androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
          exclude group: 'com.android.support', module: 'support-annotations'
      })
      implementation files('libs/zxing-2.3.0.jar')
      implementation 'com.android.support:appcompat-v7:26.1.0'
      implementation 'com.android.support.constraint:constraint-layout:1.0.2'
  }
  </code></pre>
  
  <p>I'm using this portion of code, but the application don't work in device (Certification error). What is the proper way to sign the application before running the test?</p>