I want to use local_auth plugin in flutter, and it needs Android lifecycle, so i installed flutter_plugin_android_lifecycle, but i get this error with it if i try to release apk: error:
package androidx.lifecycle does not exist. I tried a lot of things, but i just cannot get it to work.
'''
C:\flutter.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.7\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\FlutterLifecycleAdapter.java:8: error:
package androidx.lifecycle does not exist
import androidx.lifecycle.Lifecycle;
^
C:\flutter.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.7\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\FlutterLifecycleAdapter.java:22: error:
cannot find symbol
public static Lifecycle getActivityLifecycle(
^
symbol: class Lifecycle
location: class FlutterLifecycleAdapter
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileReleaseJavaWithJavac'.
> 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 1s
'''
Adding implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' in build.grable plugin folder will solve the issue.
Refer https://github.com/flutter/flutter/issues/60883 for more details.
Add this in you flutter yaml dependencies
flutter_plugin_android_lifecycle: ^1.0.11
For more can visit : https://pub.dev/packages/flutter_plugin_android_lifecycle/install
This can be also due to a version gradle problem, so try to use these compatible versions in your /android/build.gradle
classpath 'com.android.tools.build:gradle:3.5.4'
you can try also:
3.3.3
3.4.3
3.5.4
3.6.4
4.0.1
This error came to me using the flutter plugin file_picker.
I hope this work.
Related
I was building a flutter app in a Windows machine and I stopped working on it for several months, after that I now get issues on running the app. It shows those two errors:
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
Where:
Build file 'C:\Users\okeyr\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_tts-3.6.3\android\build.gradle' line: 31
What went wrong:
A problem occurred evaluating project ':flutter_tts'.
org/gradle/api/services/BuildService
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.
==============================================================================
2: Task failed with an exception.
Where:
Script 'C:\Program Files\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 463
What went wrong:
A problem occurred configuring project ':flutter_tts'.
Failed to notify project evaluation listener.
Cannot invoke method substring() on null object
compileSdkVersion is not specified.
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
Flutter doctor shows everything fine except:
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
But I don't think the issue is related with that.
I've I look in depth at failure number 1. I have check the file that gives the error and I found that in line 31:
apply plugin: 'kotlin-android'
So I just went to the file and deleted all the entries related with kotlin, because I am not using Kotlin (I guess).
Then if I rerun the app it now shows another error (related with tts again), but doesn't show the previous ones (not sure if I've moved forward or backwards)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\Users\okeyr\AndroidStudioProjects\fluttertestapp\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java:24: error: cannot find symbol
flutterEngine.getPlugins().add(new com.tundralabs.fluttertts.FlutterTtsPlugin());
^
symbol: class FlutterTtsPlugin
location: package com.tundralabs.fluttertts
1 error
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app: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 16s
Exception: Gradle task assembleDebug failed with exit code 1
After doing a search I found many people with that similar issue (even though none was related to tts plugin) which had adressed it with a flutter pub cache repair or a flutter clean. However, a flutter clean gives me no changes and error persists and when I have executed flutter pub cache repair it had shown:
Failed to repair flutter_tts 3.6.3. Error:
Pub failed to delete entry because it was in use by another process.
This may be caused by a virus scanner or having a file
in the directory open in another application.
Reinstalled 29 packages.
Failed to reinstall 1 package:
flutter_tts 3.6.3
pub finished with exit code 69
Now, if I rerun the code it gives me new error:
The plugin flutter_tts doesn't have a main class defined in C:\Users\okeyr\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_tts-3.6.3\android\src\main\java\com\tundralabs\fluttertts\FlutterTtsPlugin.java or C:\Users\okeyr\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_tts-3.6.3\android\src\main\kotlin\com\tundralabs\fluttertts\FlutterTtsPlugin.kt. This is likely to due to an incorrect androidPackage: com.tundralabs.fluttertts or mainClass entry in the plugin's pubspec.yaml.
If you are the author of this plugin, fix the androidPackage entry or move the main class to any of locations used above. Otherwise, please contact the author of this plugin and consider using a different plugin in the meanwhile.
This error also appears when running pub get or pug upgrade. But if I run pub outdated it gives me that:
Showing outdated packages.
[*] indicates versions that are not the latest available.
Package Name Current Upgradable Resolvable Latest
direct dependencies: all up-to-date.
transitive dependencies:
characters *1.2.1 *1.2.1 *1.2.1 1.3.0
collection *1.17.0 *1.17.0 *1.17.0 1.17.1
js *0.6.5 *0.6.5 *0.6.5 0.6.7
meta *1.8.0 *1.8.0 *1.8.0 1.9.0
path *1.8.2 *1.8.2 *1.8.2 1.8.3
transitive dev_dependencies:
matcher *0.12.13 *0.12.13 *0.12.13 0.12.14
test_api *0.4.16 *0.4.16 *0.4.16 0.4.18
all dependencies are up-to-date.
Process finished with exit code 0
I can't see any dependency related with tts.
Now here I am stucked in that error, I don't know how to proceed. If there is someone who could help me see the light I'd be grateful. Thanks in advance.
I am trying to run the code but it seems tts package is not well defined, anyone that could bring me some help?
I am getting the following Build failed with exception after I run my flutter project.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class com.google.android.exoplayer2.ui.DownloadNotificationHelper found in modules jetified-exoplayer-core-2.17.0-runtime (com.google.android.exoplayer:exoplayer-core:2.17.0) and jetified-exoplayer-ui-2.15.1-runtime (com.google.android.exoplayer:exoplayer-ui:2.15.1)
Go to the documentation to learn how to Fix dependency resolution errors.
* 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 3m 26s
Running Gradle task 'assembleDebug'... 208.9s
Exception: Gradle task assembleDebug failed with exit code 1
I am currently using Flutter's latest version that is Version 2.10.1. Also in my project, I used the 'better_player' pub package.
Please give me a solution to this.
Add following dependency in app/build.gradle in dependencies at the end of the file -
implementation 'com.google.android.exoplayer:exoplayer:2.17.0'
Example -
dependencies {
...
implementation 'com.google.android.exoplayer:exoplayer:2.17.0'
}
First : if you are using video_player
add this line in your app/build.gradle
implementation 'com.google.android.exoplayer:exoplayer:2.17.1'
Second : if you are using better_player
add this line in your app/build.gradle
implementation 'com.google.android.exoplayer:exoplayer:2.15.0'
Third : if you are using the both video_player & better_player
you should downgraded video_player version to 2.1.12 in pubspec.yaml
I added this code to my flutter pubspec.yaml file
plain_notification_token:
git:
url: https://github.com/zionnite/plain_notification_token.git
but whenever I run the app on my android I encounter an error
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
/Users/apple/.pub-cache/git/plain_notification_token-3709a43167c63bd8f22570afe4fb21fe2e982c39/android/src/main/java/net/kikuchy/plain_notification_token/PlainNotificationTokenPlugin.java:77: error: local variable result is accessed from within inner class; needs to be declared final
result.success(null);
^
/Users/apple/.pub-cache/git/plain_notification_token-3709a43167c63bd8f22570afe4fb21fe2e982c39/android/src/main/java/net/kikuchy/plain_notification_token/PlainNotificationTokenPlugin.java:81: error: local variable result is accessed from within inner class; needs to be declared final
result.success(task.getResult().getToken());
^
Note: /Users/apple/.pub-cache/git/plain_notification_token-3709a43167c63bd8f22570afe4fb21fe2e982c39/android/src/main/java/net/kikuchy/plain_notification_token/PlainNotificationTokenPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':plain_notification_token: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 3m 41s
Exception: Gradle task assembleDebug failed with exit code 1
please how do i resolve this?
The original package was updated recently, perhaps try the official one from pub.dev - https://pub.dev/packages/plain_notification_token, instead of the forked one from GitHub.
plain_notification_token: 0.0.4
I was update my Flutter SDK version from dev channel (1.14.5) to stable channel (2.0.1). My codes was works perfectly but now i get this error. I think the problem is at slide_countdown_clock but im not sure.
lib/Screens/sets4_widget/Countdown.dart:7:6: Error: The language version override has to be the same in the library and its part(s).
part 'package:slide_countdown_clock/clip_digit.dart';
^
lib/Screens/sets4_widget/Countdown.dart:8:6: Error: The language version override has to be the same in the library and its part(s).
part 'package:slide_countdown_clock/digit.dart';
^
lib/Screens/sets4_widget/Countdown.dart:9:6: Error: The language version override has to be the same in the library and its part(s).
part 'package:slide_countdown_clock/slide_direction.dart';
^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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 13s
Exception: Gradle task assembleDebug failed with exit code 1
^
I also share the lines of code that the error pointed to me below.
part 'package:slide_countdown_clock/clip_digit.dart';
part 'package:slide_countdown_clock/digit.dart';
part 'package:slide_countdown_clock/slide_direction.dart';
those parts are give me error. I tried flutter clean > flutter upgrade > flutter pub upgrade but still no result. Can anyone please help?
slide_countdown_clock, this package does not support Null Safety and Flutter 2.0.1 is a version with null safety.
So, you can't use it on Flutter version 2.0.1. Try to use another pub package that supports Null Safety.
You should not upgrade to Flutter version 2.0.1 until your existing project's dependencies are not supporting Null Safety.
I know this doesn't apply to your case, but I had this error as well and in my case it was due to the fact that I had the library code in the lib folder of the project using it. Just moving it in a different location solved my issue.
I'm beginner for flutter. After coding something I want to simulate codes for Android emulator. I could run successfully a few days ago but today I can't. Error code says unable to find package java.lang. I didn't find where I should look for find problem. SDK path is correct, flutter doctor didn't find any problem. Also I can run project with iOS emulator. I am working on MacOS. Here whole error information.
Fatal Error: Unable to find package java.lang in classpath or bootclasspath
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':location: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 7s
Gradle task assembleDebug failed with exit code 1
You may want to run with verbose enabled, flutter run -v. Then you can find the possible error and warnings. It also happens when your code is incompatible to the gradle version. And the solution for it is to delete .gradle from your use home folder, then on next build flutter will redownload compatible gradle version. In case of Linux, rm -rf ~/.gradle.
Main problem is about packages. Some of them needs android migrate to androidx. When project migrated androidx, problem is solved.
Documentation