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
00e22284
Commit
00e22284
authored
May 16, 2016
by
Collin Jackson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #3891 by making flutter run generate identical apks to flutter build apk
parent
32527017
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
42 deletions
+30
-42
build_apk.dart
packages/flutter_tools/lib/src/commands/build_apk.dart
+30
-42
No files found.
packages/flutter_tools/lib/src/commands/build_apk.dart
View file @
00e22284
...
...
@@ -201,46 +201,11 @@ class BuildApkCommand extends FlutterCommand {
@override
Future
<
int
>
runInProject
()
async
{
// Validate that we can find an android sdk.
if
(
androidSdk
==
null
)
{
printError
(
'No Android SDK found. Try setting the ANDROID_HOME environment variable.'
);
return
1
;
}
List
<
String
>
validationResult
=
androidSdk
.
validateSdkWellFormed
();
if
(
validationResult
.
isNotEmpty
)
{
validationResult
.
forEach
(
printError
);
printError
(
'Try re-installing or updating your Android SDK.'
);
return
1
;
}
BuildMode
mode
=
getBuildMode
();
Map
<
String
,
File
>
extraFiles
=
<
String
,
File
>{};
for
(
String
addFile
in
argResults
[
'add-file'
])
{
List
<
String
>
keyValue
=
addFile
.
split
(
'='
);
if
(
keyValue
.
length
!=
2
)
{
printError
(
'add-file option must have the format <path/in/APK>=<local/file/path>'
);
return
1
;
}
extraFiles
[
keyValue
.
first
]
=
new
File
(
keyValue
.
last
);
}
if
(
FileSystemEntity
.
isDirectorySync
(
_kDefaultAssetsPath
))
{
Directory
assetsDir
=
new
Directory
(
_kDefaultAssetsPath
);
for
(
FileSystemEntity
entity
in
assetsDir
.
listSync
(
recursive:
true
))
{
if
(
entity
is
File
)
{
String
targetPath
=
entity
.
path
.
substring
(
assetsDir
.
path
.
length
);
extraFiles
[
"assets/
$targetPath
"
]
=
entity
;
}
};
}
// TODO(devoncarew): This command should take an arg for the output type (arm / x64).
return
await
buildAndroid
(
TargetPlatform
.
android_arm
,
mode
,
getBuildMode
()
,
force:
true
,
manifest:
argResults
[
'manifest'
],
resources:
argResults
[
'resources'
],
...
...
@@ -248,7 +213,7 @@ class BuildApkCommand extends FlutterCommand {
target:
argResults
[
'target'
],
flxPath:
argResults
[
'flx'
],
aotPath:
argResults
[
'aot-path'
],
extraFiles:
extraFiles
,
addFiles:
argResults
[
'add-file'
]
,
keystore:
(
argResults
[
'keystore'
]
??
''
).
isEmpty
?
null
:
new
ApkKeystoreInfo
(
keystore:
argResults
[
'keystore'
],
password:
argResults
[
'keystore-password'
],
...
...
@@ -427,16 +392,19 @@ int _signApk(
}
// Returns true if the apk is out of date and needs to be rebuilt.
bool
_needsRebuild
(
String
apkPath
,
String
manifest
)
{
bool
_needsRebuild
(
String
apkPath
,
String
manifest
,
Map
<
String
,
File
>
extraFiles
)
{
FileStat
apkStat
=
FileStat
.
statSync
(
apkPath
);
// Note: This list of dependencies is imperfect, but will do for now. We
// purposely don't include the .dart files, because we can load those
// over the network without needing to rebuild (at least on Android).
Iterable
<
FileStat
>
dependenciesStat
=
<
String
>[
List
<
String
>
dependencies
=
<
String
>[
manifest
,
_kFlutterManifestPath
,
_kPackagesStatusPath
].
map
((
String
path
)
=>
FileStat
.
statSync
(
path
));
];
dependencies
.
addAll
(
extraFiles
.
values
.
map
((
File
file
)
=>
file
.
path
));
Iterable
<
FileStat
>
dependenciesStat
=
dependencies
.
map
((
String
path
)
=>
FileStat
.
statSync
(
path
));
if
(
apkStat
.
type
==
FileSystemEntityType
.
NOT_FOUND
)
return
true
;
...
...
@@ -462,7 +430,7 @@ Future<int> buildAndroid(
String
target
,
String
flxPath
,
String
aotPath
,
Map
<
String
,
File
>
extra
Files
,
List
<
String
>
add
Files
,
ApkKeystoreInfo
keystore
})
async
{
// Validate that we can find an android sdk.
...
...
@@ -478,7 +446,27 @@ Future<int> buildAndroid(
return
1
;
}
if
(!
force
&&
!
_needsRebuild
(
outputFile
,
manifest
))
{
Map
<
String
,
File
>
extraFiles
=
<
String
,
File
>{};
for
(
String
addFile
in
addFiles
??
<
String
>[])
{
List
<
String
>
keyValue
=
addFile
.
split
(
'='
);
if
(
keyValue
.
length
!=
2
)
{
printError
(
'add-file option must have the format <path/in/APK>=<local/file/path>'
);
return
1
;
}
extraFiles
[
keyValue
.
first
]
=
new
File
(
keyValue
.
last
);
}
if
(
FileSystemEntity
.
isDirectorySync
(
_kDefaultAssetsPath
))
{
Directory
assetsDir
=
new
Directory
(
_kDefaultAssetsPath
);
for
(
FileSystemEntity
entity
in
assetsDir
.
listSync
(
recursive:
true
))
{
if
(
entity
is
File
)
{
String
targetPath
=
entity
.
path
.
substring
(
assetsDir
.
path
.
length
);
extraFiles
[
"assets/
$targetPath
"
]
=
entity
;
}
};
}
if
(!
force
&&
!
_needsRebuild
(
outputFile
,
manifest
,
extraFiles
))
{
printTrace
(
'APK up to date; skipping build step.'
);
return
0
;
}
...
...
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