Update Gradle in Flutter project - flutter

I have this project in Flutter, but I haven't been able to build an apk for a couple of weeks, because of the Gradle version. I've tried everything, but Flutter always returns the error below:
I already install every update I found, even though, it shows that the Gradle version is 4.10.2.
flutter build apk
...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\israel.gomes\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\audioplayers-0.17.4\android\build.gradle' line: 25
* What went wrong:
A problem occurred evaluating root project 'audioplayers'.
> Failed to apply plugin [id 'kotlin-android']
> The current Gradle version 4.10.2 is not compatible with the Kotlin Gradle plugin. Please use Gradle 5.3 or newer, or the previous version of the Kotlin plugin.
* 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
The plugin audioplayers could not be built due to the issue above.
Here some information about the project status and environment----------------------
Already changed gradle-wrapper.properties (Current file):
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
android/build.gradle(Current file):
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
.
.
.
gradle --version
------------------------------------------------------------
Gradle 5.6.2
------------------------------------------------------------
Build time: 2019-09-05 16:13:54 UTC
Revision: 55a5e53d855db8fc7b0e494412fc624051a8e781
Kotlin: 1.3.41
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM: 1.8.0_261 (Oracle Corporation 25.261-b12)
OS: Windows 10 10.0 amd64
flutter doctor -v
[√] Flutter (Channel dev, 2.1.0-12.1.pre, on Microsoft Windows [versão 10.0.19042.867], locale pt-BR)
• Flutter version 2.1.0-12.1.pre at C:\Flutter
• Framework revision 8264cb3e8a (3 weeks ago), 2021-03-10 12:37:57 -0800
• Engine revision 711ab3fda0
• Dart version 2.13.0 (build 2.13.0-116.0.dev)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\israel.gomes\AppData\Local\Android\Sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = C:\Users\israel.gomes\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] IntelliJ IDEA Community Edition (version 2020.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3
• Flutter plugin version 55.0.4
• Dart plugin version 203.7759
[√] VS Code (version 1.54.3)
• VS Code at C:\Users\israel.gomes\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.20.0
[√] Connected device (3 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.114
• Edge (web) • edge • web-javascript • Microsoft Edge 87.0.664.75
• No issues found!

Here is how I upgraded gradle in my older Flutter project:
Create a new temp project with the latest version of Flutter. You'll use this to see what version of gradle Flutter is using nowadays.
In the temp project open android/build.gradle check the classpath version of gradle being used and update that in your old Flutter project. For me today it looks like this:
classpath 'com.android.tools.build:gradle:4.1.0'
In the temp project open android/gradle/wrapper/gradle-wrapper.properties and check the distributionUrl. Update your old project to use the same one. For me today it looks like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
Rerun your app. It has to download the new version of gradle to the android/.gradle directory so the first time might take a while.

The easiest way (I do so as Android Dev):
Right click android folder in root folder
Flutter
Open in Android Studio
Wait for it to load completely
It'll ask you "Would you like to upgrade gradle?|"
Click Yes
flutter clean

android/gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
android/build.gradle:
classpath "com.android.tools.build:gradle:7.0.1"
in android/gradle.properties, add this:
org.gradle.java.home=C:\\Program Files\\Android\\Android Studio\\jre

It appears as if audioplayers has an incompatible gradle version with your project.
Try upgrading audioplayers to the newest version, although this may not fix the issue, as the last comment in this thread was less than 24 hours ago.
audioplayers: ^0.18.3

An update for 2022, Android Studio Dolphin. The other answers gave me a start, but are no longer up-to-date.
Open the main flutter project in Android Studio
Right click on the [android] module. Choose "Flutter". Choose Open Android module in Android Studio
I opened in a new window, but this probably isn't required.
As it says in the text here , choose on the menu (you must be in the "Android" project)
File
Project Structure
Project
Click the Android Gradle Plugin Version dropdown and choose the latest version (or whatever one you want to update to)
Click the Gradle Version dropdown and choose the latest version (or whatever one you want to update to)
Give time for your Gradle to sync (it might have to download quite a lot, so be patient)
Now you should be able to close the Android project window, and go back to the flutter project

Try renaming the android/ folder in your project. Then run flutter create . in the directory. This should recreate your android directory. Try your build again and see if it fixed your problem.

Upgrade gradle in a Flutter project.
Open the file gradle-wrapper.properties located at {yourProjectName}/android/gradle/wrapper/gradle-wrapper.properties and replace the distributionUrl by changing the gradle version.
For example if you want to upgrade gradle from version 5.1.1 to 6.1.1, change the Url from https\://services.gradle.org/distributions/gradle-5.1.1-all.zip to https\://services.gradle.org/distributions/gradle-6.1.1-all.zip and rebuild your app.

Fast way of doing it:
Open AndroidManifest.xml (andriod/app/src/main/AndroidManifest.xml)
Click "Open for Editing in Android Studio"

In late 2022, Android Studio can fix that and upgrade Gradle:
Open the main flutter project in Android Studio
Right click on the android module. Choose "Flutter". Choose Open Android module in Android Studio, I opened in a new window
Then, in the lower right corner, Android Studio presents a message suggesting to upgrade Gradle. Follow this suggestion!
After that, you can close the Android project window
Based on Nick Fortescue answer

I was getting this issue:
FAILURE: Build failed with an exception.
Where:
Build file '/home/marcelo-cesar/Desktop/Overseasconnection-player-teams/android/app/build.gradle' line: 47
What went wrong:
A problem occurred evaluating project ':app'.
Could not find method minSdkVersion() for arguments [19, null] on DefaultConfig$AgpDecorated_Decorated{name=main, dimension=null, minSdkVersion=null, targetSdkVersion=null, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=com.ls.overseasagent, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=[], buildConfigFields={}, resValues={}, proguardFiles=[], consumerProguardFiles=[], manifestPlaceholders={applicationName=android.app.Application}, wearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.DefaultConfig$AgpDecorated.
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 3s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I solved it by making these changes:
In android/build.gradle
update these lines with these following:
ext.kotlin_version = '1.7.10'
classpath 'com.android.tools.build:gradle:7.3.1'
In android/app/build.gradle
update with this value:
compileSdkVersion 33
defaultConfig {
…
minSdkVersion 21
targetSdkVersion 31
}
In android/gradle/wrapper/gradle-wrapper.properties
update distribution line with this:
distributionUrl=https://services.gradle.org/distributions/gradle-7.5-all.zip

Related

Flutter App stuck at "Running Gradle task 'assembleDebug'

My flutter app when run from VScode is always stuck at running-gradle-task-assembledebug
When I run flutter run -v in command prompt, it works but not from VSCode. This issue seems to have come since last week.
Tried ./gradlew clean and ./gradlew clean build, this works sometimes and buils from vscode
Deleted and created a new emulator device and also tried many suggestions online
Output from flutter doctor -v
[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19044.1415], locale en-US)
• Flutter version 2.8.1 at E:\Flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (4 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at E:\sdk\Android
• Platform android-31, build-tools 30.0.2
• ANDROID_SDK_ROOT = E:\sdk\Android
• Java binary at: F:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 2020.3)
• Android Studio at F:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[√] Connected device (3 available)
• AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 97.0.4692.71
• Edge (web) • edge • web-javascript • Microsoft Edge 96.0.1054.62
• No issues found!
created a brand new flutter project and did gradlew clean and got below messages for gradlew clean --warning-mode all
> Configure project :app
Adding a Configuration as a dependency is a confusing behavior which isn't recommended. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. If you're interested in inheriting the dependencies from the Configuration you are adding, you should use Configuration#extendsFrom instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.artifacts.Configuration.html#org.gradle.api.artifacts.Configuration:extendsFrom(org.gradle.api.artifacts.Configuration[]) for more details.
at build_59yj46qtreisbbowxqfuhj29p$_run_closure3.doCall(D:\MobileDevelopment\GitRepo\jigsaw\android\build.gradle:26)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the destinationDirectory property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:destinationDir for more details.
at FlutterPlugin$_addFlutterTasks_closure20$_closure44.doCall(E:\Flutter\packages\flutter_tools\gradle\flutter.gradle:833)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.archiveName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveFileName property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archiveName for more details.
at FlutterPlugin$_addFlutterTasks_closure20$_closure44.doCall(E:\Flutter\packages\flutter_tools\gradle\flutter.gradle:834)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
BUILD SUCCESSFUL in 2s
2 actionable tasks: 2 up-to-date
Running gradlew build gives
> Task :app:stripDebugDebugSymbols
Unable to strip the following libraries, packaging them as they are: libflutter.so.
> Task :app:stripProfileDebugSymbols
Unable to strip the following libraries, packaging them as they are: libapp.so, libflutter.so, libvmservice_snapshot.so
> Task :app:lint FAILED
Ran lint on variant debug: 3 issues found
Ran lint on variant release: 3 issues found
Ran lint on variant profile: 3 issues found
Wrote HTML report to file:///D:/MobileDevelopment/GitRepo/jigsaw/build/app/reports/lint-results.html
Wrote XML report to file:///D:/MobileDevelopment/GitRepo/jigsaw/build/app/reports/lint-results.xml
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lint'.
> Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
lintOptions {
abortOnError false
}
}
...
Errors found:
D:\MobileDevelopment\GitRepo\jigsaw\android\app\src\main\AndroidManifest.xml:5: Error: Class referenced in the manifest, com.example.jigsaw.${applicationName}, was not found in the project or the libraries [MissingClass]
android:name="${applicationName}"
~~~~~~~~~~~~~~~~~~
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2m 26s
94 actionable tasks: 90 executed, 4 up-to-date
Redownloaded flutter 2.8 sdk from google official docs which also has dart in it and retried.
It's due to your gradle is downloading it's version but sometimes it's speed download too low and won't be downloaded, you can fix it :
first check your gradle version in root of your project :
<project name> > android > gradle > wrapper > gradle-wrapper.properties
and check distributionUrl , you will see which gradle version is using in project and is downloading , so you should download that version in this link https://services.gradle.org/distributions/
after you download, copy and go to this directory :
C:\Users\<user name>\.gradle\wrapper\dists\gradle <your version>\<a file with weird name>\
paste and unzip your downloaded file here.
it works for me every time I hope for you too.
let me know if there is any question.
I did solve the problem by first executing
flutter clean
and then, in order to recompile the project daet files
flutter pub upgrade

Unable to run flutter app in android studio

I created a new flutter project and when run it, it gives that error
Target kernel_snapshot failed: Exception: The value of -DDartDefines is not formatted correctly.
The value must be a JSON-encoded list of strings but was:
[flutter.inspector.structuredErrors=true]
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'D:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\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
Exception: Gradle task assembleDebug failed with exit code 1
I have tried flutter clean, and same error
flutter doctor log :
D:\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel master, v1.16.4-pre.69, on Microsoft Windows [Version 10.0.18363.959], locale en-US)
• Flutter version 1.16.4-pre.69 at D:\flutter
• Framework revision 19e7db585d (4 months ago), 2020-04-01 11:16:01 -0700
• Engine revision c9506cb8e9
• Dart version 2.8.0 (build 2.8.0-dev.18.0 eea9717938)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\user\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[!] VS Code (version 1.47.2)
• VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
Process finished with exit code 0
According to what flutter doctor is giving you the problem might be related to Android Sdk not installed or not configured really well:
Flutter provides a command to update the Android SDK path: Use
flutter config --android-sdk <path-to-your-android-sdk-path>
You can install it directly from Android Studio:
To open the SDK Manager from Android Studio, click Tools > SDK Manager or click SDK Manager in the toolbar. You might have to uncheck "hide obsolete packages" and install the packages that were considered obsoletes.
Or you can install it from this link and configure it like I said before:
https://www.google.com/url?sa=t&source=web&rct=j&url=https://android-sdk.fr.uptodown.com/windows&ved=2ahUKEwi-itWCkuzqAhXTZTUKHa29CRMQFjACegQIAhAB&usg=AOvVaw1QSSVVMrZzFltXvboDbTeQ

