Getting errors when I try to run my flutter app - flutter

When I run my flutter project I get this error
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\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 3m 6s
Exception: Gradle task assembleDebug failed with exit code 1
So I run flutter clean or delete my build folder manually, and then
run flutter pub get before running my flutter project, it then runs successfully, though
when compiling I get this error messages:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_analytics-9.1.12\android\src\main\java\io\flutter\plugins\firebase\analytics\FlutterFirebaseAnalyticsPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\src\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_dynamic_links-4.3.1\android\src\main\java\io\flutter\plugins\firebase\dynamiclinks\FlutterFirebaseDynamicLinksPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\src\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-11.4.4\android\src\main\java\io\flutter\plugins\firebase\messaging\JobIntentService.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\local_auth-1.1.11\android\src\main\java\io\flutter\plugins\localauth\LocalAuthPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
W/FlutterActivityAndFragmentDelegate(23939): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
Debug service listening on ws://127.0.0.1:51876/WyzGLXWyh3M=/ws
Finished with error: FileSystemException: Directory listing failed, path = 'C:\Users\USER\Downloads\Project\Tutorials\Documets\Flutter Tech Project\project1\New Code\dart_files\skyline-user\build\flutter_plugin_android_lifecycle\generated\source\buildConfig\debug\io\flutter\plugins\flutter_plugin_android_lifecycle\*' (OS Error: The system cannot find the path specified.
, errno = 3)
But it still works.
But anytime I want to rerun the flutter project I get the first error above, unless I run
flutter clean or delete the build folder manually & then run flutter pub get. So I have
to follow thesame process over & over again for me to compile and run my flutter project.
It is stressfull doing same process over and over again.
What could be the problem?

Related

Unable to add firebase_messaging to flutter module

I wanted to add firebase_messaging package to my flutter module and failing to build aar. I am using flutter 3.0.1. Steps to reproduce:
flutter create -t module --org com.example my_flutter_abc
cd my_flutter_abc
flutter pub add firebase_messaging
flutter build aar
Getting the following error
Running "flutter pub get" in my_flutter_abc... 2,428ms
Building with sound null safety
Running Gradle task 'assembleAarDebug'... 33.6s
Warning: The plugin firebase_messaging requires Android SDK version 33.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to C:\workspace\flutter-module\my_flutter_abc\.android\Flutter\build.gradle:
android {
compileSdkVersion 33
...
}
c:\flutter_3_0_1\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-14.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:399: error: cannot find symbol
.checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS)
^
symbol: variable POST_NOTIFICATIONS
location: class permission
c:\flutter_3_0_1\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-14.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebasePermissionManager.java:63: error: cannot find symbol
permissions.add(Manifest.permission.POST_NOTIFICATIONS);
^
symbol: variable POST_NOTIFICATIONS
location: class permission
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: c:\flutter_3_0_1\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-14.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_messaging: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 32s
Gradle task assembleAarDebug failed with exit code 1.
Modified my_flutter_abc.android\Flutter\build.gradle to use
android {
compileSdkVersion 33
....
}
then getting the following error when run flutter build aar again
Building with sound null safety
Running Gradle task 'assembleAarDebug'... 15.8s
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: c:\flutter_3_0_1\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-14.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_messaging:uploadArchives'.
> Could not publish configuration 'archives'
> Could not write to file 'c:\flutter_3_0_1\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-14.1.4\android\build\poms\pom-default.xml'.
* 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 14s
Gradle task assembleAarDebug failed with exit code 1.
The gradle files are automatically generated when flutter build command is executed. There seems to be compatibility issues related to firebase_messaging package. When I remove this package from pubspec.yaml, everything works fine.
This issue is not seen when flutter app project is created.

Build works on local but fails on codemagic | Execution failed for task ':app:stripDebugDebugSymbols'

