I was using a project as module dependency in Android Studio. I no longer now need it. So I removed the dependency from build.gradle file and then committed and pushed it. When i take a fresh check out using git in Android Studio, i am able to see that module, even though that is not being used by my project. If i check on the git site, the folder is still there. I think i need to delete it from the cache of the git which maintain the history of this. But I do not know the commands to run in the Android studio terminal to completely remove it from git respository.
Project Structure
Project
|
-app
-build.gradle(removed dependency of module 1)
-Module1
-Module2
-module3
-settings.gradle(removed module1)
Want to remove module1 from the git. Please let me know the commands.
Related
I try to build and run the sample helloworld/mobile in project (https://github.com/android/car-samples)
My question is about how to select the sample app directory as described in README.md:
Select a sample app directory (e.g. helloworld/mobile) in the Project Structure UI on the top left. Each sample app has two build targets, one for the mobile platform and the other for the automotive platform.
<<<<
I went through Project Structure UI, I tried different possibilities but no way,
Build menu always shows Make Module car-simples-main and when I launch Make Module, nothing happens.
Wondering if something has changed in the last Android Studio version,
I use Android Studio Chipmunk | 2021.2.1 Patch 1
Anyone can help?
Thanks.
First of all, let's understand how the git directory is structured.
The directory has the two folders car-lib/CarGearViewerKotlin and car_app_library, which are gradle projects that can be built using gradle.
How do you know?
Any folder contains gradle wrapper and a build.gradle and settings.gradle files means that they're ready to be built using gradle, and these can contain modules inside of them.
Now helloworld/mobile is a module, or you can view it as a sub-project.
How do you know?
If you open up the parent's settings.gradle file, you will see the line include ':helloworld:mobile' meaning that the directory helloworld/mobile is a sub-project or module for the top level car_app_library project.
Modules by themselves are not runnable, they need to be contained in a parent project with top-level gradle files.
Now the solution for your problem should be: open up these two as projects in Android studio individually: car-lib/CarGearViewerKotlin and car_app_library, it will create a default run configuration for each project.
You won't be able to run helloworld/mobile alone, you'll need to run the parent project car-samples/car_app_library.
However, You should technically be able to open the root directory (the git directory containing all of the projects) and creating a run configurations by hand for each project, and you should be able to run the projects using one Android Studio window opened.
No matter what projects I import they never work - Android Studio is always flagging this is not a Gradle build project.
I select VCS -> GIT and clone the repo without any problem. I then go through the wizard with no issues (I select create project from existing sources), creating my code base with a warning, below. When i try to run throws all sorts of errors.
Migrate Project to Gradle? This project does not use the Gradle build
system. We recommend that you migrate to using the Gradle build
system. More Information about migrating to Gradle.
Don't show this message again.
When I go to the link it makes no sense whatever to me, it says to create an arbitrary Gradle file and populate it with my references (I think), which is out of my understanding. I shouldnt have to do this as it says in the repository instructions that it is in fact a Gradle-based project.
The project I am trying to clone is
https://github.com/googlesamples/android-play-location.git
Can anybody tell me specifically how to import and run the following git repo in Android studio for example?
Ok from the start (as i dont know what other way works)
Go to Git master page (it has 'download to zip' or 'clone to desktop' button). use https://github.com/googlesamples/android-play-location as a test master page if you like to ensure you have no other issues i did not.
Click 'download zip'
Unzip the project
Close the current project in Android Studio -> File/Close Projects
A popup screen like this will appear, choose Import Project (Eclipse ADT, Gradle etc.)
You will be asked to select the project, select your unzipped project within the master folder, eg basicLocation
Select 'create project from existing resources' default
dont change project name (may cause issues)
Next through 'import project -> directories'
Next through project -> libraries
Next Through import projects -> modules and module dependencies
Next through import project ->SDK
Next through import project ->manifest.xmls
Android Studio starts. Ensure the configurations dropdown has a project in it called 'app' app
Select 'sync Gradle' icon (green circle)
May get language warning, ignore or accept restart, doesnt matter
At bottom it should now say 'Gradle executing tasks' after which it will run on device or emulator :)
Short answer: File > Open > the build.gradle file you just cloned with the repo
I just wanted to add this, because I had the same problem, and even if Fearghal´s answer and comments pointed me in the right direction, I think he may have added unnecesary extra steps, i.e. Download as ZIP, Close current project, etc.
Simply put, you VCS > Git Clone, and then open the build.gradle file. That´s it
This can happen for many reasons. I typically see it when I move the directory. The easiest way I have found is to close the project and then reopen it using "Import project (Gradle, Eclipse, ADT, etc.) menu item then selecting the folder. This will force it to reimport the project and fix any metadata/configs.
What worked for me was
On Android Studio
Open the settings.gradle file
include your project
include ':myproject'
Well, as Android Studio correctly says, https://github.com/googlesamples/android-play-location is not a Gradle project.
Any subdirectory of that repository is however.
They are different projects.
So clone that repository and import one of its subdirectory in Gradle.
I have a setup of android project on eclipse and I want to migrate to Android Studio. So, I have android-support-v4.jar that I use for my main project and my Facebook lib-project.
I guess I have to exclude lib-projects as a folder in my main module (lets call the main module Jack). Jack has dependancy on the facebook lib-project.
How should I define the android-support-v4.jar as a separate library and use it in both projects? Or should I just use directly the jar files and leave them in both Jack's libs folder and Facebook libs folder?
If the first option should be done, will ant clean release still work (with the build.xml android generated file)?
In Android Studio, builds are done with Gradle now. Gradle is different. With gradle, you tell your project which jar's you need, and it will connect to a server and download them if it doesn't already have them when you compile your apk.
A few things to note:
When you install Android Studio, it has it's own Android sdk directory. You have to download everything from the sdk downloader (from inside the Android Studio App) again. Don't bother trying to switch the sdk download path to your current one. You will only encounter bugs (Or at least I did).
So your question is worded very confusingly. It sounds like you have a main module, and then you have a library module, and the library module uses the support library.
You'll need to set it up so the main module has a dependency on your library module. From there, you'll need to go into your library module's gradle file and tell it that you want to include the android support library
dependencies {
compile 'com.android.support:appcompat-v7:19.0.0'
}
The support library is a little weird in gradle. Gradle normally would download the dependencies you need. However, android studio requires that you have the support library installed through their sdk downloader (top-right group of icons in android studio. The download icon).
After you get all your dependencies entered into your gradle file, you'll then need to go to Tools -> Android -> Sync gradle files with project. From there compile errors should go away, and you should be able to run the project.
Best of luck. By the way, Here is the documentation on Gradle on the android website. I find myself having to go to it A LOT, especially when I made the switch from Eclipse to Android Studio. This + Various tutorials I found as needed via google. http://tools.android.com/tech-docs/new-build-system/user-guide
EDIT: This link might also be helpful. Google has some steps for switching from eclipse to Android Studio: http://developer.android.com/sdk/installing/migrate.html That with some of the stuff above may prove helpful.
While I haven't tried this myself, I suggest you use the recommended migration steps provided by Google in this article.
Before you do that, though, make sure that you either:
Check that both support libraries on the main project and dependencies have the same version (Eclipse will complain about it during build time, and will likely cause problems during conversion to Gradle script.); OR,
Uncheck the "Android Private Libraries" entry on the Order and Export tab of the dependency project's build settings.
If the migration process described doesn't work smoothly for you, you can always call the Ant build script from within the Gradle script, as described here.
The Android Studio uses only Gradle, but you can export Android ant project from eclipse.
To do that go to File -> import project usually next, next, next... works.
If not go to project setting Shift + Ctrl + Alt + S and under modules -> PROJECT_NAME -> Dependencies you can add your support library.
To add a Facebook library you must add it as another module to your project.
If you still want to use Ant there is another option: Use Intellij IDEA which support Ant.
I have an Android application under development which makes use of a separate library project of my own. These two projects are stored in separate Git repositories. The application project references the library project by means of the .gitmodules file.
I'm now trying to work on both of these projects together (the application and the library) on a new machine. I cloned the application project, which resulted also in the library project being automatically cloned into my ~/git/ directory as well. So far so good.
I notice also that in Eclipse Package Explorer, the library project root has a commit hash within brackets (e.g. [MyLibraryName 0123ABC]). This presumably means that the library clone is from a certain commit point, and I understand that I could update this (i.e pull in the latest commits for this library) using git submodule foreach git pull.
Question is, what is the best way for me to continue separately developing the library project now? I tried to modify a file and stage it, but when using Team->commit, the dialogue didn't list the modified file. I assume this might be something to do with it being a submodule, pointing at a particular commit.
Should I clone my library project again, completely separately into a different subdirectory, and import as a separate project into Eclipse in order for me to do work on that library?
Having read various other SO questions, it seems apparent that there's no elegant solution for this. The steps I eventually took to solve this are:
Assuming not done so already, clone the application repository that makes use of submodules. Import all projects into Eclipse workspace, including the submodule repository (or repositories). Note that the submodule repository is a repository within the main application repository, and it's not on a particular branch; it's a reference to a particular commit (detached head).
In the Package Explorer, rename the submodule project that was imported. I gave it a name that relates to the application repo it's inside of. For instance, for an application project called ABCD, rename it from SomeLibrary to SomeLibrary_ABCD.
Next, clone the library separately from its own Git repository. Now, the point of renaming the submodule project is that it's now possible to import the Eclipse project from the standalone clone of the library repository, without Eclipse giving the "Some or all projects can not be imported because they already exist in the workspace" error.
Having done this, we have SomeLibrary_ABCD project which is not on a branch but points to a particular commit, and is a submodule of project ABCD. That submodule is updated using git submodule foreach git pull. Then, we have project SomeLibrary, which is on a branch (e.g. master).
My planned workflow is to locally switch the application project to point at my 'standalone' project of the library instead of the submodule version when I want to do development on the library. I then commit changes to SomeLibrary.
Any better suggestions than this (or corrections to anything I've stated) would be appreciated - but for now this is my own answer to the problem.
I use the wizard to create a new Android project in Eclipse Juno with Android SDK Tools revision 20.0.3 at build SDK 15 and minimum required SDK 15. The files are generated with sample code for activity, manifest, etc. I have tried different templates (like MasterDetail or BlankActivity with Tabs) in this process and there are sometimes issues such as AndroidManifest.xml or activity_main.xml with repeated XML elements. So I fix these issues manually (which I think is a bug with the wizard).
Now, I want to "team share" the project via EGIT. So I right-click the project and "Team->Share Project->git". At this point, it wants me to choose a repository. I have created a new one outside Eclipse workspace (and re-used it once created). (I also tried creating one in the parent directory (i.e. in workspace despite an Eclipse warning not to do so).
Either way, when the share operation completes, the buildpath for Libraries "Android Dependencies" does not have the "android-support-v4.jar" in the location specified which was in the workspace. It seems that after the egit operation, the project directory appears to have been moved to the repository, but the .classpath file has not changed.
Is this how egit should work (move project workspace inside git repo and tell Eclipse that the project directory is in a new location)? Is the only workaround to fix the buildpath manually?
Is there a different approach to create new android project in Eclipse and then put the relevant files (i.e. exclude generated java files) into a local git repository such that Eclipse EGIT works?
I am answering my own question after some trial and error.
Here are the steps.
Create the android project via the wizard.
Fix any XML errors (as necessary) to get a buildable project.
Right-click project and Team->Share Project->Git
Select the Git Repository (and create if necessary).
At this point, the Android Dependencies (a dynamic classpath container) in the Java Build Path will be wrong because Git has moved the files to the repository.
Close the project (Project->Close Project)
Re-open project (Project->Open Project)
Now, the Android Dependencies are correct because it is dynamic. I don't know the exact mechanism used by Eclipse for dynamic classpath container, but if you read the Android Tools website it will explain the rules used to to populate this container.
Clean the project. (Project->Clean...)
The important thing is not to try to fix these Android Dependencies yourself (like deleting it), because then your Android project may have issues when you start to build the APK.