android studio编辑不了,Android Studio:模块不会显示在“编辑配置”中

Make sure your build.gradle is

apply plugin: 'com.android.application'

not

apply plugin: 'com.android.library'

After you have changed, please sync your gradle again.

hsbhu.png

I had similar issue when I selected parent directory of my project, I resolved by Close Project -> Delete Project from Android Studio -> Import Project by selecting right build.gradle file.

Make sure you select right build.gradle file while import.

I fixed this by adding facets in Module settings. They were missing.

right click on project > open Module settings > Facets > Add facets ( "+" sign at the top ) > Android.

After adding facets you will have modules.

UPDATE:

For latest version of gradle, Facets have been removed, you can directly add modules now.

right click on project > open Module settings > Add module ( "+" sign at the top ) > Phone and Tablet Application (Now you can create a new module and configure it).

In Android Studio 3.1.2 I have faced the same issue. I resolved this issue by click on "File->Sync Project with Gradle Files".This works for me. :)

resolved this issue by clicking on "File->Sync Project with Gradle Files"

I have tried all the options with no luck. So I have ended up with my working solution. Just make following steps:

Close android studio if open.

Copy module(project) in your current workspace.

Start android studio.

You will see added module in project structure.

Open settings.gradle of your project and include ':YOUR_MODULE_NAME'.

Sync gradle and you can see module is successfully added to your project.

goto Android >> Gradle Scripts>>Build Gradle(Module :app)

make sure the first line of this file is like this.

apply plugin: 'com.android.application'

not like this

apply plugin: 'com.android.library'

Try,

Files > Sync Project with Gradle Files

or

Files > Sync with File System

Should do the trick.

This worked for me: File > Project Structure... > Modules > Green Plus Symbol > Import > Then Select The Project

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

The following worked for me:

edit the overall project's 'settings.gradle' file and add a line at the bottom to include your new module (include ':myNewModule') - e.g:

include ':myNewModule'

Synch gradle.

Add a build.gradle file into your new module directory. You need to make sure the first line says 'apply plugin: 'com.android.application'. Simply copying a build.gradle from another module in your project, if you have one, seems to work.

Synch Gradle

Your module should now show up in 'Edit Configurations'

In your module build.gradle file make sure you have the correct plugin set. it should be

apply plugin: 'android'

It appears different solutions work for difference people, for me just closing the project and importing it again resolved the problem.

It was fixed for me after removing and re-adding the Android and Android-Gradle Facets in the Module Settings dialog.

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.

For me it was fixed by simply restarting Android Studio.. Like the good old days of Eclipse

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值