Flutter: Gradle failed when trying to built app - flutter

Gradle always get stucked for more than 10 minutes when I build
Here are the logs
+2671 ms] FAILURE: Build failed with an exception.
[ +98 ms] * What went wrong:
[ +1 ms] Gradle could not start your build.
[ +3 ms] > Could not create service of type ChecksumService using
BuildSessionScopeServices.createChecksumService().
[ +7 ms] > Cannot lock checksums cache (/home/pavan/new_project/android/.gradle/checksums) as
it has already been locked by this process.

It's probably related to your cache.
If you're using a Windows OS, clear your .lock cache in this directory (search .lock in the directory itself and remove everything with a .lock extension deleted):
C:\Users<your username>.gradle\caches
If you got a Linux:
/home/ your username /.gradle/caches
If you've got a Mac:
/Users/ your username /.gradle/caches

On Windows 10, I deleted all .lock files located in .gradle directory AFTER having restarted my pc !

Related

flutter build apk --split-per-abi doesnt create three APK files

after running command in terminal, Gradle is completed unreasonably quick with a successful build result only for app-armeabi-v7a-release.apk, however, when checking the flutter-apk folder I see that only the files bellow were built and had their time stamp updated
app-debug.apk,
app.apk,
app.apk.sha1
but other files were not changed and still had an old time stamp (two weeks ago)
app-arm64-v8a-release.apk,
app-armeabi-v7a-release.apk,
app-x86_64-release.apk
• output message of flutter build apk --split-per-abi command
============================================================
Project_Path> flutter build apk --split-per-abi
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 12.5s
√ Built build\app\outputs\flutter-apk\app-armeabi-v7a-release.apk (7.8MB).
• steps taken so far
=============================
run flutter doctor
•• No issues found!
run flutter clean
••
Deleting build... 863ms
Deleting .dart_tool... 6ms
Deleting .packages... 0ms
Deleting Generated.xcconfig... 0ms
Deleting flutter_export_environment.sh... 0ms
Deleting .flutter-plugins-dependencies... 0ms
Deleting .flutter-plugins... 0ms
OUTPUT APK FILES
Try removing the contents of build/app/outputs/apk then retry the commands.

Flutter app crashes on hot restart only on iOS Simulator