I'm trying to implement a continuous deployment system to build my app and deploy to Google Play using codemagic. Doing a build works fine locally but fails remotely on codemagic.
Error summary:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> 1 exception was raised by workers:
org.gradle.process.internal.ExecException: A problem occurred starting process 'command '/usr/local/share/android-sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip''
Complete log:
== Building for Android ==
> flutter build appbundle --debug
Running "flutter pub get" in My_Project... 1,655ms
💪 Building with sound null safety 💪
Running Gradle task 'bundleDebug'...
[flutter_background_geolocation] Purging debug resources in release build
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/builder/programs/flutter_2_5_3/.pub-cache/hosted/pub.dartlang.org/geocoding-2.0.1/android/src/main/java/com/baseflow/geocoding/GeocodingPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> 1 exception was raised by workers:
org.gradle.process.internal.ExecException: A problem occurred starting process 'command '/usr/local/share/android-sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip''
* 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 2m 19s
Running Gradle task 'bundleDebug'... 141.1s
Gradle task bundleDebug failed with exit code 1
Build failed :|
Failed to build for Android
Current configuration on codemagic:
Flutter channel: stable
Mode: debug
Build for: Android
to fix this you need to upgrade Gradle version in android/gradle/wrapper/gradle-wrapper.properties to 6.7.1 or commit gradle wrapper to your repository if you don't have this file.
Additional to that you also might need to upgrade Android Gradle plugin in andriod/build.gradle
- classpath 'com.android.tools.build:gradle:3.5.4'
+ classpath 'com.android.tools.build:gradle:4.2.0'
WITHOUT GRADLE UPGRADE
if for some reasons you can't upgrade Gradle version you can freeze previous NDK version.
For that you can specify ndkVersion "22.1.7171670" in your build.gradle and make sure you use Java 1.8 since there is an issue with using latest Java versions.
In Codemagic you can specify Java version in environment section in your codemagic.yaml like this
workflows:
workflow-name:
environment:
ndk: r22b
java: 1.8

Can build app in debug mode but not in release mode Flutter

I am facing following error in console when running in release mode.
C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps\Googl
eMapsPlugin.java:19: error: cannot find symbol
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
^
symbol: class FlutterLifecycleAdapter
location: package io.flutter.embedding.engine.plugins.lifecycle
C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps\Googl
eMapsPlugin.java:92: error: cannot find symbol
lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding);
^
symbol: variable FlutterLifecycleAdapter
location: class GoogleMapsPlugin
Note: C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps
\Convert.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps
\TileProviderController.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':google_maps_flutter: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 3m 14s
Running Gradle task 'assembleRelease'... 195.8s
Gradle task assembleRelease failed with exit code 1
What I have tried so far.
Added this line to gradle.properties.
org.gradle.jvmargs=-Xmx4608m
In Android Studio
File > Invalidate Caches/Restart...
Deleted the complete pub_cache folder.
Restarted my Android Studio.
Ran flutter clean, flutter pub get, flutter upgrade.
Ran flutter pub cache repair command also.
But no solution worked.
What worked for me might help some one else.
1. Delete .gradle file present in android folder of project.
2. Update classpath in project level build.gradle file by hovering over it to the latest version.
3. Upgraded distribution URL in gradle-wrapper.properties
4. Clicked File/Invalidate Caches & restart option.
And it started to release my app once again.

gradle build failure Execution failed for task ':webview_flutter:compileDebugJavaWithJavac'

