While running my Flutter app, I sometimes use the Visual Studio Code menu: Run > Start Debugging
, and some other times I use the CLI: flutter run -d H
(a Huawei device)
I've been using the CLI while I integrated: Firebase (Firestore, Storage) and Stripe. At some point I hit the Multidex 64K reference error so I upgraded to minSdkVersion 21
in build.gradle
to get rid of that issue.
According to these instructions, API 21 already includes Multidex so I didn't need to configure anything else. Although at some point I did have to add android.useAndroidX=true
in gradle.properties
file, I just don't remember when or why.
The problem now: I want to run the app from the VS Run menu, but I get this error:
Users/maganap/Documents/develop/projects/kiryoku/kiryoku-app-flutter-3/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java:8: error: package androidx.multidex does not exist
import androidx.multidex.MultiDex;
^
/Users/maganap/Documents/develop/projects/kiryoku/kiryoku-app-flutter-3/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java:18: error: cannot find symbol
MultiDex.install(this);
^
symbol: variable MultiDex
location: class FlutterMultiDexApplication
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
But, it does work properly when run from the CLI with flutter run -d H
.
The question: I just don't want to start guessing and changing settings here and there to make it work, since following any documentation I can find about this apparently is only required when < API 21. Does anyone know the proper way to solve this?
% flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.0.1 21A559 darwin-arm, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.63.2)
[✓] Connected device (3 available)
Thanks in advance.