Desarrollando AOSP con Android Studio 3.1 No se puede construir apk de prueba para pruebas instrumentadas

Estoy tratando de construir un AOSP personalizado (en Android M, api 23) usando Android Studio porque quiero ejecutar pruebas instrumentadas en aplicaciones personalizadas que se ejecutan en el hardware. Esto está en ubuntu 64. Es muy frustrante para mí ya que no hay una ruta clara.

Mi meta Quiero seguir lapasos en esta guía del usuario AS para pruebas instrumentadas.

Ejecuté el script

~ / myAOSP / desarrollo / herramientas / idegen / intellij-gen.sh myApp company / apps / MY_APP

y abrió MY_APP.iml en Android Studio.

Ahora estoy tratando de construir el apk usando gradle solo para mi proyecto, y también el apk de prueba.

El myAOSP principal utiliza makefiles.

Seguí las instrucciones aquí y también usé build.gradle como plantillahttps: //developer.android.com/studio/intro/migrate#migrate-intelli

// This buildscript{} block configures the code driving the build
buildscript {
   /**
    * The nested repositories{} block declares that this build uses the
    * jcenter repository.
    */
    repositories {
        jcenter()
        google()
    }

   /**
    * This block declares a dependency on the 3.1.0 version
    * of the Gradle plugin for the buildscript.
    */
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

/**
 * This line applies the com.android.application plugin. Note that you should
 * only apply the com.android.application plugin. Applying the Java plugin as
 * well will result in a build error.
 */
apply plugin: 'com.android.application'

/**
 * This dependencies block includes any dependencies for the project itself. The
 * following line includes all the JAR files in the libs directory.
 */
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    // Add other library dependencies here (see the next step)
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
}

/**
 * The android{} block configures all of the parameters for the Android build.
 * You must provide a value for at least the compilation target.
 */
android {
    compileSdkVersion 23
    buildToolsVersion '27.0.3'
    defaultConfig {
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    /**
    * This nested sourceSets block points the source code directories to the
    * existing folders in the project, instead of using the default new
    * organization.
    */
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        androidTest.setRoot('tests')

       /**
        * Move the build types to build-types/<type>
        * For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        * This moves them out of them default location under src/<type>/... which would
        * conflict with src/ being used by the main source set.
        * Adding new build types or product flavors should be accompanied
        * by a similar customization.
        */
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
     }
}

repositories {
    jcenter()
    google()
}

También hubo un error de gradle: dado que Android M se está construyendo con JDK 1.7 pero Android Studio gradle usa 1.8, seguí los pasos pero tuve un error de gradle, no se pudo establecer la propiedad desconocida 'sourceCompatibility' para el proyecto raíz 'MY_PROJECT' de `type org.gradle.api.Project. docs.gradle.org/current/userguide/building_java_projects.html # en $ HOME / .gradle / gradle.properties javaHome = / Library / Java / JavaVirtualMachines / 1.7.0.jdk / Contents / Home

targetJavaVersion = 1.7 build.gradle sourceCompatibility = targetJavaVersion –`

Vi publicaciones comoDesarrollando AOSP con Android Studio pero están desactualizados o no son relevantes. Tambiénhttp: //ronubo.blogspot.com/2016/01/debugging-aosp-platform-code-with.html? view = magazine yError: (23, 17) Error al resolver: junit: junit: 4.12

Estoy buscando una solución funcional al problema de crear un apk de prueba instrumentada para una aplicación en AOSP personalizado y ejecutar pruebas instrumentadas en él, en Android Studio 3.1 (o posterior).

a) si es posible construir el apk de prueba instrumentado en gradle AS 3.1 (o posterior), sugiera una solución al error de gradle que se muestra.

b) si la construcción de gradle en a) anterior NO es posible, entonces, ¿necesito construir apk de prueba instrumentada usando los archivos MAKE actuales en el AOSP personalizado?

c) si construyo el apk de prueba instrumentada usando makefiles, ¿puedo seguir usando la interfaz de usuario de instrumentación en AS para ejecutar las pruebas en el hardware?

Respuestas a la pregunta(1)

Su respuesta a la pregunta