diff --git a/packages/flutter_tools/lib/src/android/gradle.dart b/packages/flutter_tools/lib/src/android/gradle.dart index 19c926ff9c1..514126186ed 100644 --- a/packages/flutter_tools/lib/src/android/gradle.dart +++ b/packages/flutter_tools/lib/src/android/gradle.dart @@ -36,6 +36,14 @@ enum FlutterPluginVersion { managed, } +// Investigation documented in #13975 suggests the filter should be a subset +// of the impact of -q, but users insist they see the error message sometimes +// anyway. If we can prove it really is impossible, delete the filter. +final RegExp ndkMessageFilter = new RegExp(r'^(?!NDK is missing a ".*" directory' + r'|If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning' + r'|If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to .*)'); + + bool isProjectUsingGradle() { return fs.isFileSync('android/build.gradle'); } @@ -309,6 +317,7 @@ Future _buildGradleProjectV2(String gradle, BuildInfo buildInfo, String ta workingDirectory: 'android', allowReentrantFlutter: true, environment: _gradleEnv, + filter: logger.isVerbose ? null : ndkMessageFilter, ); status.stop(); diff --git a/packages/flutter_tools/test/android/gradle_test.dart b/packages/flutter_tools/test/android/gradle_test.dart index aae26ea201a..22a9dd097b6 100644 --- a/packages/flutter_tools/test/android/gradle_test.dart +++ b/packages/flutter_tools/test/android/gradle_test.dart @@ -8,6 +8,28 @@ import 'package:flutter_tools/src/build_info.dart'; import 'package:test/test.dart'; void main() { + group('gradle build', () { + test('regexp should only match lines without the error message', () { + final List nonMatchingLines = [ + 'NDK is missing a "platforms" directory.', + 'If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /usr/local/company/home/username/Android/Sdk/ndk-bundle.', + 'If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.', + ]; + final List matchingLines = [ + ':app:preBuild UP-TO-DATE', + 'BUILD SUCCESSFUL in 0s', + '', + 'Something NDK related mentioning ANDROID_NDK_HOME', + ]; + for (String m in nonMatchingLines) { + expect(ndkMessageFilter.hasMatch(m), isFalse); + } + for (String m in matchingLines) { + expect(ndkMessageFilter.hasMatch(m), isTrue); + } + }); + }); + group('gradle project', () { GradleProject projectFrom(String properties) => new GradleProject.fromAppProperties(properties);