Is there a new version for the flutter tflite package? - flutter

I started working with Flutter and Dart lately, and I'm building a project using the tflite package. But when I want to build the app, even the demo app when just adding the tflite package to my dependencies in pubspec.yaml, to my phone (Xiaomi redmi note 10, android 12) it shows this error:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\User\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\tflite-1.1.2\android\build.gradle' line: 24
* What went wrong:
A problem occurred evaluating project ':tflite'.
> No signature of method: build_9lbq7rfhl5cpix99148s3txh6.android() is applicable for argument types: (build_9lbq7rfhl5cpix99148s3txh6$_run_closure2) values: [build_9lbq7rfhl5cpix99148s3txh6$_run_closure2#77b9e791]
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
Exception: Gradle task assembleDebug failed with exit code 1
Also, when I firstly clicked 'pub get' after depending on tflite, it showed this error:
The plugin `tflite` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
but since I am not the package author, i didn't thought much of it.
I've seen that the tflite package was lastly updated 18 months ago.
So, is there an updated version of the package? Or, is there an alternative for running the google teachable machine?

That is the last known edit to the package. If there are issues that make it unusable now, I'd suggest leaving an issue on their GitHub page so that they can address it moving forward. Unfortunately, you might have to find an alternative to using that package, or edit the package locally yourself to get rid of any dependency issues.
Judging from the volume of issues on this package raised on github (https://github.com/shaqian/flutter_tflite), I don't think it's being maintained at all anymore.

Related

I am getting a failed build while running my project

I just upgraded my Android Studio and flutter SDK. When I try running my flutter project I keep getting this error below. I am using flutter_paystack: ^1.0.5+1 package.
Parameter format not correct -
e: C:\src\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_paystack-1.0.5+1\android\src\main\kotlin\co\paystack\flutterpaystack\FlutterPaystackPlugin.kt: (48, 62): Type mismatch: inferred type is Activity? but Activity was expected
e: C:\src\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_paystack-1.0.5+1\android\src\main\kotlin\co\paystack\flutterpaystack\MethodCallHandlerImpl.kt: (19, 37): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_paystack:compileDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Please what might be the cause
package flutter_paystack: 1.0.5+1 not work on flutter 3
try change dependency of flutter_paystack 1.0.5+1 in pubspec.yaml to:
flutter_paystack:
git:
url: https://github.com/definitelyme/flutter_paystack.git
ref: a4a33c3dd0a12f46d655a2e63d11e9f20ba82d01
Go to your android/build.gradle file and update your Kotlin version hope its help to you.
ext.kotlin_version = '1.6.10'
This is mostly a problem with the Flutter version 3.
The best bet you have is to downgrade your flutter to version 2.x.x
This might conflict with other plugins you're using(like I experienced).
So you might as an alternative. Try embedding paystack payment in a webview. Create a web page, integrate paystack. Call that web page in a webview embedded in the app.
It might even be better if you're looking for extra payment options like bank transfer which isn't available on the flutter app plugin.

pubpspect get failed when adding flutter_html lib in flutter

I have tried to build app 'flutter_html: ^2.1.5" but I unable to build and getting below error in log.
The current Flutter SDK version is 1.27.0-2.0.pre.1.
Because flutter_app depends on flutter_html >=2.1.0 which requires Flutter SDK version >=2.2.0, version solving failed.
pub get failed (1; Because flutter_app depends on flutter_html >=2.1.0 which requires Flutter SDK version >=2.2.0, version solving failed.)
can you suggest the way to clear this issue?
I have upgraded flutter version and migrated and having different issue.
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':app:checkDebugManifest' (type 'CheckManifest').
- In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.tasks.CheckManifest' property 'manifest' has #Input annotation used on property of type 'File'.
Reason: A property of type 'File' annotated with #Input cannot determine how to interpret the file.
Possible solutions:
1. Annotate with #InputFile for regular files.
2. Annotate with #InputDirectory for directories.
3. If you want to track the path, return File.absolutePath as a String and keep #Input.
Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#incorrect_use_of_input_annotation for more details about this problem.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 11s
Exception: Gradle task assembleDebug failed with exit code 1
You need to upgrade your flutter SDK. Write flutter upgrade in terminal.
Or use an older version of flutter_html.

Flutter says Execution failed for task ':sqflite:compileDebugJavaWithJavac'

I used to have this sqflite in my pubspec.yaml file but recently I removed the dependence seeing I won't be making use of it, then I run the app on my android device and emulator I got a strange error and have googled for the solution, it seems I can't find any help and as well check stackoverflow.
What have done so far:
As a rule of thumb, i ran flutter clean to see if issue will be
resolved but it did not worked either
Invalidate and Restart Android Studio
Here is the Error am having
Launching lib/main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
/Users/zionnite/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/android/src/main/java/com/tekartik/sqflite/SqflitePlugin.java:910: error: cannot find symbol
database.deleteDatabase(path);
^
symbol: variable database
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sqflite:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 58s
Exception: Gradle task assembleDebug failed with exit code 1
Dependency of Interest
# sqflite: ^2.0.0+3
# path_provider: ^2.0.1
At this time even if I enable the dependency, the issue still persists.
However, everything is working out great on my ios simulator except android device and emulator
The issue caused by Java version 8. So you should use Java version 11.
Add this to build.gradle file (android/app/build.gradle)
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
Change JDK of Gradle in Android studio
Finally, Clean and rebuild.
That's it.
Issue resolved after downloading Java 11,also check the gradle and wrapper version you're using
I was encountering the same issue.I have done everything which is mentioned on stackoverflow .but the problem is in my new added package which is cached_network_image .I just remove this package and every thing start working.So you just check which new package you added and which create fuss..
I was able combat the enemy of death fighting for the progress of my code and obtain victory through the magical touch of flutter pub cache repair.
what i mean to say is that, when i ran flutter pub cache repair, Flutter was able to build and run on my android device and emulator

How do I solve a configuration problem with audioplayers when using the command flutter build apk?

I have just created an app with flutter and I want to get the apks by splitting per abi. When given the command, there is a problem with configuring the plugin audioplayers.
I thought it could be a problem with using androidX?
Here is the error I get:
´´´
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':audioplayers:verifyReleaseResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\vanda_qwkpv9x.gradle\caches\transforms-2\files-2.1\7faf2ad74a0b9932e38d86e684646e95\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\vanda_qwkpv9x.gradle\caches\transforms-2\files-2.1\7faf2ad74a0b9932e38d86e684646e95\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 56s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 57.7s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve
the incompatibility.
Building plugin audioplayers...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 2.0s
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'audioplayers'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
The plugin audioplayers could not be built due to the issue above.
Anyone suggestions?
EDIT: With newer Flutter projects (thus newer Gradle versions), android.enableR8 is deprecated!
I'm not an expert with Android nor Flutter, but after many tests it seems that the issue isn't related to a package your recently installed, but with the size of the build! I was getting errors related to audioplayers, assets_audio_player, multiple Firebase packages and so on.
In android\gradle.properties make sure you don't have android.enableR8 set to false.
Here were my issues and steps for those interested:
I was only getting errors similar to yours only on build, not while using hot reload
Errors were related to audioplayers which led me to think it's just a package issue
Replaced it with assets_audio_player, but the problems continued
Changed the order, but this made the error shift to Firebase. I recently added Craslytics and this made me think it's because I used a newer version compared to the 1-2 months old packages. I thought it was the time to upgrade to 8.x, but that didn't make sense either. Never had such issues with any FB service/
Removed the latest sound packages, build was successful, but after adding more random packages (just to increase the size), the errors came back!
R8 announcement:
R8, the new code shrinker from Google, is available in Android studio 3.3 beta
Android developers know that APK size is an important factor in user engagement. Code shrinking helps reduce the size of your APK by getting rid of unused code and resources as well as making your actual code take less space (also known as minification or obfuscation).

Flutter: build error when adding "image_cropper" and "contacts_service" packages

I can successfully build and run a fresh new flutter project. But when I add both image_cropper: ^1.0.0 and contacts_service: ^0.2.4 packages to pubspec.yaml and run flutter packages get, I cannot build the project anymore, and get this build error:
D8: Program type already present: android.support.v4.app.INotificationSideChannel
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\2.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\3.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\4.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\5.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\6.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\7.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\8.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\9.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\10.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\11.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\12.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\13.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\14.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\15.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\16.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\17.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\18.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\19.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\20.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\21.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\22.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\23.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\24.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\25.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\26.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\27.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\28.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\29.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\30.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\31.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\32.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\33.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\34.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\35.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\36.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.app.INotificationSideChannel
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 19s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https:///CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
I do not understand this error very well, but it seems that there is a naming conflict between these two packages (because of duplicate_classes in the error text). Is there any workaround for this?
Note that this error does not happen with any other pair of packages for me.
In build.gradle defaultConfig add multiDexEnabled true
This was an Android X compatibility issue. I could get it fixed by following the steps mentioned here, but in summary:
First make sure that compileSdkVersion is at least 28 in app/build.gradle. This property controls the version of the Android SDK that Gradle uses to build your APK. It doesn’t affect the minimum SDK version that your app can run on.
Right click on android directory of flutter project and open it using this menu: Flutter > Open android module in android studio
In the newly opened project, from menus select Refactor > Migrate to AdnroidX
Close the project and open your flutter project again.