Developing AOSP with Android Studio 3.1 Não é possível criar apk de teste para testes instrumentados

Estou tentando criar um AOSP personalizado (no Android M, api 23) usando o Android Studio porque quero executar testes instrumentados em aplicativos personalizados em execução no hardware. Isso está no ubuntu 64. É muito frustrante para mim, pois não há um caminho claro.

Meu gol: Eu quero seguir oetapas neste guia do usuário do AS para testes instrumentados.

Eu corri o script

~ / myAOSP / development / tools / idegen / intellij-gen.sh empresa myApp / apps / MY_APP

e abriu MY_APP.iml no Android Studio.

Agora estou tentando criar o apk usando gradle apenas para o meu projeto e também o apk de teste.

O principal myAOSP usa makefiles.

Segui as instruções aqui e também usei o build.gradle como modelohttps://developer.android.com/studio/intro/migrate#migrate-intellij

// 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()
}

Houve também um erro de gradle: Como o Android M está sendo construído com o JDK 1.7, mas o Android Studio gradle usa 1.8, eu segui as etapas, mas com erro de gradle, Não foi possível definir a propriedade desconhecida 'sourceCompatibility' para o projeto raiz 'MY_PROJECT' do `org org .gradle.api.Project. docs.gradle.org/current/userguide/building_java_projects.html # em $ HOME / .gradle / gradle.properties javaHome = / Biblioteca / Java / Java / JavaVirtualMachines / 1.7.0.jdk / Conteúdo / Página inicial

targetJavaVersion = 1.7 build.gradle sourceCompatibility = targetJavaVersion –`

Vi posts comoDesenvolvendo AOSP com Android Studio mas estão desatualizados ou não são relevantes. Além dissohttp://ronubo.blogspot.com/2016/01/debugging-aosp-platform-code-with.html?view=magazine eErro: (23, 17) Falha ao resolver: junit: junit: 4.12

Estou procurando uma solução para o problema de criar um apk de teste instrumentado para um aplicativo no AOSP personalizado e executar testes instrumentados nele, no Android Studio 3.1 (ou posterior).

a) se for possível criar o apk de teste instrumentado no gradle AS 3.1 (ou posterior), sugerimos uma correção para o erro do gradle mostrado.

b) se a construção de gradle em a) acima NÃO for possível, então preciso criar apk de teste instrumentado usando os makefiles atuais no AOSP personalizado?

c) se eu criar o apk de teste instrumentado usando makefiles, ainda posso usar a interface do usuário da instrumentação no AS para executar os testes no hardware?

questionAnswers(1)

yourAnswerToTheQuestion