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
ec9813a5
Unverified
Commit
ec9813a5
authored
Feb 17, 2020
by
shihchanghsiungsonos
Committed by
GitHub
Feb 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the issue of Android add2app build fails on Android when assets are read-only (#50047)
parent
e481fcae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
1 deletion
+88
-1
module_test.dart
dev/devicelab/bin/tasks/module_test.dart
+75
-1
flutter.gradle
packages/flutter_tools/gradle/flutter.gradle
+13
-0
No files found.
dev/devicelab/bin/tasks/module_test.dart
View file @
ec9813a5
...
...
@@ -12,6 +12,7 @@ import 'package:path/path.dart' as path;
final
String
gradlew
=
Platform
.
isWindows
?
'gradlew.bat'
:
'gradlew'
;
final
String
gradlewExecutable
=
Platform
.
isWindows
?
'.
\\
$gradlew
'
:
'./
$gradlew
'
;
final
String
fileReadWriteMode
=
Platform
.
isWindows
?
'rw-rw-rw-'
:
'rw-r--r--'
;
final
bool
useAndroidEmbeddingV2
=
Platform
.
environment
[
'ENABLE_ANDROID_EMBEDDING_V2'
]
==
'true'
;
...
...
@@ -39,10 +40,36 @@ Future<void> main() async {
);
});
section
(
'Add plugins'
);
section
(
'Add read-only asset'
);
final
File
readonlyTxtAssetFile
=
await
File
(
path
.
join
(
projectDir
.
path
,
'assets/read-only.txt'
))
.
create
(
recursive:
true
);
if
(!
exists
(
readonlyTxtAssetFile
))
{
return
TaskResult
.
failure
(
'Failed to create read-only asset'
);
}
if
(!
Platform
.
isWindows
)
{
await
exec
(
'chmod'
,
<
String
>[
'444'
,
readonlyTxtAssetFile
.
path
]);
}
final
File
pubspec
=
File
(
path
.
join
(
projectDir
.
path
,
'pubspec.yaml'
));
String
content
=
await
pubspec
.
readAsString
();
content
=
content
.
replaceFirst
(
'
\n
# assets:
\n
'
,
'
\n
assets:
\n
- assets/read-only.txt
\n
'
,
);
await
pubspec
.
writeAsString
(
content
,
flush:
true
);
section
(
'Add plugins'
);
content
=
await
pubspec
.
readAsString
();
content
=
content
.
replaceFirst
(
'
\n
dependencies:
\n
'
,
'
\n
dependencies:
\n
device_info: 0.4.1
\n
package_info: 0.4.0+9
\n
'
,
...
...
@@ -226,6 +253,29 @@ Future<void> main() async {
);
}
section
(
'Check file access modes for read-only asset from Flutter module'
);
final
String
readonlyDebugAssetFilePath
=
path
.
join
(
hostApp
.
path
,
'app'
,
'build'
,
'intermediates'
,
'merged_assets'
,
'debug'
,
'out'
,
'flutter_assets/assets/read-only.txt'
,
);
final
File
readonlyDebugAssetFile
=
File
(
readonlyDebugAssetFilePath
);
if
(!
exists
(
readonlyDebugAssetFile
))
{
return
TaskResult
.
failure
(
'Failed to copy read-only asset file'
);
}
String
modes
=
readonlyDebugAssetFile
.
statSync
().
modeString
();
print
(
'
\n
read-only.txt file access modes =
$modes
'
);
if
(
modes
!=
null
&&
modes
.
compareTo
(
fileReadWriteMode
)
!=
0
)
{
return
TaskResult
.
failure
(
'Failed to make assets user-readable and writable'
);
}
section
(
'Build release host APK'
);
await
inDirectory
(
hostApp
,
()
async
{
...
...
@@ -272,6 +322,30 @@ Future<void> main() async {
)
{
return
TaskResult
.
failure
(
"Release host APK doesn't contain metadata: flutterProjectType = module "
);
}
section
(
'Check file access modes for read-only asset from Flutter module'
);
final
String
readonlyReleaseAssetFilePath
=
path
.
join
(
hostApp
.
path
,
'app'
,
'build'
,
'intermediates'
,
'merged_assets'
,
'release'
,
'out'
,
'flutter_assets/assets/read-only.txt'
,
);
final
File
readonlyReleaseAssetFile
=
File
(
readonlyReleaseAssetFilePath
);
if
(!
exists
(
readonlyReleaseAssetFile
))
{
return
TaskResult
.
failure
(
'Failed to copy read-only asset file'
);
}
modes
=
readonlyReleaseAssetFile
.
statSync
().
modeString
();
print
(
'
\n
read-only.txt file access modes =
$modes
'
);
if
(
modes
!=
null
&&
modes
.
compareTo
(
fileReadWriteMode
)
!=
0
)
{
return
TaskResult
.
failure
(
'Failed to make assets user-readable and writable'
);
}
return
TaskResult
.
success
(
null
);
}
on
TaskResult
catch
(
taskResult
)
{
return
taskResult
;
...
...
packages/flutter_tools/gradle/flutter.gradle
View file @
ec9813a5
...
...
@@ -647,6 +647,15 @@ class FlutterPlugin implements Plugin<Project> {
extraGenSnapshotOptions
extraGenSnapshotOptionsValue
splitDebugInfo
splitDebugInfoValue
treeShakeIcons
treeShakeIconsOptionsValue
doLast
{
project
.
exec
{
if
(
Os
.
isFamily
(
Os
.
FAMILY_WINDOWS
))
{
commandLine
(
'cmd'
,
'/c'
,
'attrib -r ${assetsDirectory}/* /s'
)
}
else
{
commandLine
(
'chmod'
,
'-R'
,
'u+w'
,
assetsDirectory
)
}
}
}
}
File
libJar
=
project
.
file
(
"${project.buildDir}/${AndroidProject.FD_INTERMEDIATES}/flutter/${variant.name}/libs.jar"
)
Task
packFlutterAppAotTask
=
project
.
tasks
.
create
(
name:
"packLibs${FLUTTER_BUILD_PREFIX}${variant.name.capitalize()}"
,
type:
Jar
)
{
...
...
@@ -859,6 +868,10 @@ class FlutterTask extends BaseFlutterTask {
return
intermediateDir
}
String
getAssetsDirectory
()
{
return
"${outputDirectory}/flutter_assets"
}
CopySpec
getAssets
()
{
return
project
.
copySpec
{
from
"${intermediateDir}"
...
...
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