-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Overview
Android 13 Tiramisu (API 33) has recently entered beta and soon (in June) will enter "platform stability" phase (source).
As a developer, I'd like to test whether my application works with API 33 (e.g to test new notification permission).
To do this, I first bumped targetSdkVersion and compileSdkVersion to 33 in my <flutter_project_root>/android/app/build.gradle. It failed with the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:mergeDevDebugAssets'.
> Could not resolve all dependencies for configuration ':app:devDebugRuntimeClasspath'.
> Could not create task ':app:minifyDevReleaseWithR8'.
> Failed to find Platform SDK with path: platforms;android-33
Then I read this short tutorial and learned that I have to set targetSdkVersion and compileSdkVersion to "Tiramisu" (I am using AGP 7.0.4 – in <flutter_project_root>/android/build.gradle I have dependencies { classpath 'com.android.tools.build:gradle:7.0.4' /.../ }`. After doing so, I got the following error:
FAILURE: Build failed with an exception.
* Where:
Script '/Users/bartek/fvm/versions/stable/packages/flutter_tools/gradle/flutter.gradle' line: 461
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> For input string: ""
This caught my attention. I opened /Users/bartek/fvm/versions/stable/packages/flutter_tools/gradle/flutter.gradle, went to line 461 and saw this code.
For reference, here's the PR that introduced the
substring(8) as intonproject.android.compileSdkVersion
It assumes that compileSdkVersion is an int, which is not the case for Tiramisu.
Quick fix
I wanted to make the app target API 33 and compile, so I modified the /Users/bartek/fvm/versions/stable/packages/flutter_tools/gradle/flutter.gradle. Actually, I've submitted a PR for this so it's easier to see changes.
After the above modifications, the Gradle build was still failing with:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:mergeDevDebugAssets'.
> Could not resolve all dependencies for configuration ':app:devDebugRuntimeClasspath'.
> Could not create task ':app:minifyDevReleaseWithR8'.
> Failed to find target with hash string 'Tiramisu' in: /Users/bartek/androidsdk
After changing compileSdkVersion from "Tiramisu" to "android-Tiramisu" and targetSdkVersion to 33, the build succeeded and my app ran 🚀. This SO thread helped me.
Steps to Reproduce
- Create a new flutter project (e.g the default counter app).
- Set
targetSdkVersionandcompileSdkVersionto"Tiramisu"influtter_project_root/android/app/build.gradle - Execute
flutter run - Watch it fail
Expected results:
I expected my app to build successfully and run on the physical/virtual android device.
Actual results:
Gradle build failed with the following exception:
FAILURE: Build failed with an exception.
* Where:
Script '/Users/bartek/fvm/versions/stable/packages/flutter_tools/gradle/flutter.gradle' line: 461
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> For input string: ""
Code sample
I hope that I provided everything that might be needed for reproduction. If anything is missing, please let me know 🙏
Logs
As a sidenote, below you can see that flutter doctor can't handle android-Tiramisu as well.
$ flutter doctor -v
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.3.1 21E258 darwin-arm, locale en-PL)
• Flutter version 3.0.0 at /Users/bartek/fvm/versions/stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ee4e09cce0 (9 days ago), 2022-05-09 16:45:18 -0700
• Engine revision d1b9a6938a
• Dart version 2.17.0
• DevTools version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/bartek/androidsdk
• Platform android-32, build-tools 32.1.0-rc1
• ANDROID_SDK_ROOT = /Users/bartek/androidsdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.1)
• IntelliJ at /Users/bartek/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
• Flutter plugin version 67.0.4
• Dart plugin version 221.5588
[✓] IntelliJ IDEA Ultimate Edition (version 2022.1)
• IntelliJ at /Users/bartek/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/221.5080.210/IntelliJ IDEA.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.67.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.40.0
[✓] Connected device (3 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 12 (API 32) (emulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 12.3.1 21E258 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 101.0.4951.64
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
$ sdkmanager --list_installed | grep "platforms;android"
platforms;android-28 | 6 | Android SDK Platform 28 | platforms/android-28
platforms;android-29 | 5 | Android SDK Platform 29 | platforms/android-29
platforms;android-30 | 3 | Android SDK Platform 30 | platforms/android-30
platforms;android-31 | 1 | Android SDK Platform 31 | platforms/android-31
platforms;android-32 | 1 | Android SDK Platform 32 | platforms/android-32
platforms;android-Tiramisu | 4 | Android SDK Platform Tiramisu | platforms/android-Tiramisu
sdkmanager --list_installed | grep "build-tools"
build-tools;28.0.3 | 28.0.3 | Android SDK Build-Tools 28.0.3 | build-tools/28.0.3
build-tools;29.0.2 | 29.0.2 | Android SDK Build-Tools 29.0.2 | build-tools/29.0.2
build-tools;30.0.2 | 30.0.2 | Android SDK Build-Tools 30.0.2 | build-tools/30.0.2
build-tools;31.0.0 | 31.0.0 | Android SDK Build-Tools 31 | build-tools/31.0.0
build-tools;32.0.0 | 32.0.0 | Android SDK Build-Tools 32 | build-tools/32.0.0
build-tools;32.0.0-rc1 | 32.0.0 rc1 | Android SDK Build-Tools 32-rc1 | build-tools/32.0.0-rc1
build-tools;32.1.0-rc1 | 32.1.0 rc1 | Android SDK Build-Tools 32.1-rc1 | build-tools/32.1.0-rc1
build-tools;33.0.0-rc4 | 33.0.0 rc4 | Android SDK Build-Tools 33-rc4 | build-tools/33.0.0-rc4