-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Impossible to open Project in Android Studio #1760
Comments
The AGP (Android Gradle Plugin) is the thing that does the minimum supported gradle check. The problem is if you have a single gradle project, then using the Part of this is because Gradle community recommends checking the gradle wrapper so that end users don't have to update their own gradle wrapper, so if there was a version bump it can be managed by a single person. However, that means checking in binary code into the repository and distributing that which is against Apache policies for security reasons. So in order to reduce reliance on a particular system gradle version, but still allow older gradle wrappers to update to a newer version, we have a "dummy" tools project that doesn't import the AGP and the CLI is configured to use the wrapper from the dummy project. Hence why this works from the cordova CLI. Android Studio will have it's own configurations and you'll need to configure gradle to use a compatible gradle version. This might also mean having to upgrade Android Studio if you're using an older version. Cordova Android 13 should work with Android Studio Ladybug out of the box, assuming default settings on both the Cordova Android project and Android Studio. Hopefully this answers your question? |
Hi @breautek , Second, I think the documentation here must be updated https://github.com/apache/cordova-android/blob/master/README.md Thrid, I have Iguana. Is it a reason Ladybug works? Thanks! |
Cordova-android 12 and earlier did behave slightly different in that the gradle wrapper task was executed on the main android project, using the system gradle version. This means you'd need to install and upgrade your system gradle install to a version compatible by the AGP version being used. So if AGP required min 8.3 for example, you would need system gradle install at version 8.3 at least, for cordova android to install it's desired wrapper. In cordova-android 13 using the dummy tools project, the gradle version installed on the system is much more flexible and isn't restricted to what AGP needs. The project can still install the correct wrapper version which is then used by the builds (which will also satisfy AGP requirements)
Can you explain what part of the README should be updated?
Iguana is definitely older. Cordova-android 13 is configured to use AGP 8.3.0 by default. I also think Android Studio has an embedded gradle that it uses, which is likely 8.2 based on the error message. Iguana supports up to AGP 8.3 (according to Android docs) but will probably require additional configurations to make it work. Ladybug is definitely recommended for Cordova-Android 13 though, as it was the version used for testing on Cordova Android 13 release. FWIW, setting up a new cordova android project and then opening it up in Android Studio Ladybug it builds without further action. My system gradle version is also 8.7. |
Hi @breautek , Thanks for your response. AGP 8.3 requires Gradle 8.4 and Android tells me 8.2. Maybe that have Gradle included but potentially, not smart from Google to not include the right version :/ Regarding my remark for the documentation, if everything works out of the box in Ladybug, it's good. For opening on Android Studio for debug purpose, only way for me is to add a Gradle Wrapper and I can click on the elephant icon (Sync Project with Gradle files). However, i can use my system gradle to build with
Side question I see normal that Kr. |
With Iguana or Ladybug? With Ladybug I can build and debug just fine, using a sample "HelloWorld" cordova application. I did not use any Cordova CLI commands other than to add the plaform. The only time I'd have to sync with gradle is if there was an actual gradle file change while the IDE was opened. Now I am pretty sure when using the IDE, you end up using the embedded gradle runtime (e.g. you don't use the tools gradle wrapper stuff.) If you right click the android module and Which for me is Gradle 8.9 (gradle wrapper is actually configured to use 8.7 so I think that shows it's not using the "correct" gradle version)
Yah you'd think they would just not declare Iguana as a supported IDE if Iguana ships/uses with Gradle 8.2, but I think perhaps using the Project Structure settings maybe you can select a newer gradle version. Ideally 8.7 but any version that is 8.4+ should work.
I'm not actually familiar with that gradle task. Good chance it's bugged but if it's failing gracefully and it's job is just to print stuff probably not a big deal. |
I think perhaps if Cordova CLI as part of the This way it can initialise the wrapper using nearly any gradle version using the Right now Cordova only sets up the wrapper on build (e.g.
Now open the project in Android Studio Iguana, and you should see it using Gradle 8.7 and I assume it would build just find on that IDE version since Android does state the IDE supports AGP 8.3. If that works, I can look into making this improvement in the CLI so that the wrapper is placed in the proper location for IDE usage. |
Hi @breautek , I always speak about Iguana. I have atm some security constraints to update Android Studio by myself on my current workstation.
Even if open the project structure in ![]()
Regarding your last message, it's quite funny because it was what I'm doing (manually) since I created this ticket to make it work for debugging purpose :) But for me, it was a "workaround" thinking I miss something else :)
With those two commands, the Meanwhile, I'll add a after_build hook for this copy. Thanks for the support and will try to be there the 31th Jan for the Cordova Meeting. |
I see haha! Yah I realised I kinda went in a circle, but I do now fully understand the issue I think and I do plan on addressing it some point. But I don't know if it will make it into any patch release. Right now I don't have much volunteer time available to contribute. I'll make a milestone and add this issue though so it's not forgotten, but it might only be addressed in the next major. Kinda depends on how things gets rolled out, if it gets too close to major release time for API 36 support.
Awesome! :) |
Hi,
We are using Cordova since a long time. Build is well working through the Cordova CLI.
However, i'm wondering why gradle is now moved to "tools" folder into the android project.
Due to that, we cannot import the project into Android Studio. I have the following error.
Do I miss something?
Thanks in advance
Ionic:
Ionic CLI : 7.2.0
Ionic Framework : @ionic/angular 6.3.2
@angular-devkit/build-angular : 13.3.9
@angular-devkit/schematics : 13.3.9
@angular/cli : 13.3.9
@ionic/angular-toolkit : 6.1.0
Cordova:
Cordova CLI : 12.0.0 ([email protected])
Cordova Platforms : android 13.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 15 other plugins)
Utility:
cordova-res : 0.15.4
native-run : not installed globally
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.12.2
ios-sim : 8.0.2
NodeJS : v16.20.2
npm : 8.19.4
OS : macOS Unknown
Xcode : Xcode 15.4 Build version 15F31d
Kr.
TiBz0u
The text was updated successfully, but these errors were encountered: