热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

使用AndroidStudio3.1开发AOSP无法为仪表化测试构建测试apk

如何解决《使用AndroidStudio3.1开发AOSP无法为仪表化测试构建测试apk》经验,是哪儿的问题?

我正在尝试使用Android Studio构建定制的AOSP(在Android M,api 23上),因为我想对在硬件上运行的自定义应用程序运行检测测试.这是在ubuntu 64.这对我来说非常令人沮丧,因为没有明确的切入路径.

我的目标:我想按照本AS用户指南中的步骤进行仪表化测试.


我运行了脚本

〜/ myAOSP/development/tools/idegen/intellij-gen.sh myApp公司/ apps/MY_APP

并在Android Studio中打开了MY_APP.iml.

现在我正在尝试使用gradle为我的项目构建apk,以及测试apk.

主要的myAOSP使用makefile.

我按照这里的说明进行操作,并使用build.gradle作为模板https://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/
        * For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        * This moves them out of them default location under src//... 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()
}

还有一个gradle错误:由于Android M是使用JDK 1.7构建的,但Android Studio gradle使用1.8,我按照步骤但有gradle错误,无法为`type org的根项目'MY_PROJECT'设置未知属性'sourceCompatibility' .gradle.api.Project.$ HOME/.gradle/gradle.properties中的docs.gradle.org/current/userguide/building_java_projects.html#javaHome =/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

targetJavaVersion = 1.7 build.gradle sourceCompatibility = targetJavaVersion -`

我看过像Android Studio开发AOSP这样的帖子,但它们已经过时或不相关.另外http://ronubo.blogspot.com/2016/01/debugging-aosp-platform-code-with.html?view=magazine和错误:(23,17)无法解决:junit:junit:4.12

我正在寻找一个有效的解决方案,解决在Android Studio 3.1(或更高版本)中为自定义AOSP中的应用程序构建检测测试apk并在其上运行检测测试的问题.

a)如果可以在gradle AS 3.1(或更高版本)中构建检测测试apk,那么请建议修复显示的gradle错误.

b)如果上面的a)中的gradle构建是不可能的,那么我是否需要使用定制AOSP中的当前makefile构建仪器化测试apk?

c)如果我使用makefile构建仪表化测试apk,那么我仍然可以使用AS中的仪器UI来运行硬件上的测试吗?


推荐阅读
author-avatar
一夜知秋50050
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有