I am new to Android Studio.This is my project screenshot.My project builds successfully but when i run it only Build Successful is shown.
By what I understand I think where build is written in the toolbar there should be my project name.When I go to Edit Configuration inside Module there is only one option that is No Module while I think my project name should be there.When I right click on my project and click on Make Module 'Copy of IBL2 eclipse' nothing happens.This project was running fine in eclipse.
This question is related to
android
android-studio
In the "project" page on the top left corner in android studio.
From dropdown 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'
I had the same issue since I changed my app ID in config.xml file.
I used to open my Android project by choosing among recent projects of Android Studio.
I just File > Open > My project to get it working again.
Other path is " tool menu-->android-->sync proyect with gradle File"
CHECK if the project setting is like this,if the module that you want is show in here
IF the module that you want or "Module SDK" is not show or not correct.
then go to the module's build.gradle file to check if the CompileSdkVersion has installed in your computer.
or modifier the CompileSdkVersion to the version that has been installed in your computer.
In my case:I just installed sdk version 29 in my computer but in the module build.gradle file ,I'm setting the CompilerSdkVersion 28
Both are not matched.
Modifier the build.gradle file CompilerSdkVersion 29 which I installed in my computer
It's working!!!
For some reason, I was missing the settings.gradle
file.
settings.gradle
under your root directory, and inside it:include ':app'
(assuming your app is indeed inside /app
directory).
File
-> Sync Project with Gradle Files
.
After that everything worked out for me.
I was able to resolve this issue by performing a Gradle sync
To do this:
In project view, right click the root (in my example below, "JamsMusicPlayer"
Click "Synchronize {ProjectName}"
Once this completes, you should see a module in your "Run" dialog
For me the sdk version mentioned in build.gradle wasn't installed. Used SDK Manager to install the right SDK version and it worked
Try first in Android Studio:
File -> Sync Project with Gradle Files
Check for the file gradle.properties
in your project root folder. If not there, create a new file with the name / copy the file from other project.
Open and check both the build.gradle file and confirm you have have any error in those files.
Then, Click on the File
menu -> Sync project with Gradle Files
.
I had a similar issue of my app module disappearing, this was after a large merge (from hell). I found app.iml
was missing <component name="FacetManager">
when compared with other projects and before the merge. So I copy and pasted the below under the root <module >
element.
Manually editing the .iml files maybe ill advised so proceed at your own risk.
File: project root folder > app > app.iml
Add the following...
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/src/debug/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
Sometimes the following fix will work. Go to your build.gradle of your project and add google() into the repositories element and google() should be the at the top of all the repository.
This is the sample of the repositories block. What you need to do is to add google() or if that exists already, take that to the top of all the line inside repositories
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
}
I had the same issue when using Kotlin DSL. The project level build.gradle.kts file seemed to be causing problems in that Android Studio could not detect it. What solved this for me was:
Rename build.gradle.kts -> build.gradle
File -> Sync Project with Gradle Files
Rename build.gradle -> build.gradle.kts
Hope it helps.
If you have imported the project, you may have to re-import it the proper way.
Steps :
Tested on AndroidStudio version 1.0.1
Source: Stackoverflow.com