Related
After I upgrade my gradle gradle-5.4.1 to gradle-6.3, I got an error like 'buildSrc' cannot be used as a project name as it is a reserved name. I'm using buidleSrc for Gradle Dependency Management(link). I dont know how to solve this issue please help on this.
tldr: Remove "buildSrc" from settings.gradle / settings.gradle.kts. With gradle update, "buildSrc" is now reserved project name.
If you are looking an answer for Android, this should be helpful:
Open your settings.gradle / settings.gradle.kts
Remove "buildSrc" from included modules
Rebuild
Example:
settings.gradle.kts might look like this (syntax will be different for settings.gradle)
include(":app")
rootProject.name = "yourapp"
include(":moduleA")
include(":buildSrc")
include(":moduleB")
include(":moduleC")
remove the line that includes "buildSrc" like:
include(":app")
rootProject.name = "yourapp"
include(":moduleA")
include(":moduleB")
include(":moduleC")
and rebuild project.
just remove include ':buildSrc' from the settings.gradle file and everything will go well.
This is a change introduced in Gradle 6.0 that made buildSrc a reserved project name.
It means you have a reference to buildSrc as a project in your settings.gradle(.kts).
The reference will look like:
include("buildSrc")
includeBuild("buildSrc")
I would recommend to start by removing that reference and see if it fixes the issue.
If not, it means your project was wired differently and you simply have to rename it.
screenshot of my problem
Hi guys!
There has been a recent problem regarding the ability to import the ParseImageView class in Android Studio and there is currently only one solution: Unable to import ParseImageView - Android.
When trying this solution, it asks to download a ParseUI-Widget file from github and then import that project into my current project and then finally add a dependency for the ParseUI in the build.gradle. When attempting to sync the gradle, the error in the screenshot keeps on popping up no matter where I place the ParseUI-Widget file in the project file directory.
Please Help!
Thanks
Few things to check.
Make sure that this is the content you have inside your ParseUI-Widget.
Move your ParseUI-Widget up one directory. This way it is the same level as app
You also need to edit your settings.gradle. Your settings gradle likely looks like this:
include ':app'
Edit it to look like this:
include ':app', ':ParseUI-Widget'
You have two options:
You currently have ParseUI-Widget within the app/ directory. So you should be including it in your top-level settings.gradle file as :app:ParseUI-Widget, and within your build.gradle as compile project(':app:ParseUI-Widget')
You can also move the entire app/ParseUI-Widget directory one directory up, so that it's in the same directory, side by side with your app/ directory.
From your screenshot, it seems you haven't imported the ParseUI-Widget module. Rather you just cloned the project from github and pasted it in your project directory structure.
What you have to do is,
go in your android studio project structure view,
right click and under new,
click on new module and then
import the ParseUI-Widget as module.
Then those dependencies are in build. gradle will work fine.
I had successfully imported a Module in my Application project in Android Studio.
Then I deleted or removed the module by following the below link:
How to delete a module in Android Studio
I also removed the project module from the dependencies of my build.gradle(app) file.
Now, When I need to again include the same module project in my Andorid Application, it doesn't allows me, and gives the Project already contains module with the same name error.
I had check in my Project, Package, Android Structure but the project module which i need to Import and add as a Module Project is not there but still it say it already exist.
Can anyone help me to overcome this issue.??
If somebody faces this issue, except removing the Folder containing the old module also remove from the settings.gradle file the line corresponding to the old module: include ':youroldmodule'. If you dont remove that line manually, 2 modules with the same name will appear when trying to add module dependency.
Switch to the Project View. Then open .idea/modules.xml. Find and delete the line that corresponds to the module. Then Invalidate Caches and Restart. That's it.
I solved the problem through this way:
Open Module Settings(Mac: command + down; Windows: F4) and delete the module.
Delete the module folder on the disk. You will find it at ~/AndroidStdioProjects/YourApplicationName/ModuleName.
Import the Module.
I have encountered this.
And I deleted the folder which below my project with the module name I set before, then I can import a module with same name again.
Hope this helps you.
The project view on the left hand side, doesn't show 'everything' your project contains. You can switch the view from the drop-down menu, which is defaulted to 'Android' and change it to 'Project Files', which will probably show you where the problematic reference to the Module remains.
Alternatively, just check on disk where your project is located. I found references in the main project folder.
You can't import a module if you've put the code for the module in the place it will end up being copied to. I had the module source code placed in the project root folder and it failed to import with the above message. If you move the code away somewhere, on import Android Studio will copy the code in.
If you still see the error after removing the code from settings.gradle and the app gradle file, check the following file and remove any entries with the module name you are trying to remove.
./.idea/modules.xml
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
Remove compile project(':module_name') from build.gradle under app folder
then remove module folder under your Project Folder
then remove your module name entry from settings.gradle
This worked for me:
In app/build.gradle, remove this line from dependencies {:
implementation project(':library')
In settings.gradle, change
include ':app', ':library'
to
include ':app'
Then you can import the library. Be sure to put the lines back into the gradle files you took out above.
Those who are still seeing this issue and have already removed the module from settings.gradle file but still sees that Module already present while importing it again, This is what I did:
1.) Switch to Project mode in Android studio for your project
2.) Once switching it to Android mode, delete that module manually by clicking right click on it.
And Hope it works for you now.
I am Not Sure but I hope it's Help you.
Step 1:
Pressed Alt + 1 for get Focus of your App.
Step 2:
Now Pressed F4 for open Module structure of Project
Step 3
Now Select Dependencies and Remove All Extra dependencies of your project.
than Pressed OK.
and Resync gradle.
I hope you are clear with my solution.
Best Luck
I had this problem when I was trying to add junit 4.12 to my project.First of all I delete old junit codes in dependencies of my build.gradle(app) file manually.Next I deleted the old junit.jar from my library with deleting libs folder and then create new libs folder directory in my app for add library.and for the end.......I find the old junit FILE near the end of project view after gradle folder....you can see in this image......and I deleted it.now I can add new module very easy and without same name error.sorry for bad english!!
look this image for last order
I solved this by removing the existing module from the project structure, then renaming the folder. It finally worked when I removed the folder, ran a sync, then re-added the folder and attempted to import.
In one condition if you have copy a folder like this
rootProject/module1
if you import module android studio will find if you have same name folder.
if you have it is not import android studio will tell you you have contains this module ,you just add this in setting.gradle
like
include ':modlue1'
If shows this error after deleting the module from project structure then, select Project view of our project in android studio and then explore and the there will be the folder of module that we imported, right click on that and Delete it and rebuild the app.
If any of the above answers worked for you and you are sure that your branch is clean then close your Android Studio, browse to the root of your project and delete .idea folder. Then re-launch Android studio and run your project.
I had same issue, initially created a module, then removed it from settings.gradle and finally the fix was to ACTUALLY remove ALL folders related to that module, those won't be visible in the ANDROID view, hence change to project view and remove all related or browse using an external tool and remove all folders
For me, there was still a reference to the old module in my project's /.idea/gradle.xml file:
<option value="$PROJECT_DIR$/mymodule" />
I just deleted that line then re-synced with gradle and the error went away.
I have a custom library that needs to be referenced in about 10 projects. Everything works fine in Eclipse but I want to migrate them to Android Studio in order to take advantage of the build system. I've already check
Android studio add external project to build.gradle
How to share a single library source across multiple projects
and some other links and docs in Gradleware but I don't get to make my projects compile.
My file structure is like:
+projects
|+libraryProject
|+---workspace
|+------projectSrc
|
|+project0
|+---workspace
|+------projectSrc0
|
|+project1
|+---workspace
|+------projectSrc1
.
.
|+projectN
|+---workspace
|+------projectSrcN
Each project contains docs, design files, etc... and therefore is no convenient to have the src in the same root folder.
In my "project1", settings.gradle file I've used:
include ':module-custom-lib'
project(':module-custom-lib').projectDir = new File(settingsDir, '../../../libraryProject/workspace/projectSrc')
In my build.gradle file, dependencies section I add:
dependencies {
compile project(':..:..:..:libraryProject:workspace:projectSrc')
....
}
But I get an error saying that the project wasn't found.
I've also used the following approach:
def customLib = file('../../../libraryProject/workspace/projectSrc')
settings.createProjectDescriptor(rootProjectDescriptor, 'module-custom-lib', customLib)
include ':module-custom-lib'
Then in the build.gradle
dependencies {
compile project(':module-custom-lib')
....
}
Please help. Thanks for your time.
EDIT: I've managed to get it working by adding the module app as a suffix in the project dir.:
include ':module-custom-lib'
project(':module-custom-lib').projectDir = new File(settingsDir, '../../../libraryProject/workspace/projectSrc/app')
Now the library members resolve perfectly, but the project's 'R' resource class can not be resolved. So if I do:
setContentView(R.layout.main);
it fails to find that resource. Cleaning and rebuilding the project doesn't fixes the issue.
EDIT 2: Apparently, there was a problem with the manifest merging 'cause the problem was fixed once I adjusted the minSdk and targetSdk of both projects. The previous solution work perfectly.
Your first attempt has a simpler syntax, and should work. Your settings.gradle file looks okay:
include ':module-custom-lib'
project(':module-custom-lib').projectDir = new File(settingsDir, '../../../libraryProject/workspace/projectSrc')
though you should be cautious about including a relative path there -- Android Studio may not use the same working directory as a build you do from the command line, so referencing things relative to rootDir may help alleviate problems.
In the dependencies block of a module's build file, you need to reference a module the same way you do in settings.gradle, so you'd use something like this:
dependencies {
compile project(':module-custom-lib')
}
In dependencies blocks, you're linking to projects using Gradle's project namespace, and since you've already explicitly set up the root directory of the library module, you don't need to try to locate it in the filesystem here. That :..:..:.. syntax wouldn't work anyway to reference a module that's outside of your project's root directory, as this one is.
You should consider bundling "releases" of your library to a Maven repository (possibly your local Maven repo). This way you can reference your library from any other project that needs to use it just like you do with 3rd party libraries.
I am using Android studio and I want to add module to my project like
"action bar Sherlock" or jar files,
but when I opened the project structure there is no module or library in the menu :\
In intelij it's appearing:
So what's the problem? How can I add these modules in Android studio?
Update 19 March 2019
A new experience someone has just faced recently even though he/she did add a library module in app module, and include in Setting gradle as described below. One more thing worth trying is to make sure your app module and your library module have the same compileSdkVersion (which is in each its gradle)!
Please follow this link for more details.
Ref: Imported module in Android Studio can't find imported class
Original answer
Sometimes you use import module function, then the module does appear in Project mode but not in Android mode
So the thing works for me is to go to Setting gradle, add my module manually, and sync a gradle again:
First, create your Module. You can do that using the default Android Studio Module Wizard (File -> New -> New Module), select Android Library, give it a Name and a package name, and finish.
After that you will see that nothing happens. Open the side Gradle Projects Section (should be somewhere on the right panel)
You should see something like this:
Expand your module gradle and run the Run Configurations task.
After that refresh the content and refresh the project structure.
It should work now.
Do right mouse click on your project, then select 'Open Module Settings' - then you can add modules to your project..
Go to File->Project Structure-> Project Settings -> Modules.
Click on the green colored + and add new module. select Application module and set the content root to your project module.
Click next and then finish.
Reference
You need to add a gradle.settings file to your root project structure, after that when you "Open Module settings" you will the menu aligned to your gradle.settings. When importing a project to Android Studio, it doesn't create this file for you. Sometimes it's usually better to start a clean project and move your code there, it's usually easier to achieve.
This Might be help some:
To import module as library in your project.
File > New > Import Module
Select Valid path in Source Dir..
Tick on Import > Finish
Now Open Module setting:
Go to File > Project Structure > Modules
Modules > Dependency > click on Green Plus Sign.
Click on Module Dependency > locate module > and Implement your module.
if your module is not shown in "Choose Modules Window"
Follow the below step..
Open Settings.Gradle file
include ':app', 'Put your module name here' and sync project.
Follow Open Module Setting as above.
As for me issue was that the first line in the build.gradle file of the OpenCV library.
It was something like this:
apply plugin: 'com.android.application'
This refers to the fact that the imported OpenCV is an application and not a library. It exists for OpenCV above 4.1.0. So change it to:
Something like this:
apply plugin: 'com.android.library'.
You might get an error in ApplicationId, comment it out in the gradle file.
Open settings.gradle and add the module as below,
include ':app',':bottomnav'
here i have added my newly imported module ':bottomnav' separated with a comma. then Sync your project. your module will be visible to dependency.
Android Studio only displays those module, which are defined in the settings.gradle file of your application.
after defining the module in settings.gradle, you will be able to add the module as dependency of your application.
I had the same problem, after switching to a branch that did not have my module, then switching back.
Clean Project -> Rebuild Project did not work for me.
But File -> Invalidate caches/restart did work.
Check settings.gradle. You'll find this : include ':app'
Just add your own module name and it should look like this :
include ':app', ':yourModuleName'
Sync.
That's it.
Had similar issue when running version control on a project in Android Studio (0.4.2). When pulling it down to a new location and importing the modules, only the "Android SDK" were showing in the Project Structure.
I removed the .idea/ folder from the version control, by adding it to .gitignore file, and did a fresh pull and imported the modules. Now all the settings appeared correctly in the Project Settings and Platform Settings for the Project Structure.
Here's what I did to solve this problem
Close Android Studio
Quick Start -> Check out from Version Control
Please go to Module settings
and choose Modules from Project Settings
then you need to Select src and gen folders and marked them as Source folders by right-click on them and select Source
First You Have To Add Name Of Your Module In setting.gradle(Project Setting) File Like This..
include ':app', ':simple-crop-image-lib'
Then You Need To Compile This Module Into build.gradle(Module app) File Like This..
implementation project(':simple-crop-image-lib')
That's all for adding module now it will be appear in android section or project section as well.
If It's till did't appear rebuild or clean your project..
Although not similar to the question above,
In my case,
The module is not visible in the android tab,
I saw it in the project tab.
After deleting the .idea/workspace.xml file, (I guess there is a problem because the unloadlist list remains here?)
When I reopened the project, it worked fine.
Additionally,
When invalidate caches (clear VCS Log caches and indexes),
It shows up for new modules, not for previously deleted modules (this only worked when deleting workspace.xml).
If you moved the modules, modify your workspace.xml file and settings.gradle file to use the new paths of your module.
Otherwise you will need to try using the import module feature.
Make sure the directory name is lower case.
First and foremost, check that all the modules are listed in your settings.gradle file.
If they are not, add them.
If they are, change something/anything in the file so that the Sync Project prompt comes on. Sync and your project should compile fine; the modules you're looking for will appear in your project structure.
in my case somehow build.gradle file deleted under app i restore it