-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error Gradle "Could not resolve project" on compile #116
Comments
Resolving this issue actually takes two parts. @NiSHoW mentioned the first step. I confirmed it by testing that change in this fork. The second step is fixing the plugin-build.gradle template in cordova-android. My current hacky solution is to run the following script as a cordova hook: config.xml
hooks/cordova-plugin-gradle-update.js
I'm not sure if and when cordova-android plans on fixing that. Ideally they will fix that in both versions 6.4.0 and 7.0.0. I say that because v7.0.0 introduced structural changes that I don't think most developers want to make right now. If anyone has a better solution or knows of something that I'm missing, then please share. Environment: |
Sounds so complex. Thank you for sharing.
|
I've hit this issue and fixed it in a similar way to @renzoolguin above (many thanks!) I'm pretty new to Cordova, but I'm a bit baffled as to why this hasn't been fixed in cordova-android itself and in this project - is this an unusual bug? I'm not demanding for it to be fixed, I'm just confused as to why it hasn't been an issue for lots of other people. One thing I found was that 'after_platform_add' seems to be called too late - when I use 'cordova prepare' this doesn't get called until after the whole project has been generated - at which point the plugin has already had the gradle file generated. I tried changing this to 'before_plugin_install' - which initially seemed to work, but I believe there's a race condition of sorts - this appears to run in parallel with the generation of the gradle configs. The ultimate fix I ended up with was to modify the generated gradle files - rather than the template, using the same code as above. It all feels a bit dirty! Environment |
Had the same problem, fixed it thanks to the info on this thread:
However, I had to modify the hook code to avoid timing issues: by making the hook return a promise we can ensure the build won't continue until the hook is finished.
|
fixes some issues in cordova default plugin-build.gradle file: - replace deprecated "compile" configurations with "implementation" - replace old Java 1_6 variables with 1_8 - fix "cdvCompileSdkVersion" and "cdvBuildToolsVersion" undefined vars
Thanks to everyone in the thread contributing to the install hook helping me get past some of the build issues I was having. I wanted to mention though, that using Cordova 9 causes this to break with the error:
The fix was easy enough however. Just add const deferral = context.requireCordovaModule('q').defer(); with const deferral = q.defer(); (or you could make it a one-liner, dealer's choice) That said, I created a new fork in order to add several other fixes I needed for my application (including a couple others added to this hook script), and some changes to make it simpler to install/configure for others in my organization that will also need to maintain our app. Maybe it'll be of use to others as well: And here is a summary of the changes: |
Thank you. I will review those some time soon. It is really annoying that everything keeps breaking, but I try to keep up now and then. |
@erobertson42 thanks for sharing this! When I try to build my project I get `Checking Java JDK and Android SDK versions
FAILURE: Build failed with an exception.
BUILD FAILED in 1s FAILURE: Build failed with an exception.
BUILD FAILED in 1s |
They keep deprecating everything... But shouldn't this be in a new thread? |
@Johnafriedman, I'm sorry, but I don't know how much help I can be without knowing more about your setup. However I can say that I never had to explicitly install the android.support plugin, or manually add any support dependencies to any config file(s). Although I do have the "Android Support Repository" package installed in Android Studio, you could check to see if you have that as well. I'm not sure if it will help, but it's worth a try. I'll admit I'm fairly new to Cordova and Android development in general. SDK Manager -> SDK Tools tab -> Support Repository |
Thanks for your response and suggestion. I am new to this and wasn't sure if I should open an issue in the forked repo. I was able to build successfully by replacing |
Very good. Teamwork makes the dream work! |
@Johnafriedman I'll take a look at it and update as necessary. I currently have an Android Support issue with Crosswalk, so I'm trying to work out anything related to that. Which minimum Android Support version are you targeting? |
@renzoolguin I am using
My Android Studio > Preferences > System Settings > Android SDK | SDK Tools | Android Support Library shows rev. 23.2.1 My cordova project config.xml has these preferences:
|
There is a new system to add dependencies
build-extra.gradle file of project download-library must be change like this
see this reference:
https://stackoverflow.com/questions/33718663/gradle-error-configuration-declares-dependency-which-is-not-declared
The text was updated successfully, but these errors were encountered: