ndk-build: Use uid
to limit logcat
to the current application
#33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #10
This is a port of:
rust-mobile/xbuild#131
rust-mobile/xbuild#135
Having never really understood how Android Studio does it, I just stumbled upon this very new stackoverflow answer that has a rather beatiful solution to the current problems with
pidof
, without drawbacks. Pidof has always been flaky as it relies on the app to be running, which may either take some time or never happen if the app crashed beforepidof
is first run. This results in silly workarounds such as loops that induce extra delay and need to have an upper bound. And thispid
changes every time the app is restarted, making it a tedious process that also doesn't react to manual app restarts on the device. Retrieving theuid
viapm list packages -U
on the other hand, and passing that tologcat --uid
has the following advantages:The only downside is that
pm list package
possibly returns multiple packages if there is a substring match; for this reason the code searches for an explicit match in the output.