Not sure what is going on, but when I hot restart my flutter app crashes using iOS simulator. Hot restart works fine on an Android simulator. I even tried to uninstall and install XCode again.
Here is what gets printed on the terminal
[ +459 ms] Hot restart performed in 924ms.
[ +3 ms] Restarted application in 936ms.
[ +900 ms] Service protocol connection closed.
[ ] Lost connection to device.
[ +3 ms] DevFS: Deleting filesystem on the device (file:///Users/frederickmfinanga/Library/Developer/CoreSimulator/Devices/775342AF-E52F-46EB-9CDB-9C29720FC357/data/Containers/Data/Application/D093EF45-D895-481C-B965-CA56F7881A5C/tmp/the_hair_routinenSBAWo/the_hair_routine/)
Failed to send request: {"jsonrpc":"2.0","id":"46","method":"getMemoryUsage","params":{"isolateId":"isolates/4165970133496907"}}
[ +257 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not completed
[ +1 ms] "flutter run" took 646,839ms.
[ +259 ms] ensureAnalyticsSent: 242ms
[ +1 ms] Running shutdown hooks
[ ] Shutdown hook priority 4
[ ] Shutdown hooks complete
[ ] exiting with code 0
I had the same issue. After two days of debugging I have just found out it was caused by one of my dependencies. It is firebase_auth package version 1.1.3.
As I can see the issue is resolved in firebase_auth 1.1.4 released on 10th of May 2021.
So just update to firebase_auth 1.1.4 if you use this package
I faced something similar a few days back.
There can be two possibilities why it is happening :
You have not granted permission for something you are trying to access (like getting the location/camera ). If this is the case then read the docs of the package you might be using and add the permissions programatically.
Sometimes our podfile reference gets corrupted. (This is what happened in my case). For this delete your podfile.lock file (ios/podfile.lock). For a fresh start you can also delete your pubspec.lock as well. And then do a flutter pub get or simply run your app.

Why does a cloned Flutter app not run on my phone?

I'm trying to run a Flutter app on my phone using VSC.
The app is a clone of this repository:
https://github.com/londonappbrewery/dicee-flutter
This is the error message I'm getting:
https://pastebin.com/MtGCSC98
(I tried to post the code on the post, but SO doesn't allow it since it's "too much code", then I posted only the link to pastebin and it said "too little code" smh. So, here are the first 4 rows...)
c:\Users\mudcip\Desktop\programming\flutter\dicee-flutter\lib>flutter run -v
[ +440 ms] executing: [C:\src\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +223 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +11 ms] 9b2d32b605630f28625709ebd9d78ab3016b2bf6
I tried to search other similar questions but found no solution.
This error occurs because you are running program from lib folder insted running from main project

Flutter APK build android resource linking failed vibrate package

I'm trying to build an apk for my app but I get a resource linking fail on the vibrate package.
I can run my app in release mode and I can also build an app bundle without failure.
I already did a successful apk build two days ago, what I changed since this build:
-upgrading to Android studio 4.0
-run a pub cache repair (due to an other error resolved now)
Error I get:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':vibrate:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\plest\.gradle\caches\transforms-2\files-2.1\1aeb117cf01e0e03a347b2b45aacb6fb\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontStyle not found.
C:\Users\plest\.gradle\caches\transforms-2\files-2.1\1aeb117cf01e0e03a347b2b45aacb6fb\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/font not found.
C:\Users\plest\.gradle\caches\transforms-2\files-2.1\1aeb117cf01e0e03a347b2b45aacb6fb\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontWeight not found.
C:\Users\plest\.gradle\caches\transforms-2\files-2.1\1aeb117cf01e0e03a347b2b45aacb6fb\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\plest\.gradle\caches\transforms-2\files-2.1\1aeb117cf01e0e03a347b2b45aacb6fb\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 22s
Running Gradle task 'assembleRelease'... 24,3s
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 cloud_firestore...
Running Gradle task 'assembleAarRelease'...
The plugin cloud_firestore could not be built due to the issue above.
Process finished with exit code 1
My flutter doctor is good and a flutter clean doesn't change anything.
I can't access the flutter panel when right click on the android panel.
EDIT:
if I run with verbose I get this in my log
[ +17 ms] > Task :vibrate:extractDebugAnnotations UP-TO-DATE
[ +1 ms] > Task :vibrate:mergeDebugGeneratedProguardFiles UP-TO-DATE
[ +1 ms] > Task :vibrate:mergeDebugConsumerProguardFiles UP-TO-DATE
[ +1 ms] > Task :vibrate:prepareLintJarForPublish UP-TO-DATE
[ +1 ms] > Task :vibrate:mergeDebugJavaResource UP-TO-DATE
[ +1 ms] > Task :vibrate:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
[ +2 ms] > Task :vibrate:transformNativeLibsWithSyncJniLibsForDebug UP-TO-DATE
[ +1 ms] > Task :vibrate:bundleDebugAar UP-TO-DATE
[ +1 ms] > Task :vibrate:compileDebugSources UP-TO-DATE
[ +1 ms] > Task :vibrate:assembleDebug UP-TO-DATE
[ +253 ms] > Task :app:mergeDebugNativeLibs
[ +1 ms] Unable to strip library
'C:\Users\plest\StudioProjects\the_spot\build\app\intermediates\merged_native_libs\debug\out\lib\x86\libflutter.so' due to
missing strip tool for ABI 'X86'. Packaging it as is.
[ +97 ms] > Task :app:stripDebugDebugSymbols
[ +1 ms] Compatible side by side NDK version was not found.
[ +1 ms] Unable to strip library
'C:\Users\plest\StudioProjects\the_spot\build\app\intermediates\merged_native_libs\debug\out\lib\x86_64\libflutter.so' due
to missing strip tool for ABI 'X86_64'. Packaging it as is.
I resolved my issue upgrading vibrate 0.0.4 to flutter_vibrate 1.0.0

How exactly should I host a dart package internally in an internet less environment

I am trying to host all the packages my flutter application depends in svn repo and use it in a system without internet connection(unfortunately git is not possible yet) but has access to this svn repo.
What I did so far:
I do know I can use a path based dependency in my pubspec.yaml by using the path attribute. For e.g.
I can depend on a specific package named xyz by keeping it along with its dependecies in a folder say packages alongside the lib folder as shown below.
project
|_ lib
|_ packages
|_ xyz
|_ dep1_for_xyz
|_ dep2_for_xyz
Then referring to it in pubspec.yaml as shown below and this works.
dependencies:
flutter:
sdk: flutter
xyz:
path: packages/xyz
Problems & question:
I came across this environment variable pub_hosted_url in the following pages: ref1 and ref2.
I tried to use it as follows.
Create an environment variable pub_hosted_url and point it to a directory in the remote svn repo.
for e.g., https://username:password#repository_url/dart_packages.
Then add & commit a package inside this dart_packages folder.
for e.g. built_value_generator-6.8.2 and all its relevant dependencies in a similar fashion.
Then add the dependencies in the pubspec.yaml as usual.
for e.g built_value_generator: ^6.7.1
Then run the flutter pub get -v.
Problem1:
I am currently facing an Handshake error on client side. I understand this because of the certificate that svn server uses. Since its a self signed certificate, flutter/pub/dart is unable to verify the validity of this certificate.
following is the error I see.
[ +528 ms] IO : Retry #1 for GET https://pub_hosted_url/api/packages/built_value_generator...
[ +3 ms] IO : HTTP GET https://pub_hosted_url/api/packages/built_value_generator
[ +2 ms] | Accept: application/vnd.pub.v2+json
[ +2 ms] | user-agent: Dart pub 2.7.0
[ +24 ms] IO : HTTP error:
[ +2 ms] | HandshakeException: Handshake error in client (OS Error:
[ +2 ms] | CERTIFICATE_VERIFY_FAILED: self signed certificate in certificate chain(handshake.cc:354))
[ +1 ms] |
[ +1 ms] | dart:_http _HttpClient.openUrl
[ +2 ms] | package:http/src/io_client.dart 33:36 IOClient.send
[ ] | package:pub/src/http.dart 68:39 _PubHttpClient.send
[ ] | package:http_retry/http_retry.dart 97:33 RetryClient.send
Question1
How do I let flutter pub get know that this is a trusted host or even add this certificate into its trusted list.
Problem 2:
This problem I see is from the above error message, where the packages are looked with the following url format https://pub_hosted_url/api/packages/my_dependency. This means the flutter pub get expects packages to be placed in a very specific format or specific location. I couldn't find any relevant documentation for this apart from this alpha level pub_server package here.
Question 2
So question is What is the correct format of hosting our packages internally in an svn repo, if at all if its possible.