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
c02be8cd
Unverified
Commit
c02be8cd
authored
May 31, 2022
by
Gary Qian
Committed by
GitHub
May 31, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support string compileSdkVersion for preview android SDKs (#104662)
parent
552c50e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
1 deletion
+98
-1
flutter.gradle
packages/flutter_tools/gradle/flutter.gradle
+4
-1
flutter_build_preview_sdk.dart
...ols/test/integration.shard/flutter_build_preview_sdk.dart
+94
-0
No files found.
packages/flutter_tools/gradle/flutter.gradle
View file @
c02be8cd
...
@@ -458,7 +458,10 @@ class FlutterPlugin implements Plugin<Project> {
...
@@ -458,7 +458,10 @@ class FlutterPlugin implements Plugin<Project> {
/** Prints error message and fix for any plugin compileSdkVersion or ndkVersion that are higher than the project. */
/** Prints error message and fix for any plugin compileSdkVersion or ndkVersion that are higher than the project. */
private
void
detectLowCompileSdkVersionOrNdkVersion
()
{
private
void
detectLowCompileSdkVersionOrNdkVersion
()
{
project
.
afterEvaluate
{
project
.
afterEvaluate
{
int
projectCompileSdkVersion
=
project
.
android
.
compileSdkVersion
.
substring
(
8
)
as
int
int
projectCompileSdkVersion
=
Integer
.
MAX_VALUE
// Default to int max if using a preview version to skip the sdk check.
if
(
project
.
android
.
compileSdkVersion
.
substring
(
8
).
isInteger
())
{
// Stable versions use ints, legacy preview uses string.
projectCompileSdkVersion
=
project
.
android
.
compileSdkVersion
.
substring
(
8
)
as
int
}
int
maxPluginCompileSdkVersion
=
projectCompileSdkVersion
int
maxPluginCompileSdkVersion
=
projectCompileSdkVersion
String
ndkVersionIfUnspecified
=
"21.1.6352462"
/* The default for AGP 4.1.0 used in old templates. */
String
ndkVersionIfUnspecified
=
"21.1.6352462"
/* The default for AGP 4.1.0 used in old templates. */
String
projectNdkVersion
=
project
.
android
.
ndkVersion
?:
ndkVersionIfUnspecified
String
projectNdkVersion
=
project
.
android
.
ndkVersion
?:
ndkVersionIfUnspecified
...
...
packages/flutter_tools/test/integration.shard/flutter_build_preview_sdk.dart
0 → 100644
View file @
c02be8cd
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'../src/common.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
late
Directory
tempDir
;
late
String
flutterBin
;
late
Directory
exampleAppDir
;
setUp
(()
async
{
tempDir
=
createResolvedTempDirectorySync
(
'flutter_plugin_test.'
);
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
,
);
exampleAppDir
=
tempDir
.
childDirectory
(
'aaa'
).
childDirectory
(
'example'
);
processManager
.
runSync
(<
String
>[
flutterBin
,
...
getLocalEngineArguments
(),
'create'
,
'--template=plugin'
,
'--platforms=android'
,
'aaa'
,
],
workingDirectory:
tempDir
.
path
);
});
tearDown
(()
async
{
tryToDelete
(
tempDir
);
});
test
(
'build succeeds targeting string compileSdkVersion'
,
()
async
{
final
File
buildGradleFile
=
exampleAppDir
.
childDirectory
(
'android'
).
childDirectory
(
'app'
).
childFile
(
'build.gradle'
);
// write a build.gradle with compileSdkVersion as `android-Tiramisu` which is a string preview version
buildGradleFile
.
writeAsStringSync
(
buildGradleFile
.
readAsStringSync
().
replaceFirst
(
'compileSdkVersion flutter.compileSdkVersion'
,
'compileSdkVersion "android-Tiramisu"'
),
flush:
true
);
expect
(
buildGradleFile
.
readAsStringSync
(),
contains
(
'compileSdkVersion "android-Tiramisu"'
));
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
...
getLocalEngineArguments
(),
'build'
,
'apk'
,
'--debug'
,
],
workingDirectory:
exampleAppDir
.
path
);
expect
(
result
.
stdout
,
contains
(
'Built build/app/outputs/flutter-apk/app-debug.apk.'
));
expect
(
exampleAppDir
.
childDirectory
(
'build'
)
.
childDirectory
(
'app'
)
.
childDirectory
(
'outputs'
)
.
childDirectory
(
'apk'
)
.
childDirectory
(
'debug'
)
.
childFile
(
'app-debug.apk'
).
existsSync
(),
true
);
},
);
test
(
'build succeeds targeting string compileSdkPreview'
,
()
async
{
final
File
buildGradleFile
=
exampleAppDir
.
childDirectory
(
'android'
).
childDirectory
(
'app'
).
childFile
(
'build.gradle'
);
// write a build.gradle with compileSdkPreview as `Tiramisu` which is a string preview version
buildGradleFile
.
writeAsStringSync
(
buildGradleFile
.
readAsStringSync
().
replaceFirst
(
'compileSdkVersion flutter.compileSdkVersion'
,
'compileSdkPreview "Tiramisu"'
),
flush:
true
);
expect
(
buildGradleFile
.
readAsStringSync
(),
contains
(
'compileSdkPreview "Tiramisu"'
));
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
...
getLocalEngineArguments
(),
'build'
,
'apk'
,
'--debug'
,
],
workingDirectory:
exampleAppDir
.
path
);
expect
(
result
.
stdout
,
contains
(
'Built build/app/outputs/flutter-apk/app-debug.apk.'
));
expect
(
exampleAppDir
.
childDirectory
(
'build'
)
.
childDirectory
(
'app'
)
.
childDirectory
(
'outputs'
)
.
childDirectory
(
'apk'
)
.
childDirectory
(
'debug'
)
.
childFile
(
'app-debug.apk'
).
existsSync
(),
true
);
},
);
}
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