I have converted one of our Android projects from the old Groovy settings.gradle and build.gradle files to the new Kotlin DSL, i. e. settings.gradle.kts and build.gradle.kts.
While "it works on my machine" - in particular: the original project I converted from Groovy to Kotlin works fine in its original directory - all my co-workers are unable to open the project when they clone the repo. Importantly, neither can I open the project myself (with the same AS installation on the same machine) when I clone the repo to some other directory. So, I suspect there is some additional detail missing in some configuration file but I cannot seem to figure out which...
Details:
When I just use File > Open... and then select the project folder, I only get the error message "The project 'xxx' is not a Gradle-based project"
When I instead go through Import Project (Gradle, Eclipse ADT, etc.) and then select Import project from external model and Android Gradle Android Studio will create an empty build.gradle file and fail with the error message "ERROR: Plugin with id 'com.android.library' not found." Deleting the build.gradle just goes back to the error message I described in the first bullet point.
I am aware of this Github issue, which seems to describe the same problem, but it's been very quiet and I thought someone around here must have figured out a solution to this...
Oh, command line builds work everywhere - this is purely an Android Studio problem.
UPDATE: When I copy the whole project to a new folder (instead of cloning the repository) I can open it without any problems. So, am I correct in assuming that there must be something inside the folder - but not in Git - that makes it work?
I was able to 'fix' it by deleting the .idea directory and reopening the project. The .idea directory is usually not committed in git but I guess copying the directory invalidates the directory structures in the files within the .idea directory.
The whole bug is easily reproducible when you click on File > Re-import Gradle project.
#Boni2k answer does not work for me.
I have to rename the root build.gradle.kts back to build.gradle, fix the syntax error, sync the project (which works fine immediately), and rename the file back to build.gradle.kts. Then the error is gone and I can sync the project successfully.
What I did to raise the error was that I moved the project to a different folder, and rename the project.
Related
I am beginner in developing test automation for Mobile apps, and already I am facing "Cannot resolve symbol........." issues. I have also done a "sync to Gradle".
I have a MainActivityTest class which consist of the following :
As can be seen, the red-colored texts are giving me the issues of "Cannot resolve symbol when mouse-over them.
The following is the Gradle in my app module
Hope to have advice as what have I done wrong.
Steps you can explore:
Step 1: File > Sync Project with Gradle Files.
Step 2: If it doesn't work even now, File > Invalidate Caches and Restart.
Step 3: After you restart, you can Clean Project, Rebuild Project.
Another Step: File > Close Project, and reopen it.
Edit:
If you didn't find any solution to the problem with the above steps you can follow the following steps.
Close Android Studio.
Let Us consider your project name is ' AndroidProject '.
Go to your project folder (...../AndroidProject/). It will have app/, build/, gradle/, release/ folders and build.gradle, gradlew, gradle.properties, 'gradle.bat, settings.gradle, local.properties` files.
Delete the build/ folder. (Don't worry nothing is going to happen! This folder is something that is generated).
Now navigate into app/, and delete the build/ folder in that as well.
Open Android studio now. The project will rebuild. Your errors will be gone.
I am using Android-Studio to build my app. In order to add libraries, I need to edit build.gradle file but I don't see it anywhere. Even if I changed files-view from android to project and vice-versa .
Why don't I see/have build.gradle ?
Check in your git repository if it contains the build.gradle files.
If not, you can just add manually to your project.
You should have something like this:
root
|--app
|----build.gradle
|--build.gradle
|--settings.gradle
You can also create a new blank project and copy the build.gradle files into your existing project (of course in the app/build.gradle file you have to change the values and the dependencies).
With huge help from #JuLes (commentting on my question) I figure out how to solve it. Here is what I did:
I totally removed Android-Studio following this guidance, then ...
I installed Gradle from this link, then ...
I re-installed Android-Studio following this link:
I am gussing the main problem was that I didn't installed Gradle manually and hence Android-Studio was using some sort of Gradle-Wrapper to allow the application to run.
Now, finally I can edit build.gradle.
BIG THANKS TO: JuLie
I'm trying to use mp4parser library in my project. My android studio version is 1.0.2. Here's what I've done so far:
I've downloaded mp4parser zipfile from the link: https://github.com/sannies/mp4parser
I've extracted the zip file to MyProjectName/app/libraries
Renamed the folder to mp4parser
Add this line of code to settings.gradle file:
include ':app:libraries:mp4parser'
Add this line of code to build.gradle (in dependencies block):
compile project('libraries:mp4parser')
Now I want to sync the project with gradle files. This error pops up:
Error:Configuration with name 'default' not found.
I don't have this problem with other libraries. Seems that its only mp4parser that I have problem with. How can I fix this?
If you're including the library as source, the best thing to do is to unpack it somewhere and import it as a module.
The error you're getting is cryptic but it means that the build system is looking for a build.gradle file at that location and not finding it (or it doesn't see an apply plugin statement in the file telling it what to do). I'm assuming that the library you're trying to use doesn't have a Gradle build script.
If you import the library using the Android Studio UI, a build script will be generated for the module and you should be good to go.
In Android Studio, I wanted to rename the root directory. There was no way to do this within Android Studio, so I exited AS and renamed the folder and then opened the project again. But when I went to run the app, it indicates:
AndroidManifest.xm does not exist or has incorrect root tag
The manifest does exist, but apparently something breaks by renaming the file. I tried invalidating the cache but that didn't help.
Closing the project and then removing it from the list and then reimporting the project as a non-Android project corrected the problem. Still, this seems to be a hack. It should be possible to rename the root folder without having to take this approach.
Im using Back Track r3 and android studio 0.8.6, every time i start a project i get
"Gradle project refresh failed - cause error in opening zip file"
error message, what can i do to fix it?
update:
after trying to delete /gradle folder in plugins
this is what i get.
only more errors i cant rebuild the project
Delete everything in the .gradle directory in your home directory, and also the .gradle directory in your project, and rebuild.
The rebuild will take some time because it will need to re-download a bunch of Gradle and project dependencies, but I think one of those has become corrupted.
Old, but had it today on a react native generated project :
so I deleted the content of the gradle dir at the root (myproject-dir/android/gradle) of the android project -> it redownloaded everything, and it was fine !
Hope this will help someone.