Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/flutter_tools/lib/src/android/gradle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -310,6 +318,7 @@ Future<Null> _buildGradleProjectV2(String gradle, BuildInfo buildInfo, String ta
workingDirectory: 'android',
allowReentrantFlutter: true,
environment: _gradleEnv,
filter: logger.isVerbose ? null : ndkMessageFilter,
);
status.stop();

Expand Down
22 changes: 22 additions & 0 deletions packages/flutter_tools/test/android/gradle_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> nonMatchingLines = <String>[
'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<String> matchingLines = <String>[
':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);

Expand Down