Continuing the conversation from #286, where I had the same problem as @ritavkashyap123, and @asabri97 speculated it was my build environment, and to pull 0.1.38.
I pulled 0.1.38 and built, same error. I did eventually get the project built, after substantial effort. Here's the highlights-
- initially I was using flutter (3.35.5) installed from snap under Ubuntu 22.04. Looking under /snap/flutter I found two versions of STL-- /snap/flutter/current/usr/include/c++/9 and /snap/flutter/current/usr/include/c++/10. I figure these captured versions of STL headers were possibly the source of the problem
- to test that hypothesis, I started clean by cloning https://github.com/flutter/flutter and using that version to build yolo-flutter-app, which mostly went well (no stl_vector.h error), but got a new errors-
:~/projs/yolo-flutter-app/example$ flutter run
Launching lib/main.dart on SM G986U in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ultralytics_yolo:compileDebugKotlin'.
> Error while evaluating property 'friendPathsSet$kotlin_gradle_plugin_common' of task ':ultralytics_yolo:compileDebugKotlin'.
> Could not resolve all files for configuration ':ultralytics_yolo:debugCompileClasspath'.
> Failed to transform flutter.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: /home/me/projs/flutter/bin/cache/artifacts/engine/android-arm/flutter.jar.
> Transform's input file does not exist: /home/me/projs/flutter/bin/cache/artifacts/engine/android-arm/flutter.jar. (See https://issuetracker.google.com/issues/158753935)
> There are 3 more failures with identical causes.
...
Running Gradle task 'assembleRelease'... 55.8s
┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ This issue appears to be https://github.com/flutter/flutter/issues/58247. │
│ Fix this issue by adding the following to the file /home/kev/projs/yolo-flutter-app/example/android/app/build.gradle: │
│ android { │
│ lintOptions { │
│ checkReleaseBuilds false │
│ } │
│ } │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
- I figured there might be issues left behind by the snap version of flutter, so I read up on how to reset flutter's build apparatus:
- flutter clean
- flutter pub cache repair
- rm -rf ~/.gradle/caches
- flutter precache --android
- So then I tried a build, flutter build apk
the old error was gone, replaced by a new one ("Could not read workspace metadata from /home/kev/.gradle/caches/8.13/kotlin-dsl/accessors/7c2e71f9da456135e1d8c18b575a2dea/metadata.bin")
- Hmm. I tried
flutter pub outdated which showed many packages behind current versions (often the case in large projects)
- Tried:
flutter pub upgrade but little change
- Then realized adding
-v to flutter build apk would add useful info, which led to "org.gradle.api.GradleException: Error resolving plugin [id: 'dev.flutter.flutter-plugin-loader', version: '1.0.0']"
- After much research and trying things, including Dart, Flutter, Gradle and AGP mutual version incompatibilities, I found that the current Flutter version just wasn't working for yolo-flutter-app, and tried downgrading, from 3.35.5 to eventually 3.24.3
- Also to get a working build, I changed some things (a proper diff can be provided, if you want). As a Flutter newb, I don't know which of these were caused by improper system env / tools / versions, but some of it appears to be incompatible dependencies between current Flutter and yolo-flutter-app:
example/android/app/build.gradle
...
+buildscript {
+ repositories {
+ google()
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:8.13.0'
+ classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24' // often needed too
+ }
+}
...
android {
namespace = "com.ultralytics.yolo_example"
- compileSdk = flutter.compileSdkVersion
+ compileSdk = 35
example/android/gradle/wrapper/gradle-wrapper.properties
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
example/android/settings.gradle
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
- id "com.android.application" version "8.6.0" apply false
- id "org.jetbrains.kotlin.android" version "2.1.0" apply false
+ id "com.android.application" version "8.6.1" apply false
+ id "org.jetbrains.kotlin.android" version "1.9.24" apply false
example/pubspec.yaml
environment:
- sdk: ^3.8.1
- flutter: ">=3.32.1"
+ sdk: ">=3.5.0 <4.0.0"
+ flutter: ">=3.24.0"
pubspec.yaml
environment:
- sdk: ^3.8.1
- flutter: ">=3.32.1"
+ sdk: ">=3.5.0 <4.0.0"
+ flutter: ">=3.24.0"
- With the change in Flutter version came a downgrade of Dart SDK, and with that came one Dart API incompatibility, in
class Color: Color.withValues no longer existed, instead .withOpacity was available, e.g.
example/lib/presentation/widgets/model_selector.dart
@@ -22,7 +22,7 @@ class ModelSelector extends StatelessWidget {
height: 36,
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
- color: Colors.black.withValues(alpha: 0.6),
+ color: Colors.black.withOpacity(0.6),
After hours spent trying to get all the versions playing together nicely, I figured why not, let's downgrade to .withOpacity too! And it worked, the app compiles and executes and works as expected (!). But now my source is disjoint from the original project. 😠 It may be OK, my work is a forked, customized version anyways, as I'm using yolo-flutter-app as a starting point and will be making many mods.
However, I'm left with the question of whether my version tweaks were necessary. Had I started on a brand-new, clean VM, fresh checkouts of everything (including Flutter), would it have worked? Pets vs cattle. Time-wise I must move forward, can't go back and test that thought.
@asabri97 Thoughts?
Continuing the conversation from #286, where I had the same problem as @ritavkashyap123, and @asabri97 speculated it was my build environment, and to pull 0.1.38.
I pulled 0.1.38 and built, same error. I did eventually get the project built, after substantial effort. Here's the highlights-
the old error was gone, replaced by a new one ("Could not read workspace metadata from /home/kev/.gradle/caches/8.13/kotlin-dsl/accessors/7c2e71f9da456135e1d8c18b575a2dea/metadata.bin")
flutter pub outdatedwhich showed many packages behind current versions (often the case in large projects)flutter pub upgradebut little change-vtoflutter build apkwould add useful info, which led to "org.gradle.api.GradleException: Error resolving plugin [id: 'dev.flutter.flutter-plugin-loader', version: '1.0.0']"class Color: Color.withValues no longer existed, instead .withOpacity was available, e.g.After hours spent trying to get all the versions playing together nicely, I figured why not, let's downgrade to .withOpacity too! And it worked, the app compiles and executes and works as expected (!). But now my source is disjoint from the original project. 😠 It may be OK, my work is a forked, customized version anyways, as I'm using yolo-flutter-app as a starting point and will be making many mods.
However, I'm left with the question of whether my version tweaks were necessary. Had I started on a brand-new, clean VM, fresh checkouts of everything (including Flutter), would it have worked? Pets vs cattle. Time-wise I must move forward, can't go back and test that thought.
@asabri97 Thoughts?