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

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?

Related

Convert Gradle/Kotlin project to Android Project

I created a kotlin project with the command gradle init, which I can build and run without issues. I know AndroidStudio uses gradle to build/deploy an android project. With this in mind, can i modify the generated kotlin project to also become an android project? I want that when gradle build is issued, an apk file is generated, instead of the jar being generated right now. And, if possible, being able to deploy the apk to the phone connected to the computer (either via usb or wi-fi).
You actually can, just add the AGP (Android Gradle Plugin) to your build.gradle script.
And from there, structure your project to as Android Project.
Of course it's like manual type of doing it, It's easier just to start an Android Project from Android Studio cause it will generate all the files needed for Android Project.

Android Studio cannot detect project structure of a flutter project

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.

Why Android Studio is ignoring files in git repo and how to import a project from git?

Currently, I'm trying to work with a git server hosted at my company. When I'm initiating the git inside my Android projet root directory, there's some files automaticaly ignored, why ?
Next, when I clone my project in another computer (with a different OS and a different SDK installation path) and when I try to import the cloned project, Android Studio seems to not find a proper existing project : I see the gradle icon instead of the Android Studio icon :
Project import screenshot
How can I make a proper import ?
Thanks for your answers.
IDE project files are meant to be ignored. These files usually contain local configuration files, like paths and configuration to run and build software depending on your machine/OS.
Importing a gradle project should result in a new Android Studio / IntelliJ project. About the files that are ignored, those should be the local build files that I mentioned.
Do you experience issues when you are just importing the project?

Import Sibling Module in Android Studio

I have an Android project recently converted to Gradle from Maven/IntelliJ. The project has a traditional maven structure with the app and sdk projects being sibling projects referenced through the nexus. I can import either of the projects into Android Studio correct and build them, but when I try to import the SK as a module into the app project (which is what we did in IntelliJ) Android Studio basically refuses to import it. I'm using Android Studio 0.8.2. The actual error I get is either
Specify location of the Gradle or Android Eclipse project
if I select the SDK's .iml file or
Select modules to import
if I select the build.gradle file or the root directory.
I would like to avoid converting to the current Gradle super project mechanism because that would require new source control and would lose valuable history.
What I have tried:
Separate projects, works but doesn't allow SDK debugging and generally is a pain to manage due the multiple windows.
Using an empty super project. This gets both projects in the same windows, but Android Studio no longer detects the project's source controls. IntelliJ would correctly identify the sibling source controls in the previous configuration.
Is there any way to get Module Import to work in Android Studio like in IntelliJ?

Android Studio 0.4.3 Eclipse project without gradle

Prior to this version it seemed easy to open an eclipse project as-is in Android Studio without any conversion. I prefer the Android Studio environment, but am working on a project that uses eclipse as the main IDE. I'd rather not have to download the eclipse bundle just for this one project.
Is there any way to open an eclipse project as-is, without conversion to the gradle build system, in Android Studio 0.4.3?
EDIT:
It appears that if you use Android Studio's download from source control feature, it'll let you open the project that way. But what if I already have the source downloaded? I don't want to remove it just to redownload it again. It seems like this option has disappeared from the main 'import' wizard.
We're strongly encouraging users to move toward the Gradle build system, and we're in the slow process of making that the only way to create new projects in Android Studio -- you're seeing this now on importing Eclipse-based projects. We'd like to replace all other build systems in use with Gradle, including Ant and the Eclipse internal builder, though the latter two are farther out on the roadmap.
If your ultimate goal is to move to Android Studio, then you might want to reconsider and just set up a Gradle build file. You don't have to adopt the Gradle-style multimodule project structure (which the current Eclipse importer imposes upon you by making a copy of your project); you can rework your build.gradle file to use the Eclipse-structured project in-place. You can get a good start on this if from Eclipse you use the feature to export your project to Gradle build files. It will set up the project in that fashion, though that feature in ADT is a little out of date and you'll need to update the version of the Android Gradle plugin in the build file and the Gradle version in the wrapper that it outputs.
I think this may actually solve your problem. IntelliJ or Android Studio have never been able to use the Eclipse project directly -- they've always imported the Eclipse project and converted to an IntelliJ-style project, and if you later change the Eclipse project, you'll need to re-import into IntellilJ-land. I'm guessing your real desire is to use the Eclipse project in Android Studio without having it make a copy and converting into its preferred directory structure. (By the way, we'll eventually improve Eclipse-to-Gradle import to lift this restriction).
Once you have the Gradle build file in place, you can use it when working with the project in Android Studio, and you'll still have the Eclipse project files when working with it in Eclipse. The big drawback is that you'll have to keep them in sync as you change dependencies and project structure, but hopefully that doesn't happen too often. Even if you weren't using Gradle, you'd still need to keep both projects in sync anyway, so Gradle isn't costing you anything there.
Having said all that, it doesn't directly answer your question, which is how to use the your project without Gradle.
Once you have an IntelliJ-built project, you can open it in Android Studio and use it normally without migrating to Gradle (though I think it does show you a popup when opening the project recommending you do so; you can ignore that). What you need to do is to get that initial IntelliJ project, and once you have it, check all the .iml files into source control -- those .iml files contain all the project information. To get those files, you'll need to import the Eclipse project either in IntelliJ CE, or in Android Studio prior to 0.4.0. Then you'll have your .iml files -- hang on to them.
I'll point out that if you're using Gradle as your build system, we recommend that you don't check those .iml files into source control. There, the build.gradle files are the source of truth for project structure; the fact that Android Studio creates .iml files at all is an implementation detail that reflects that internally Android Studio is still treating this project as an import instead of deriving structure from the Gradle files directly (and we resynchronize state when we know we need to). But saving those .iml files into source control or modifying them directly will lead to confusion or loss of any changes you make there when it resynchronizes.
I think you should give a try to Intellij Idea with ADT Plugin instead of Android Studio, if such requirements are there. Intellij IDEA will support both type of Android projects.
What If I want to move to Android Studio completely sometime?
There is nothing new in Android Studio it is just an IDE based on Intellij IDEA. You can easily switch between Intellij IDE and AS anytime. The only thing is to learn in AS is the new gradle build system. IDE related most of the features are there in Intellij IDE as well.
If you want to move Android Studio start using gradle Build System. That is only the main power of new Tools.
As per your question you don't wanna move your project in gradle then you can have both IDE together like Intellij IDEA at place of Eclipse and Android Studio as well. Msot of the Developer including me having Eclipse along with Android Studio.
EDIT :
I found a workaround to import Eclipse project in Android Studio but I will not recommend you to do this
Look at my answer here
Not Use Gradle In Android Studio

Categories

Resources