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
cf56caa7
Commit
cf56caa7
authored
Apr 21, 2016
by
Jason Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a flag to "flutter build apk" that can package additional files into the APK (#3474)
parent
99725c2b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
3 deletions
+25
-3
build_apk.dart
packages/flutter_tools/lib/src/commands/build_apk.dart
+25
-3
No files found.
packages/flutter_tools/lib/src/commands/build_apk.dart
View file @
cf56caa7
...
@@ -122,6 +122,7 @@ class _ApkComponents {
...
@@ -122,6 +122,7 @@ class _ApkComponents {
File
libSkyShell
;
File
libSkyShell
;
File
debugKeystore
;
File
debugKeystore
;
Directory
resources
;
Directory
resources
;
Map
<
String
,
File
>
extraFiles
;
}
}
class
ApkKeystoreInfo
{
class
ApkKeystoreInfo
{
...
@@ -155,6 +156,9 @@ class BuildApkCommand extends FlutterCommand {
...
@@ -155,6 +156,9 @@ class BuildApkCommand extends FlutterCommand {
argParser
.
addOption
(
'flx'
,
argParser
.
addOption
(
'flx'
,
abbr:
'f'
,
abbr:
'f'
,
help:
'Path to the FLX file. If this is not provided, an FLX will be built.'
);
help:
'Path to the FLX file. If this is not provided, an FLX will be built.'
);
argParser
.
addOption
(
'add-file'
,
help:
'Add a file to the APK (must have the format <path/in/APK>=<local/file/path>).'
,
allowMultiple:
true
);
argParser
.
addOption
(
'keystore'
,
argParser
.
addOption
(
'keystore'
,
help:
'Path to the keystore used to sign the app.'
);
help:
'Path to the keystore used to sign the app.'
);
argParser
.
addOption
(
'keystore-password'
,
argParser
.
addOption
(
'keystore-password'
,
...
@@ -191,6 +195,16 @@ class BuildApkCommand extends FlutterCommand {
...
@@ -191,6 +195,16 @@ class BuildApkCommand extends FlutterCommand {
BuildMode
mode
=
getBuildMode
();
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
);
}
// TODO(devoncarew): This command should take an arg for the output type (arm / x64).
// TODO(devoncarew): This command should take an arg for the output type (arm / x64).
return
await
buildAndroid
(
return
await
buildAndroid
(
...
@@ -203,6 +217,7 @@ class BuildApkCommand extends FlutterCommand {
...
@@ -203,6 +217,7 @@ class BuildApkCommand extends FlutterCommand {
outputFile:
argResults
[
'output-file'
],
outputFile:
argResults
[
'output-file'
],
target:
argResults
[
'target'
],
target:
argResults
[
'target'
],
flxPath:
argResults
[
'flx'
],
flxPath:
argResults
[
'flx'
],
extraFiles:
extraFiles
,
keystore:
(
argResults
[
'keystore'
]
??
''
).
isEmpty
?
null
:
new
ApkKeystoreInfo
(
keystore:
(
argResults
[
'keystore'
]
??
''
).
isEmpty
?
null
:
new
ApkKeystoreInfo
(
keystore:
argResults
[
'keystore'
],
keystore:
argResults
[
'keystore'
],
password:
argResults
[
'keystore-password'
],
password:
argResults
[
'keystore-password'
],
...
@@ -217,11 +232,13 @@ Future<_ApkComponents> _findApkComponents(
...
@@ -217,11 +232,13 @@ Future<_ApkComponents> _findApkComponents(
TargetPlatform
platform
,
TargetPlatform
platform
,
BuildMode
buildMode
,
BuildMode
buildMode
,
String
manifest
,
String
manifest
,
String
resources
String
resources
,
Map
<
String
,
File
>
extraFiles
)
async
{
)
async
{
_ApkComponents
components
=
new
_ApkComponents
();
_ApkComponents
components
=
new
_ApkComponents
();
components
.
manifest
=
new
File
(
manifest
);
components
.
manifest
=
new
File
(
manifest
);
components
.
resources
=
resources
==
null
?
null
:
new
Directory
(
resources
);
components
.
resources
=
resources
==
null
?
null
:
new
Directory
(
resources
);
components
.
extraFiles
=
extraFiles
!=
null
?
extraFiles
:
<
String
,
File
>{};
if
(
tools
.
isLocalEngine
)
{
if
(
tools
.
isLocalEngine
)
{
String
abiDir
=
platform
==
TargetPlatform
.
android_arm
?
'armeabi-v7a'
:
'x86_64'
;
String
abiDir
=
platform
==
TargetPlatform
.
android_arm
?
'armeabi-v7a'
:
'x86_64'
;
...
@@ -249,7 +266,8 @@ Future<_ApkComponents> _findApkComponents(
...
@@ -249,7 +266,8 @@ Future<_ApkComponents> _findApkComponents(
List
<
File
>
allFiles
=
<
File
>[
List
<
File
>
allFiles
=
<
File
>[
components
.
manifest
,
components
.
icuData
,
components
.
libSkyShell
,
components
.
debugKeystore
components
.
manifest
,
components
.
icuData
,
components
.
libSkyShell
,
components
.
debugKeystore
]..
addAll
(
components
.
jars
);
]..
addAll
(
components
.
jars
)
..
addAll
(
components
.
extraFiles
.
values
);
for
(
File
file
in
allFiles
)
{
for
(
File
file
in
allFiles
)
{
if
(!
file
.
existsSync
())
{
if
(!
file
.
existsSync
())
{
...
@@ -295,6 +313,9 @@ int _buildApk(
...
@@ -295,6 +313,9 @@ int _buildApk(
String
abiDir
=
platform
==
TargetPlatform
.
android_arm
?
'armeabi-v7a'
:
'x86_64'
;
String
abiDir
=
platform
==
TargetPlatform
.
android_arm
?
'armeabi-v7a'
:
'x86_64'
;
artifactBuilder
.
add
(
components
.
libSkyShell
,
'lib/
$abiDir
/libsky_shell.so'
);
artifactBuilder
.
add
(
components
.
libSkyShell
,
'lib/
$abiDir
/libsky_shell.so'
);
for
(
String
relativePath
in
components
.
extraFiles
.
keys
)
artifactBuilder
.
add
(
components
.
extraFiles
[
relativePath
],
relativePath
);
File
unalignedApk
=
new
File
(
'
${tempDir.path}
/app.apk.unaligned'
);
File
unalignedApk
=
new
File
(
'
${tempDir.path}
/app.apk.unaligned'
);
builder
.
package
(
builder
.
package
(
unalignedApk
,
components
.
manifest
,
assetBuilder
.
directory
,
unalignedApk
,
components
.
manifest
,
assetBuilder
.
directory
,
...
@@ -390,6 +411,7 @@ Future<int> buildAndroid(
...
@@ -390,6 +411,7 @@ Future<int> buildAndroid(
String
outputFile:
_kDefaultOutputPath
,
String
outputFile:
_kDefaultOutputPath
,
String
target
,
String
target
,
String
flxPath
,
String
flxPath
,
Map
<
String
,
File
>
extraFiles
,
ApkKeystoreInfo
keystore
ApkKeystoreInfo
keystore
})
async
{
})
async
{
// Validate that we can find an android sdk.
// Validate that we can find an android sdk.
...
@@ -420,7 +442,7 @@ Future<int> buildAndroid(
...
@@ -420,7 +442,7 @@ Future<int> buildAndroid(
resources
=
_kDefaultResourcesPath
;
resources
=
_kDefaultResourcesPath
;
}
}
_ApkComponents
components
=
await
_findApkComponents
(
platform
,
buildMode
,
manifest
,
resources
);
_ApkComponents
components
=
await
_findApkComponents
(
platform
,
buildMode
,
manifest
,
resources
,
extraFiles
);
if
(
components
==
null
)
{
if
(
components
==
null
)
{
printError
(
'Failure building APK: unable to find components.'
);
printError
(
'Failure building APK: unable to find components.'
);
...
...
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