Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AndroidToolTask] Log tool output as error (#8861)
`AndroidToolTask.Execute()` logs full tool output on error Context: dotnet/android-tools#208 Context: b002dc3 Very often the *context* to understand a tool error isn't printed to stderr, but is instead printed earlier to stdout. For example, consider this annotated `r8` output snippet from b002dc38 (`[stderr]` and `[stdout]` are annotations): % $HOME/android-toolchain/jdk-11/bin/java -Xmx1G -classpath …/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.0-preview.4.20/tools/r8.jar com.android.tools.r8.D8 --debug --min-api 23 --output obj/Debug/net7.0-android/android/bin/ … [stdout] Error in obj/Debug/net7.0-android/lp/59/jl/classes.jar:android/support/v4/app/INotificationSideChannel$Stub.class: [stdout] Type android.support.v4.app.INotificationSideChannel$Stub is defined multiple times: obj/Debug/net7.0-android/lp/59/jl/classes.jar:android/support/v4/app/INotificationSideChannel$Stub.class, obj/Debug/net7.0-android/lp/4/jl/bin/classes.jar:android/support/v4/app/INotificationSideChannel$Stub.class [stdout] Compilation failed [stdout] Exception in thread "main" java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj/Debug/net7.0-android/lp/59/jl/classes.jar:android/support/v4/app/INotificationSideChannel$Stub.class [stdout] at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:98) [stdout] at com.android.tools.r8.D8.main(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:4) [stdout] Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj/Debug/net7.0-android/lp/59/jl/classes.jar:android/support/v4/app/INotificationSideChannel$Stub.class [stdout] at Version.fakeStackEntry(Version_3.3.28.java:0) [stdout] at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:75) [stdout] … [stdout] Caused by: com.android.tools.r8.internal.f: Type android.support.v4.app.INotificationSideChannel$Stub is defined multiple times: obj/Debug/net7.0-android/lp/59/jl/classes.jar:android/support/v4/app/INotificationSideChannel$Stub.class, obj/Debug/net7.0-android/lp/4/jl/bin/classes.jar:android/support/v4/app/INotificationSideChannel$Stub.class [stdout] at com.android.tools.r8.internal.DT.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:14) [stdout] … [stderr] java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj/Debug/net7.0-android/lp/59/jl/classes.jar : android/support/v4/app/INotificationSideChannel$Stub.class When originally processed, the *only* output included in the error message was the the only line written to stderr: error : java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj/Debug/net7.0-android/lp/59/jl/classes.jar : android/support/v4/app/INotificationSideChannel$Stub.class The fix in b002dc38 was to update `<JavaToolTask/>` to capture *all* output from `java …`, and when an error occurred, dump *all* of it. Bump to dotnet/android-tools@1ea4e35eaf which updates `AndroidToolTask` to do the same thing, "lowering" the logic into a common base class of `<JavaToolTask/>`: capture all output (stdout & stderr) from the tool, and when an error occurs, log *all* of the captured output into an `XAccc0000` error message. `ccc` is the `AndroidToolTask.TaskPrefix` property. The `<Exec/>` tasks that ran `adb` directly have been replaced with `<AndroidAdb/>` instances. This task inherits from `AndroidToolTask` and will now benefit from improved error logging. Changes: dotnet/android-tools@05f9a90...1ea4e35 * dotnet/android-tools@1ea4e35: [AndroidToolTask] Log tool output as error * dotnet/android-tools@c8a5b5b: Check for ANDROID_HOME Sdk location on Windows
- Loading branch information