-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Allow for gradle downloading missing SDK assets #28097
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
Conversation
|
This has some unfortunate paths right now - gradle doesn't download the SDK manager if you don't already have it, so this path is bad: flutter doctor with licenses only: Reports that you're missing some SDK bits and gradle should fix it. My gut says the right fix for this is to download the SDK manager for them if it's missing instead. I'll open a separate PR for that. |
|
Great, thanks for the link to the other issue. I think the best work around for that right now is to just say license status is unknown if we can't access the Android SDK manager rather thant throwing, and printing some instructions about how to get it. |
tvolkert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM, but other reviewers should add their review as well.
| List<AndroidSdkVersion> _sdkVersions; | ||
| AndroidSdkVersion _latestVersion; | ||
|
|
||
| final bool licensesOnly; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The licenses directory is always present, right? Should this be called missingPlatformTools?
Either way, can you document the member to describe the supported sdk structures and how this member denotes which one is present here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not present if you haven't accepted the licenses - in which case gradle wouldn't download the assets for you.
That said, this would probably be more useful as a getter called platformToolsAvailable or missingPlatformTools. I'll look at that and make sure it's documented.
I wouldn't expect this to change anything in VS Code at all since it all looks internal (we don't make any assumptions about the Android SDK dependencies, we just run Flutter and let it complain - or not). I did try kicking off Dart Code's integration tests against your branch on Travis/AppVeyor but they failed because your fork doesn't have all the tags (so it thinks Flutter is 0.3.6-pre.2578 and fails on |
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is a great change and I really appreciate the additional documentation added
|
@dnfield I pulled your fork and did a quick test with VS Code (since my tests use flutter-tester and don't exercise Android building!). With the changes and my normal SDK, everything was fine. When I wiped out the SDK except for licences, Flutter doctor reported the expected text (first build will be slower), however trying to run (flutter_gallery) resulted in this: The file So, I tried from the terminal with Tried a second time, worked fine. Repeated the whole thing again - same result. First build attempt failed (with the "getter 'name' called on null" error), second run worked. So, one last go from the command line with It's the same error as mentioned above, though this time it pointed me at the log with a stack trace: |
|
I'm not an expert in Android SDK internals, but I am guessing that emulator is part of SDK. However since emulator is not required to build a project, Gradle may not pull it together with dependencies. In other words, I expect |
|
I have some more tests to create and paths to update to make sure that's covered. |
|
@dnfield LMK if you can't repro the above and I'll do some debugging (it's using a physical device, so I don't think it's related to the last comments above). |
|
@DanTup oh true, unrelated to physical device, my bad. Although it's unclear whether Flutter uses |
It does use ADB, and it seems Gradle is able to install it - since after the first failure the subsequent runs work fine (without me downloading anything myself). My guess is that there's something running prior to the Gradle step that relies on something from the SDK (but doesn't fail nicely, so we continue on and instead fail later). I haven't dug into it, but if Dan can't repro I'll have a look. |
|
Yes, |
|
I'm not able to reproduce your issue @DanTup - flutter run does indeed fail, but it just tells me there are no devices available. Do you have another adb hanging out somewhere on your system path? |
|
Oh, apparently I do :/ It's not a symlink either, it's a binary. I'm not sure how I ended up with one there as well as one in the SDK folder. I think I got everything I had through Android Studio, but I could be wrong. |
|
Ah! Do you have The error is strange. We probably should have an assert in there to check that the project isn't null by that step. But I think your couldn't find android SDK issue is from that. |
|
Scratch that - sorry for the spam. I see where the problem is now. We're using aapt to find the bundle identifier in this path and for some reason you don't seem to have it.... |
|
Yep, |
I don't know what aapt is, but you're right that I don't seem to have it (on PATH, at least). |
|
I'm able to reproduce this by putting adb back on my path. I'll see about fixing it. |
|
Right now, flutter run ends up going through a code path where, to find the APK, it relies on being able to invoke aapt. This is a really weird path. It can only happen under the following circumstances:
It's fixable though :) Just writing a test for it. |
|
@dnfield with a licence-only SDK and adb on But... I did see this a couple of times while testing - when the app launched on the device it crashed and I got this in the output: I'm not sure whether it's related to this change. |
|
@DanTup I'm pretty sure that's related to other problems that happened in the midst of this. Using engine from master should fix that. |
Fixes #28076
Fixes #25119
It looks like when we moved to a gradle based project structure (#7902), we never updated our checks for this - but support for this has been there since versions of the plugin before when we converted over, so this change shouldn't break anyone. Gradle is fully capable of downloading whatever necessary SDK components when using a command line build, which is what
build apkdoes, as long as the SDK licenses have been accepted (which can be done in a number of ways, per https://developer.android.com/studio/intro/update#download-with-gradle).I suspect we still need the validation logic in there e.g. if someone ends up corrupting their SDK installation, or for other commands (like listing devices). Tagged @devoncarew to validate that this won't break anything for Android Studio. and @DanTup to validate for VSCode.
I've updated Flutter doctor to report on this scenario. /cc @gspencergoog because this changes a test you wrote to fix a crasher (#22676) - we'd no longer crash on a missing adb, here, but would crash if ADB couldn't be executed.
In local tests, a build where I only have my licenses present with a broadband connection:
Second run (after flutter clean):
I've seen the resolving dependencies bit take longer though, up to 90ish seconds, when downloading SDK bits.