Warning! The 'flutter' tool you are currently running is from a different Flutter repository than the one last used by this package

Everytime i try to build an apk or appbundle, this error comes up. please help.
Warning! The 'flutter' tool you are currently running is from a different Flutter repository than the one last used by this package. The repository from which the 'flutter' tool is currently executing will be u
sed instead.
running Flutter tool: C:\Users\MOMO\Mygit\flutter
previous reference : C:\flutter
This can happen when you have multiple copies of flutter installed. Please check your system path to verify that you are running the expected version (run 'flutter --version' to see which flutter is on your pat
h).
Compiler message:
/C:/flutter/packages/flutter/lib/src/rendering/layer.dart:1580:36: Error: 'ImageFilterEngineLayer' isn't a type.
oldLayer: _engineLayer as ui.ImageFilterEngineLayer,
^^^^^^^^^^^^^^^^^^^^^^
/C:/flutter/packages/flutter/lib/src/rendering/layer.dart:1578:27: Error: The method 'pushImageFilter' isn't defined for the class 'SceneBuilder'.
'SceneBuilder' is from 'dart:ui'.
Try correcting the name to the name of an existing method, or defining a method named 'pushImageFilter'.
engineLayer = builder.pushImageFilter(
^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\MOMO\Mygit\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 780
What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
Process 'command 'C:\Users\MOMO\Mygit\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 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 15.7s
Gradle task assembleRelease failed with exit code 1
Thats my flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.18363.778], locale en-US)
• Flutter version 1.12.13+hotfix.9 at C:\Users\MOMO\Mygit\flutter
• Framework revision f139b11 (4 weeks ago), 2020-03-30 13:57:30 -0700
• Engine revision af51afceb8
• Dart version 2.7.2
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\MOMO\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: D:\Android\Android Studio1\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Android Studio (version 3.6)
• Android Studio at D:\Android\Android Studio1
• Flutter plugin version 45.0.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] IntelliJ IDEA Ultimate Edition (version 2019.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.1
• Flutter plugin version 45.0.2
• Dart plugin version 193.5731
[!] Connected device
! No devices available
! Doctor found issues in 1 category.

I am unable to build my flutter web project

When trying to run flutter build web i get "build web" is not currently supported.
I had previous errors where i was stuck with Dart 2.5.0-dev.4.0.flutter-be66176534 and required 2.5.0 or higher, this has now been solved but i am unable to build my project.
flutter doctor -v
[√] Flutter (Channel stable, v1.9.1+hotfix.2, on Microsoft Windows [Version 10.0.18932.1000], locale en-GB)
• Flutter version 1.9.1+hotfix.2 at C:\src\flutter
• Framework revision 2d2a1ffec9 (8 days ago), 2019-09-06 18:39:49 -0700
• Engine revision b863200c37
• Dart version 2.5.0
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\germa\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[!] Android Studio (version 3.4)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[√] VS Code (version 1.38.1)
• VS Code at C:\Users\germa\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.4.1
I have tried
re-installing dart
re-installing flutter
re-installing Visual Studio code
copy file contents to a new web project (same error)
I couldn't find any information on what this is caused by and how to resolve it online
What can i do to resolve this error?
Please once do configure like below
flutter channel stable
flutter upgrade
flutter config --enable-web
cd into project directory
flutter create .
flutter run -d chrome
So currently you are at stable channel . You have to switch to the beta channel as flutter web is not at a stable channel right now. In order to make it working run the following commands in the terminal.
flutter channel beta
flutter upgrade
flutter config --enable-web.
After that restart your IDE and build the web app.
I was facing problem in flutter stable 2.0.2, by running
flutter create .
it was not creating web module, after upgrading it has started working. I guess my flutter web sdk had some issue so by fresh upgrade it got fixed.
if your are facing the problem
Ambiguous organization in existing files: {package_name1, package_name2}. The --org command line argument must be specified to recreate project.
you can use this command
flutter create --org package_name1 .
And
flutter run -d chrome
Just check whether you have used any plugins in pubspecs.yaml that is nonweb supportive.
you have to add web support to an existing app:
flutter create .
then try to
flutter build web

Flutter run stuck at Installing build\app\outputs\apk\app.apk

Edit: It seemed to work after restarting everything, no other solution really noticed.
I couldn't find useful solutions on following thread:
Flutter stuck at Installing build\app\outputs\apk\app.apk
It's not the same issue, mine doesn't finish installing.
I have an Honor 7 as a connected device and using Visual Studio Code.
When running 'flutter run' following happens:
Launching lib/main.dart on PLK L01 in debug mode...
Initializing gradle... 1,1s
Resolving dependencies... 3,3s
Gradle task 'assembleDebug'...
Gradle task 'assembleDebug'... Done 15,6s
Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk... -
Once last step is loading, my device asks to accept app installation. Once accepted it provides 2 options after installation:
Open App
Finish ( Meaning = return to home screen )
Either way the last step doesn't finish. 'flutter clean' makes no difference. Hot reload not working. Did anyone else encounter this issue ?
'flutter doctor -v' output:
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.17134.590], locale de-DE)
• Flutter version 1.0.0 at F:\flutter
• Framework revision 5391447fae (3 months ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at C:\Users\user\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-P, build-tools 27.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
• All Android licenses accepted.
[√] Android Studio (version 2.2)
• Android Studio at E:\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_76-release-b03)
[√] Android Studio (version 3.1)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[!] IntelliJ IDEA Community Edition (version 2017.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.io/intellij-setup/#installing-the-plugins
[!] IntelliJ IDEA Ultimate Edition (version 2017.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2017.3.2
X Flutter plugin not installed; this adds Flutter specific functionality.
• Dart plugin version 173.4127.31
• For information about installing plugins, see
https://flutter.io/intellij-setup/#installing-the-plugins
[√] VS Code, 32-bit edition (version 1.12.2)
• VS Code at C:\Program Files (x86)\Microsoft VS Code
• Flutter extension version 2.22.3
[√] Connected device (1 available)
• PLK L01 • H8WDU15207300112 • android-arm64 • Android 6.0 (API 23)
! Doctor found issues in 2 categories.
Solutions is quite simple
For flutter hot reload problems that may be happening with your project,
It is a problem with your device, and not flutter or Android Studio
This happens when your logcat hangs up.
You might want to increase your buffer size.
To do this, go into your device or emulator:
Settings > Developer options (Ensure they are turned on),
Change the buffer size to a higher number.
Then run flutter run -v again
Other user may get solution in this url.
In my case the app uninstalled manually so it is not showing in launcher .
and got solution in this
post.
which is
Go to Settings.
Go to Apps.
Select your app. (here, you can verifythat your app is not uninstalled properly).
Open the overflow menu (which are 3 dots)on the top right and select Uninstall for all users.
In my case the problem was that I forgot to change MainActivity.kt package name after I modified it.
package com.WrongCompanyName.WrongProjectName
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity: FlutterActivity() {
override fun configureFlutterEngine(#NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
Make sure your MainActivity.java is in the right location, it has a MainActivity class declaration, and that the package matches your package id.
Edit: You can enter this in the terminal
flutter run
And then r to hot reload. You might have to Ctrl+C and n first
It's slower than F5, but still works!
My original answer:
I got around this problem by typing the command in the Terminal
flutter run -d <deviceId>
for my LG phone, it was
flutter run -d LGUS998d7315d51
My solution was to check the package name (iOS is applicationId) of my Android App.
I had recently changed the name of my package from the default "com.example.app_name" to something more custom. However, I had forgotten to change all of the locations.
I believe the most important locations are as follows:
Mac / iOS
build.gradle -- search for "applicationId"
Android
[app_name]\android\app\src\debug\AndroidManifest.xml
[app_name]\android\app\src\main\AndroidManifest.xml
[app_name]\android\app\src\profile\AndroidManifest.xml
Just search for package="
Open android\app\build.gradle and set a different application id to the app.
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.othervalue.sbmicalc"
}
Then remove previous build:
flutter clean
and run again:
flutter run
I have been struggling with this off and on for a year, here is what I just noticed that makes it work or not work on my system.
I discovered tonight that if I have my virus protection running my emulator stalls in the
" ---> Built build\app\outputs\apk\debug\app-debug.apk.
and I just get a white screen. I turn off the virus protection and it works fine in debug mode.
If its on I have to keep going to the terminal and doing: " flutter run " to see any changes I have made.
Maybe this will help someone.
I faced this problem and found a solution.(I use emulator)
It seems this is just an emulator problem.
AVD Manager -> Actions -> Wipe Data
Maybe you need to do flutter clean, but the problem will solve.
In my case, it was not uninstalled the flutter app properly from mobile phone because my mobile has normal space and private space...so when I uninstall the app from normal space it was uninstalled but not uninstall from private space. then after removing the app from private space and run
flutter clean
and run the again it's work fine!
flutter run
I have also faced the same issue when I have changed targetSdkVersion to static values (33) in my case
android/app/build.gradle
targetSdkVersion flutter.targetSdkVersion to targetSdkVersion 33
So, By un-doing changes and by adding constant in local.properties worked for me
android/app/build.gradle
targetSdkVersion flutter.targetSdkVersion
and
android/local.properties
flutter.versionName=1.0.0
flutter.versionCode=1
flutter.targetSdkVersion=33
If you see your app installed like this -> just click it to open. It worked for me