Flutter application crashing after branch change - flutter

We changed our branch yesterday and the app isn't running on the new branch. It gives me an error:
Launching lib/main.dart on Redmi Note 9 Pro in debug mode...
/home/aman/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-8.3.0/android/src/main/java/com/baseflow/permissionhandler/ServiceManager.java:75: warning: [deprecation] queryIntentActivities(Intent,int) in PackageManager has been deprecated
List<ResolveInfo> callAppsList = pm.queryIntentActivities(callIntent, 0);
^
error: warnings found and -Werror specified
/home/aman/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-8.3.0/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java:317: warning: [deprecation] getPackageInfo(String,int) in PackageManager has been deprecated
.getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS);
^
1 error
2 warnings
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':permission_handler: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 1m 5s
Running Gradle task 'assembleDebug'... 66.7s
Exception: Gradle task assembleDebug failed with exit code 1
I dont think the branch change is any problem in this. I have no idea tho what its saying.

It states that your permission handler is using a deprecated package. If you are using an older version of flutter upgrade the permission handler in pubspec to 9.0.0 or if you are using flutter 3+ use the latest version and try again. As a first try you can change the version of permission handler in pubspec to any
permission_handler: any
And try if it works

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.

PackageManager has been deprecated

I have a project in flutter that I developed a few years ago. I have flutter version 2.10.4 installed on my computer. When I want to run the application on my computer, the Android studio console shows me the following message:
/Users/rodrigosanchez/development/flutter/.pub-cache/hosted/pub.dartlang.org/android_intent-2.0.2/android/src/main/java/io/flutter/plugins/androidintent/IntentSender.java:87: warning: [deprecation] resolveActivity(Intent,int) in PackageManager has been deprecated
return packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null;
^
error: warnings found and -Werror specified
1 error
1 warning
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':android_intent: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 9s
Exception: Gradle task assembleDebug failed with exit code 1
I hope you can help me.
Thanks so much for reading.
Run the app on Android device.
Thanks
it seem happen because android_intent package is discontinued and replacing by android_intent_plus package. try changing your package and choose the package version that matched to your current SDK version.

FlutterSecureStoragePlugin.java:260: error: method references are not supported in -source 7

when I build the flutter 2.10.3 app, shows error:
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
Running Gradle task 'assembleDebug'...
/Users/xiaoqiangjiang/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-5.0.0/android/src/main/java/com/it_nomads/fluttersecurestorage/FlutterSecureStoragePlugin.java:250: error: lambda expressions are not supported in -source 7
handler.post(() -> methodResult.success(result));
^
(use -source 8 or higher to enable lambda expressions)
/Users/xiaoqiangjiang/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-5.0.0/android/src/main/java/com/it_nomads/fluttersecurestorage/FlutterSecureStoragePlugin.java:260: error: method references are not supported in -source 7
handler.post(methodResult::notImplemented);
^
(use -source 8 or higher to enable method references)
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_secure_storage: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 8s
Exception: Gradle task assembleDebug failed with exit code 1
what should I do to tweak the source version?
Try using version 5.0.1 which has java 8.
5.0.1 #
[Android] Added java 8 requirement for gradle build.
Please check the same in its changelog flutter_secure_storage

flutter app apk is giving clipboard_manager error

I am trying to build an apk of my flutter app, but when I run this command
flutter build apk
I encounter the following error;
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':clipboard_manager:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/home/username/.gradle/caches/transforms-2/files-2.1/a528b13ac93e64cafa3d0480e2c93207/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/home/username/.gradle/caches/transforms-2/files-2.1/a528b13ac93e64cafa3d0480e2c93207/core-1.1.0/res/values/values.xml:142:5-173: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 9s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 10.1s
The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the
incompatibility.
Building plugin clipboard_manager...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 741ms
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'clipboard_manager'.
> 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. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
The plugin clipboard_manager could not be built due to the issue above.
I am getting the flutter pub outdated --mode=null-safety
Package Name Current Upgradable Resolvable Latest
direct dependencies:
clipboard_manager ✗0.0.4 ✗0.0.4 ✗0.0.4 ✗0.0.4
cupertino_icons ✗0.1.3 ✗0.1.3 ✓1.0.3 ✓1.0.3
dio ✗3.0.10 ✗3.0.10 ✓4.0.0 ✓4.0.0
flutter_circular_chart ✗0.1.0 ✗0.1.0 ✗0.1.0 ✗0.1.0
flutter_secure_storage ✗3.3.5 ✗3.3.5 ✓4.2.0 ✓4.2.0
flutter_svg ✗0.19.3 ✗0.19.3 ✓0.22.0 ✓0.22.0
http ✗0.12.2 ✗0.12.2 ✓0.13.3 ✓0.13.3
image_picker ✗0.6.5+3 ✗0.6.5+3 ✓0.8.0+3 ✓0.8.0+3
logger ✗0.9.4 ✗0.9.4 ✓1.0.0 ✓1.0.0
provider ✗4.3.3 ✗4.3.3 ✓5.0.0 ✓5.0.0
8 dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml, or run `flutter pub upgrade --null-safety`.
I have searched for it, and they told to change the flutter.sdk, to home.username/Android/Sdk I did this, but after running the buiuld command I got home/lechat/snap/flutter/common/flutter in flutter.sdk in local.properties.
I do not know what the problem actually is. Kindly halp me with this problem. If you any other information I am ready to share it.
I have also followed this question, related problem
but still getting the same error.
Check this similar question there are multiple answers and all of them seem to get the work done, only one of them uses clipboard_manager though.

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