Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7851a751
Unverified
Commit
7851a751
authored
Jun 19, 2019
by
Jonah Williams
Committed by
GitHub
Jun 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix NPE in flutter tools (#34725)
parent
0d4f4bdd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+8
-7
gradle_test.dart
packages/flutter_tools/test/android/gradle_test.dart
+13
-0
No files found.
packages/flutter_tools/lib/src/android/gradle.dart
View file @
7851a751
...
...
@@ -509,7 +509,7 @@ Future<void> _buildGradleProjectV2(
flutterUsage
.
sendTiming
(
'build'
,
'gradle-v2'
,
Duration
(
milliseconds:
sw
.
elapsedMilliseconds
));
if
(!
isBuildingBundle
)
{
final
Iterable
<
File
>
apkFiles
=
_
findApkFiles
(
project
,
androidBuildInfo
);
final
Iterable
<
File
>
apkFiles
=
findApkFiles
(
project
,
androidBuildInfo
);
if
(
apkFiles
.
isEmpty
)
throwToolExit
(
'Gradle build failed to produce an Android package.'
);
// Copy the first APK to app.apk, so `flutter run`, `flutter install`, etc. can find it.
...
...
@@ -546,22 +546,23 @@ Future<void> _buildGradleProjectV2(
}
}
Iterable
<
File
>
_findApkFiles
(
GradleProject
project
,
AndroidBuildInfo
androidBuildInfo
)
{
@visibleForTesting
Iterable
<
File
>
findApkFiles
(
GradleProject
project
,
AndroidBuildInfo
androidBuildInfo
)
{
final
Iterable
<
String
>
apkFileNames
=
project
.
apkFilesFor
(
androidBuildInfo
);
if
(
apkFileNames
.
isEmpty
)
return
const
<
File
>[];
return
apkFileNames
.
map
<
File
>((
String
apkFileName
)
{
return
apkFileNames
.
expand
<
File
>((
String
apkFileName
)
{
File
apkFile
=
project
.
apkDirectory
.
childFile
(
apkFileName
);
if
(
apkFile
.
existsSync
())
return
apkFile
;
return
<
File
>[
apkFile
]
;
final
BuildInfo
buildInfo
=
androidBuildInfo
.
buildInfo
;
final
String
modeName
=
camelCase
(
buildInfo
.
modeName
);
apkFile
=
project
.
apkDirectory
.
childDirectory
(
modeName
)
.
childFile
(
apkFileName
);
if
(
apkFile
.
existsSync
())
return
apkFile
;
return
<
File
>[
apkFile
]
;
if
(
buildInfo
.
flavor
!=
null
)
{
// Android Studio Gradle plugin v3 adds flavor to path.
apkFile
=
project
.
apkDirectory
...
...
@@ -569,9 +570,9 @@ Iterable<File> _findApkFiles(GradleProject project, AndroidBuildInfo androidBuil
.
childDirectory
(
modeName
)
.
childFile
(
apkFileName
);
if
(
apkFile
.
existsSync
())
return
apkFile
;
return
<
File
>[
apkFile
]
;
}
return
null
;
return
const
<
File
>[]
;
});
}
...
...
packages/flutter_tools/test/android/gradle_test.dart
View file @
7851a751
...
...
@@ -41,6 +41,18 @@ void main() {
expect
(
shouldBeToolExit
,
isToolExit
);
});
// Regression test for https://github.com/flutter/flutter/issues/34700
testUsingContext
(
'Does not return nulls in apk list'
,
()
{
final
GradleProject
gradleProject
=
MockGradleProject
();
const
AndroidBuildInfo
buildInfo
=
AndroidBuildInfo
(
BuildInfo
.
debug
);
when
(
gradleProject
.
apkFilesFor
(
buildInfo
)).
thenReturn
(<
String
>[
'not_real'
]);
when
(
gradleProject
.
apkDirectory
).
thenReturn
(
fs
.
currentDirectory
);
expect
(
findApkFiles
(
gradleProject
,
buildInfo
),
<
File
>[]);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
test
(
'androidXFailureRegex should match lines with likely AndroidX errors'
,
()
{
final
List
<
String
>
nonMatchingLines
=
<
String
>[
':app:preBuild UP-TO-DATE'
,
...
...
@@ -537,3 +549,4 @@ Platform fakePlatform(String name) {
class
MockLocalEngineArtifacts
extends
Mock
implements
LocalEngineArtifacts
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockXcodeProjectInterpreter
extends
Mock
implements
XcodeProjectInterpreter
{}
class
MockGradleProject
extends
Mock
implements
GradleProject
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment