Android Studio: Module won't show up in “Edit Configuration”

后端 未结 30 2157
情歌与酒
情歌与酒 2020-11-29 15:38

I\'ve imported a project to Android Studio with several subprojects.

I want to run a subproject.

I successfully made this subproject\'s build.gradle as a mo

30条回答
  •  醉话见心
    2020-11-29 16:26

    I finally figure out why the module is not showed up when I add configuration for AndroidTests for a com.android.library module.

    If you include your library module in your application's build.gradle like this:

    compile project(':yourlibrary')
    

    Since for library module it is compiled with release mode by default, you can't run Android Tests for it, that's why it won't show up in the module list. I fixed it with following modification:

    Add following configuration to the build.gradle of your library module:

         publishNonDefault true
    

    By make following changes, you can debug compile your library by editing the build.gradle of your application module like following:

    -    compile project(':yourlibrary')
    +    debugCompile project(path: ':yourlibrary', configuration: 'debug')
    +    releaseCompile project(path: ':yourlibrary', configuration: 'release')
    

    Then sync it and you'll find it shows in the list.

提交回复
热议问题