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

后端 未结 30 2095
情歌与酒
情歌与酒 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:25

    For me it was:

    1. Right click on app project folder & select Load/Unload Modules...

    2. Select app module, click Unload >, & click OK

    3. Right click on app again & select Load/Unload Modules...

    4. Select app module, click < Load, & click OK

    app then appeared for me in the configurations list again.

    0 讨论(0)
  • 2020-11-29 16:26

    Try,

    Files > Sync Project with Gradle Files or Files > Sync with File System Should do the trick.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-11-29 16:26

    In my case problem was from a higher (or not downloaded) compileSdkVersion and targetSdkVersion in build.gradle(app). This was happened because of cloning project in another pc that not downloaded that sdk image.

    0 讨论(0)
  • 2020-11-29 16:27

    The following are methods to help you:

    1. Close and Open Project again
    2. Close and Open Android Studio
    3. Clean Project
    4. Rebuild Project
    5. Instantiate and Restart
    6. Make sure you have included :app
    7. Import the Project
    0 讨论(0)
  • 2020-11-29 16:28

    This mainly happens when you copy a library project and try to build it. The solution would be to add

    apply plugin: 'com.android.application'
    

    in the build.gradle file, instead of

    apply plugin: 'com.android.library'
    

    Then do a gradle sync

    0 讨论(0)
提交回复
热议问题