when listing distributions, if one has no ndk_api, consider it to be 0#1494
when listing distributions, if one has no ndk_api, consider it to be 0#1494
Conversation
this avoids crashes, but also ensure that it doesn't consider it a match, is that something we want?
|
@inclement @AndreMiras opinions welcome! |
|
Thanks for looking into this! |
|
Yeah i was wondering about just setting to None, but i now think it's not going to make much of a difference, since this is only checked if user asked for a specific api, this way may trigger a few unnecessary distribution rebuild, and some unused space, but it's probably a lesser evil than trying to guess what api was used in an older distribution if we fail. |
|
Thanx @tshirtman your solution solved my problem ! |
|
The intended solution is to delete and rebuild the dist as ultimately using a dist with an unknown API target can't be recommended, but this wasn't a major point. Setting a default value is acceptable, it may as well be zero. It would also be good to print a warning in this case. |
|
Ok, i'll add a warning, would something like: "Distribution {dist} has been built with an unknown api target, ignoring it, you might want to delete it". represent the intention well? |
|
Sounds good to me! |
| "built with an unknown api target, ignoring it, " | ||
| "you might want to delete it".format( | ||
| distname=dist.name, | ||
| distdir=dist.dist_dir |
There was a problem hiding this comment.
I though it would make it easier for user to remove it… but i can remove it if it's not relevant.
There was a problem hiding this comment.
No sorry what I mean is the format string seems to add a param that's not used, right?
There was a problem hiding this comment.
Yea kind of looks like (distdir) should be {distdir}
There was a problem hiding this comment.
uh, i misread that >_<, thanks for your patience 😆
|
Please note an https://github.com/kivy/python-for-android/blob/master/pythonforandroid/distribution.py#L98 This is why I made this pull request: #1484 just to provide some background So I highly recommend against merging this unless you either address this, or you're certain that this won't be an issue (I might be wrong, obviously, I'm not sure either if this code path can be hit in this case). |
|
When it was None I got tons of errors and couldnt build the apk, but @tshirtman solution worked like charm ! 0 is better and buit the apk on the fly. if you woried bout that line just replace: |
|
Right, that might be one way to address it, but then also the argument parser default value for |
ghost
left a comment
There was a problem hiding this comment.
See my comment, with None sometimes being used for ndk_api instead of 0. I think it should be either None or 0 everywhere, not a mix of both (this broke things for me at one place, which is why I changed the --ndk-api default in a pull request recently)
|
Another line that may need changing in relation to this pull request: https://github.com/kivy/python-for-android/blob/master/pythonforandroid/distribution.py#L215 Might be worth searching for |
|
Hm. Thinking about this some more, why can't we fix the code that breaks handling |
|
It's good feedback, i had looked at the line you mention and assumed that it wouldn't be an issue, but didn't think that Anything against that? |
|
As elaborated above, I like |
|
As a general note, this is important only for the handling of existing dists that predate the ndk_api setting. It should not be possible to create new dists with p4a that don't have an NDK API. The change here should be seen in that light: we don't want dists with a missing NDK API to actually work well (if at all), just to not crash p4a. |
|
Thank you for clarifying @inclement then do we want to address it this way in this case? |
|
@AndreMiras I might be wrong, but I think the change here means that rather than the presence of an old, non-ndk build crashing p4a always, it will no longer disrupt build of a proper distribution with ndk version when any old distribution is still present - with this warning advising the user to remove that old outdated distribution, since it won't be built or be recognized anyway. (at least if Nevertheless, I think this pull request is useful, because the warning is much more useful than a random backtrace, and I also find it useful to not block building a more recent project just because an older, incompatible distribution happens to be lying around. But of course one could still abort the entire build always but with a nice error. However, I prefer the solution here (given I understood things correctly) |
|
@tshirtman what do you think about changing this line: (The idea being that a distribution with |
ghost
left a comment
There was a problem hiding this comment.
I haven't actually TESTED it, but just code-wise this all looks reasonable to me.
this avoids crashes, but also ensure that it doesn't consider it a
match, is that something we want?