Android Studio cannot detect project structure of a flutter project - android

Initially, I was looking why I could not open the emulator window, then I found out that the main reason for that was that android studio cannot detect flutter project structure automatically, due to the missing ".iml" files and ".idea" folder, due to which it does not know the existence of two modules i.e my_project and my_project_android.
Can anyone help me? Why is this happening?
Note:- Android studio can detect flutter project structure just fine if I create a project from my computer only, but since I am importing a project from GitHub, it cannot detect the appropriate project structure.
Below is how my modules section in the project structure looks, everything section is completely empty here.
Edit 1:-
Following are the picks on trying to import project inside modules
Edit 2:-
This is from where I import project directly from android studio using "Get from Version Control" than,
After this, I just click on clone and no more settings are asked(or required).

I found out that the project I was getting from VCS was flawed, it had gradle files in the flutter root folder and some more problems, eventually, I created a new flutter project after that I copied dart and other files and also updated some android files, and it worked.

Related

Android Studio : Open Android Module in Android Studio option is missing in flutter project

I am developing a flutter app for both iOS and Android. When generating the APK, I prefer to use Android studio (my default IDE is VSCODE). However, when I go to Tools > Flutter I do not see Open Android Module in Android Studio option. I do see Open iOS Module in Xcode.
I followed couple of SO answers, even tried replacing android.iml file from a working project. Nothing happened. I re-cloned my project from BitBucket because sometimes the Android Studio was fine when the project is freshly from repo, but this time, that didn't work either.
I Also tried opening the gradle file and looking for the option (as explained in one SO answer), that didn't work too.
However I noticed, few issues.
In the folder structure, the root folder is replaced by the flutter icon. in projects where I have no issues with, the folder icon is folder.
In here I see .dart_tool folder. In working apps with no issue, I do not see this folder.
I do not have an android.iml file. In other projects I did.
Below is my folder structure in a nutshell. Whats going on here and how to fix this issue?
When you don't see any options to
open module in android studio
because of missing .iml files caused by .gitignore file, follow simple steps.
Click on File and choose Open..
Now in the opened dialog choose android folder of example flutter project under your plugin module. For e.g if test is your plugin with example as it's app then you need to select and click Ok
test\example\android
3. Then wait for Android Studio to sync and download necessary jar files.
Simplest solution
Open flutter project
Go to android folder
open manfiest file
On the top right you will see option open module in android studio
click on this option
Solution 2:-
Import your android project as a project in android studio
The easiest way is to use this command in the root directory of your project, it will create some missing files and it will definitely work.
flutter create --platforms=android .
Now just right click to Android folder

How to import an Android Studio project from android.googlesource.com?

I'm trying to open the DeskClockApp (https://android.googlesource.com/platform/packages/apps/DeskClock/) in my version of Android Studio. However, since no gradle files are downloaded, Android Studio is struggling to see the project as an Android-Gradle app.
I've tried downloading the source code as a zip, importing it as Git from Android Studio's VCS, etc. The online repository doesn't have the gradle files b/c the developer added a gitignore for gradle (makes sense). I also considered adding the gradle files myself but the project structure seems to be slightly different than the structure defined online. When I first import that project it says Android Framework detected, however, on configuring it for Android it cannot find any module to run, or even display the correct files (in the Project view). Is there any way to generate the correct gradle files for this? Maybe run it without gradle?

Android Studio: I can not run/debug my project after cloning it from my repository

My HD died two days ago, luckily my android app is versioned on Bitbucket. So I got an SSD, reinstalled Windows 10 and the latest Android Studio. With Android Studio installed, I've cloned the project of my app through the 'Checkout project from Version Control' option in the welcome window of Android Studio. The project seems to have been cloned correctly, bringing all my source codes.
However, Android Studio was not able to create a Run / Debug configuration automatically. So, I tried to create a configuration by my own by clicking Edit Configurations> Add New Configuration (green cross) and choosing the option Android App. When choosing this option, the error 'Error: Module not specified' is showing below in the window, like Shows the image I attached.
This is the first time I have to clone my Android project from my repository and unfortunately I am not sure how to handle it. Can anybody help me?
Looks like you are missing the settings.gradle file. Create a new one in the project root folder with the following content:
include ':app'
include ':BaseGameUtils'
include ':squarecamera'
include ':volley'
I just guessed your modules, fix them in case they are not correct.

cloning project from Git in Android Studio

I'm using Android Studio 2, after migrating from Eclipse I pushed the project to a new repository. Now when I try to clone it ,it doesn't work.
After cloning it asks me :
Would you like to create a Studio project for the sources you have checked out to ?
I hit 'yes' and then "Import project from external model".
I can see then the project but I can't run it. I can't even sync with gradle files. This option is not existent.
Here is the official documentation to migrate an Eclipse project to an Android Studio: Migrating from Eclipse ADT. You should follow the step if you want your project to be usable under Android Studio since the project structure is a bit different betwwen the two environment.
You have to mantein this structure, with .idea and app directories directly in the root folder of your project, without any other wrapping folder.

How do I import/build this project?

I am not a dev, but have some dev experience. I have never used Android Studio before but I wanted to look at an example app. I picked one I am very interested in, but it gives me nothing but grief just trying to import it.
https://github.com/AltBeacon/android-beacon-library-reference
Notes:
I am using the latest version of Android Studio. (1.0.2). I have added in all the SDK files needed I think.
I have downloaded and un-zipped Gradle 2.2.1.
I am running Ubuntu 14.04.
I have dealt with Eclipse for Android previously and was able to
hack someone else's code to suit my needs and actually deploy an unsigned apk.
The readme/install directions at the github don't really help a noob
like me.
Install:
I have extracted the project from the Download Zip link.
For the actual import into Android Studio I choose "Open an Existing
Android Studio Project" - because it looks like one.
I then choose the root directory created by unzipping the zip file,
in this case it is named "android-beacon-library-reference-master".
But it seems to select the project's Gradle subfolder (/gradle) for the project! Which I'm quite certain is invalid. I cannot seem to get it to use the root
folder.
What am I missing? Or is this not the correct way to "import" this particular app? Is this app not compatible with AS 1.0.2?.
TIA!
In Android Studio, close any projects currently open. You should see the Welcome to Android Studio window.
1.Click Import Non-Android Studio project.
2.Locate the project you exported from Github, expand it, select the build.gradle file and click OK.
3.In the following dialog, leave Use gradle wrapper selected and click OK. (You do not need to specify the Gradle home.)
Android Studio properly updates the project structure and creates the appropriate Gradle build file.
Can you try "Import Project" instead "Open Project". Thanks.

Categories

Resources