My flutter app doesn't even have webview_flutter plugin and it's showing error for that. Gradle build failure. First it told me to set minSDkVersion to 19. I did that but still error. I had the same app but different project running before with exact same code and plugins. I don't understand what's going on. Please help.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\thumbnails-
1.0.1\android\src\main\java\com\asapjay\thumbnails\ThumbnailsPlugin.java uses or overrides a
deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\flutter\.pub-cache\hosted\pub.dartlang.org\webview_flutter-
2.0.6\android\src\main\java\io\flutter\plugins\webviewflutter\InputAwareWebView.java:31: error:
cannot find symbol
private ThreadedInputConnectionProxyAdapterView proxyAdapterView;
^
symbol: class ThreadedInputConnectionProxyAdapterView
location: class InputAwareWebView
C:\flutter\.pub-cache\hosted\pub.dartlang.org\webview_flutter-
2.0.6\android\src\main\java\io\flutter\plugins\webviewflutter\InputAwareWebView.java:112: error:
cannot find symbol
new ThreadedInputConnectionProxyAdapterView(
^
symbol: class ThreadedInputConnectionProxyAdapterView
location: class InputAwareWebView
Note: Some input files use or override 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 ':webview_flutter: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 44s
Exception: Gradle task assembleDebug failed with exit code 1
ThreadedInputConnectionProxyAdapterView has wrong extension .jav
You can just change it to .java by hand as a temporary fix.
or
I temporarily downgraded webview_flutter back to 2.0.4. (after downgrading webview_flutter if this solution not working then you need to check your pubsepc.lock file for webview_flutter, because some other dependencies may extend webview_flutter so this package will visible in pubsepc.lock file, then you just need downgrade webview_flutter from this file also)
Enjoy!
This happen because of the webview_flutter package version issue. I have downgrade the version and it worked. Go to the pubspec.yaml and downgrade the version to 2.0.14

Flutter: Updated a plugin in resulted in an error about a deprecated API

My original error was this:
theme: Theme.of(context, shadowThemeOnly: true),
^^^^^^^^^^^^^^^
/D:/Program%20Files/flutter/packages/flutter/lib/src/material/theme.dart:106:20: Context: Found this candidate, but the arguments don't match.
static ThemeData of(BuildContext context) {
^^
/D:/Program%20Files/flutter/.pub-cache/hosted/pub.dartlang.org/dropdown_search-0.4.4/lib/src/selectDialog.dart:153:7: Error: No named parameter with the name 'child'.
child: AlertDialog(
^^^^^
/D:/Program%20Files/flutter/packages/flutter/lib/src/material/dialog.dart:1065:12: Context: Found this candidate, but the arguments don't match.
Future<T?> showDialog<T>({
^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'D:\Program Files\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1029
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDevDebug'.
> Process 'command 'D:\Program Files\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 14s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 15.4s
Exception: Gradle task assembleDebug failed with exit code 1
Once I changed the plugin in my pubspec.yaml I ended up getting this:
Note: D:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\apple_sign_in-0.1.0\android\src\main\java\dev\gilder\tom\apple_sign_in\AppleSignInPlugin.java uses or overrides a deprecated
API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.5.0\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.14.1+2\android\src\main\java\io\flutter\plugins\firebase\firestore\FlutterFirebaseFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.18.0+1\android\src\main\java\io\flutter\plugins\firebase\auth\FlutterFirebaseAuthPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
D:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_storage-4.0.1\android\src\main\java\io\flutter\plugins\firebase\storage\FirebaseStoragePlugin.java:47: warning: [deprecation] Registrar in PluginRegistry has been deprecated
public static void registerWith(PluginRegistry.Registrar registrar) {
^
1 warning
Note: D:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_keyboard_visibility-3.2.2\android\src\main\java\com\jrai\flutter_keyboard_visibility\FlutterKeyboardVisibilityPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\Program Files\flutter\.pub-cache\hosted\pub.dartlang.org\google_sign_in-4.5.5\android\src\main\java\io\flutter\plugins\googlesignin\GoogleSignInPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Parameter format not correct -
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 136.8s
Exception: Gradle build failed to produce an .apk file. It's likely that this file was generated under D:\WEBDEV\Endev Studios\Medical App\Brian's Dev Work at GSH\APP
TESTING\skinopathy-doctors\build, but the tool couldn't find it.
I'm using Flutter and I'm on the Master channel.
I've done:
flutter clean
flutter upgrade
flutter pub get
I don't even understand why I would have to go into the pubspec.yaml file to make changes; I thought flutter upgrade and flutter pub get dealt with all that.
The strange thing is, no one else seems to be getting this error but me. A thing to note: I am using VS Code and my colleagues are using intelliJ. They are able to access a "Flutter Plugins" folder and actually bring up a file for the plugin and make changes to resolve this. I don't have a Flutter Plugins folder.
Thank you in advance to everyone who helps.