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
bf751921
Commit
bf751921
authored
Dec 16, 2015
by
Eric Seidel
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #971 from eseidelGoogle/apk_res
Add support for bundling apk resources
parents
1e888693
64bec536
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
16 deletions
+14
-16
apk.dart
packages/flutter_tools/lib/src/commands/apk.dart
+14
-16
No files found.
packages/flutter_tools/lib/src/commands/apk.dart
View file @
bf751921
...
...
@@ -10,6 +10,7 @@ import 'package:path/path.dart' as path;
import
'../artifacts.dart'
;
import
'../base/file_system.dart'
;
import
'../base/logging.dart'
;
import
'../base/process.dart'
;
import
'../build_configuration.dart'
;
import
'../device.dart'
;
import
'../runner/flutter_command.dart'
;
...
...
@@ -66,19 +67,23 @@ class _ApkBuilder {
return
(
_androidJar
.
existsSync
()
&&
_aapt
.
existsSync
()
&&
_zipalign
.
existsSync
());
}
void
package
(
File
outputApk
,
File
androidManifest
,
Directory
assets
,
Directory
artifacts
)
{
_run
(
_aapt
.
path
,
[
void
package
(
File
outputApk
,
File
androidManifest
,
Directory
assets
,
Directory
artifacts
,
Directory
resources
)
{
List
<
String
>
packageArgs
=
[
_aapt
.
path
,
'package'
,
'-M'
,
androidManifest
.
path
,
'-A'
,
assets
.
path
,
'-I'
,
_androidJar
.
path
,
'-F'
,
outputApk
.
path
,
artifacts
.
path
]);
];
if
(
resources
.
existsSync
())
{
packageArgs
.
addAll
([
'-S'
,
resources
.
path
]);
}
runCheckedSync
(
packageArgs
);
}
void
sign
(
File
keystore
,
String
keystorePassword
,
String
keyName
,
File
outputApk
)
{
_run
(
_jarsigner
,
[
runCheckedSync
([
_jarsigner
,
'-keystore'
,
keystore
.
path
,
'-storepass'
,
keystorePassword
,
outputApk
.
path
,
...
...
@@ -87,17 +92,7 @@ class _ApkBuilder {
}
void
align
(
File
unalignedApk
,
File
outputApk
)
{
_run
(
_zipalign
.
path
,
[
'-f'
,
'4'
,
unalignedApk
.
path
,
outputApk
.
path
]);
}
void
_run
(
String
command
,
List
<
String
>
args
,
{
String
workingDirectory
})
{
ProcessResult
result
=
Process
.
runSync
(
command
,
args
,
workingDirectory:
workingDirectory
);
if
(
result
.
exitCode
==
0
)
return
;
stdout
.
write
(
result
.
stdout
);
stderr
.
write
(
result
.
stderr
);
runCheckedSync
([
_zipalign
.
path
,
'-f'
,
'4'
,
unalignedApk
.
path
,
outputApk
.
path
]);
}
}
...
...
@@ -108,6 +103,7 @@ class _ApkComponents {
File
classesDex
;
File
libSkyShell
;
File
keystore
;
Directory
resources
;
}
class
ApkCommand
extends
FlutterCommand
{
...
...
@@ -168,6 +164,8 @@ class ApkCommand extends FlutterCommand {
components
.
classesDex
=
new
File
(
artifactPaths
[
1
]);
components
.
libSkyShell
=
new
File
(
artifactPaths
[
2
]);
components
.
keystore
=
new
File
(
artifactPaths
[
3
]);
// TODO(eseidel): Should this be configurable from flutter.yaml?
components
.
resources
=
new
Directory
(
'apk/res'
);
if
(!
components
.
androidSdk
.
existsSync
())
{
logging
.
severe
(
'Can not locate Android SDK:
$androidSdkPath
'
);
...
...
@@ -204,7 +202,7 @@ class ApkCommand extends FlutterCommand {
_ApkBuilder
builder
=
new
_ApkBuilder
(
components
.
androidSdk
.
path
);
File
unalignedApk
=
new
File
(
'
${tempDir.path}
/app.apk.unaligned'
);
builder
.
package
(
unalignedApk
,
components
.
manifest
,
assetBuilder
.
directory
,
artifactBuilder
.
directory
);
artifactBuilder
.
directory
,
components
.
resources
);
builder
.
sign
(
components
.
keystore
,
_kKeystorePassword
,
_kKeystoreKeyName
,
unalignedApk
);
File
finalApk
=
new
File
(
argResults
[
'output-file'
]);
...
...
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