When I run the app it get stuck
Launching lib\main.dart on Lenovo A319 in debug mode...
Running Gradle task 'assembleDebug'...
(This is taking an unexpectedly long time.)
It never initialize Gradle nor the dependencies
Here is solution in my case.
Open your flutter Project directory.
Change directory to android directory in your flutter project directory cd android
clean gradle ./gradlew clean
Build gradle ./gradlew build or you can combine both commands with just ./gradlew clean build
Now run your flutter project. If you use vscode, press F5. First time gradle running assembleDebug will take time.
PS: Delete gradle in case of all that steps don't work
flutter run -v showed that I was stuck on
Downloading https://services.gradle.org/distributions/gradle-5.6.2-all.zip
This was going to take hours, as for some reason the download speed was ~10kB/s on a decent DSL connection.
Solution:
Interrupt gradle build
Download the required gradle zip from a fast mirror. e.g. https://distfiles.macports.org/gradle/gradle-5.6.2-all.zip
Copy gradle-5.6.2-all.zip to C:\Users\ <MyUsername>\.gradle\wrapper\dists\gradle-5.6.2-all\9st6wgf78h16so49nn74lgtbb (of course the last folder will have a different name on your PC)
flutter run and voilà.
In my case, Windows Firewall was causing this problem. After I disabled it temporarily the problem was gone. Worth giving it a try. Good luck!
If you are on Windows:
try adding firewall exceptions to your Android Studio.
Go to:
Control Panel\System and Security\Windows Defender Firewall\Allowed apps
Hit the button:
Allow another app
Add your new firewall exceptions:
studio.exe and studio64.exe
I hope this can be useful for you too.
If Running Gradle task assembledebug is taking unexpectedly long time,
try updating Gradle in your project. (Downloading latest zip file)
You can follow steps in this answer.
Or try by:
Open a project in Android Studio
Right-click on android in Projects Panel
Go down to Flutter and click on the 'Open Android module in Android Studio'.
(See screenshot for reference)
This should open the project as an Android Project.
Now, click on 'gradle' in the right panel.
Next, click on 'Execute Gradle Task' icon
This should open a 'Run Anything' window.
Now, Run the command gradlew clean
and, then run gradlew build
If prompted by Android Studio to 'Update Gradle Plugin', do that.
The update would download the required .zip files.
And, your apps should work fine after that.
I am using VS Code on Ubuntu 18.04
For me it was a background download of the appropriate android sdk build tools for my connected device. Running flutter run -v showed that it was downloading android SDK build tools which usually take some time. Once it was done, the flutter app compiled and ran successfully.
Solution
Ensure you have installed android sdk tools and added them to the environment path.
I assume you have downloaded android sdk tools.
Ensure you have installed gradle and added it to the path
Ensure you have installed latest dart and flutter sdks
For no 1 and 2 please refer to this post:
Setting up flutter without Android studio
For me what worked was clean wipe the emulator data by AVD Manager
There were two reasons for me on Archlinux:
I needed to unset TERM which was set to xterm-256color (reference).
For some reason, flutter stable was not working for me; so I switched to master with: flutter channel master && flutter upgrade. I'll be able to switch back to flutter stable when the fix in master makes its way into stable (reference).
This worked for me.I got an issue with license acceptance.
First you need to go through the flutter directory and then run the command
C:\Users\thrishool\flutterProjects\flutter>flutter doctor
Then it will display if everything is fine or not.I got an issue that, I didnot accept all the licenses.So you need to accept them all.Now type this in cmd
C:\Users\thrishool\flutterProjects\flutter>flutter doctor --android-licenses
Accept all the licenses and you are good to go.
For me simply the process took too much time. It kept running for about 10 mins and finally the app started running.
This problem occurred on my system because of the Zen Kernel.
I installed the Linux-LTS kernel and started system using this.
Then my project backed to compile again.
I used the command "flutter clean" in my project and it returned to work perfectly, please try.
Igual a imagem
flutter clean
This is likely one of number of issues and some of the recommended troubleshooting can be found here.
Check that you are building against an Android sdk that you have
installed... in your build.gradle file check the compileSdkVersion.
You can try uninstalling and reinstalling the relevant SDK.
Some users have reported that they had to resintall Dart.
Without a little more information basic troubleshooting is the best we can offer sorry.
Good luck.
For creating an apk for Android in Flutter this issue sometimes happens. I had the luck of facing this issue as well. Here are the few ways it can be solved:
1. Due to androidX
If you followed recommended route from here:
https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
Try this:
Check with steps in “not recommended” way in above tutorial if every listed files is same as in your project, especially :
in root/android/gradle/wrapper/gradle-wrapper.properties set distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
in root/android/build.gradle, set
dependencies { classpath 'com.android.tools.build:gradle:3.3.2' }
check if root/android/app/build.gradle SDK version is set to minimum 28 for:
compileSdkVersion 28 and targetSdkVersion 28
Thank you.
In Android Studio:
Tools -> Flutter -> Flutter clean.
After that just run the app
I stumbled on this problem when I was running my app without debugging it. Theres two option
Start Debugging
Run without Debugging
I was doing the second option the whole time which got me stuck in that running graddle loop. I fixed my problem with the first option.
Had the same issue because of the wrong compileSdkVersion in the build.gradle file.
Working fine now.
In my case I forgot to download Google Web Driver.
It’s running once I downloaded Google Web Driver.
It is taking time on windows 10 as the Android studio needs firewall permission to connect to the device(AVD).
There can be another reason that you don't have downloaded full Android SDK on your machine.
To check the issue simply run the command on your terminal/cmd/PowerShell command tool.
flutter doctorflutter doctor
check if SDK is installed or not.
Try to install and accept license using the following command
flutter doctor --android-licenses
If this doesn't resolve your problem then go to android studio and Open your Android Studio,
File-> settings->System settings(left tab) ->Android SDK
,
go to
SDK Tool section
in that page,
untick hide obsolete packages,
select Android SDL tools(obsolete)
and press apply also install other useful tools according to your convenience.
This helped: check if root/android/app/build.gradle SDK version is set to minimum 28 for:
compileSdkVersion 28 and targetSdkVersion 28
Occurs with import of Firestore.
In my case the Android Gradle Plugin Version was not updated to any version at all. So i updated it by right clicking on my project folder, clicked "Open Module Settings" and updated gradle plugin version accordingly.
In my case, I need to update Android SDK built-tools.
Open in Android studio Tools->SDK Manager-SDK tools.
Mark Android SDK Built-Tools, press Apply, wait for the update.
After updated, press Apply and try to run.
I fixed the issue by switching off my antivirus while running my project in the terminal
To run your project in a terminal simply type --> flutter run
This worked for me:
C:\Users<user>\AndroidStudioProjects<flutter_app>\android> gradlew clean
C:\Users<user>\AndroidStudioProjects<flutter_app>\android> gradlew build
Now run it, for initial build
“Running Gradle task 'assembleDebug'… ”
will take 10-12 mins after that it will be good to go.
Download the required gradle zip from a fast mirror: https://distfiles.macports.org/gradle/gradle-5.6.2-all.zip
Copy gradle-5.6.2-all.zip to C:\Users
.gradle\wrapper\dists\gradle-5.6.2-all\9st6wgf78h16so49nn74lgtbb
If this does not work, go to android studio's terminal then run:- flutter run.
See what SDK platform it's asking you. like SDK API 28, 29, or 30.
Then goto SDK manager and install the required SDK API. Then restart android studio.
It will work perfectly fine!!
The same problem occurred on my mac in Android Studio 4.1, unfortunately, I forgot to install Java on my machine, try installing Java.
nothing was working for me
I do update the flutter SDK & update all the dependencies to the latest version. after that, I open the android module as a project in android studio. It downloads some files. after completion, I do clean the project using Build->clean Project & update the Gradle version.
After that, I again open the flutter project and run the app. It's working now.... :)
This might also be due to developers permission, if you will be using any package which requires devices permission lets say url_launcher and you haven't given permission for that it wont run. Solution for windows is that just run ms-settings:developers this in your command prompt/ powershell and enable for developers option and then it will work fine.
and if that doesnt also works then just run flutter clean and flutter create . it will work.
How are you !,
After many attempts, nothing they recommended worked for me.
My problem was that I had * .dart files with many lines of code to perform SQL create and insert operations initially in SQLite, I removed those 4072 lines of operations, the file was reduced in size and I no longer had to compile a very code file long, instead, I preloaded the database into assets, and it worked flawlessly! ..
The message that the operation is taking a long time no longer appears, I hope it serves you.
Before, when long file size
After, without SQL code operations
I solved the issue by reinstalling SDK Platform on Android studio for Android API 29
Tools->SDK Manager-SDK Platform
Next go to
Android > app > build.gradle
Make sure you also change
compileSdkVersion 29
targetSdkVersion 29
Be patient, it take longer for the first launch...But, not take forever like before.
good luck
I am trying to implement Bamboo into creating an IPA file or APK file using Xbuild but I am getting 1 warning and 1 error:
The warning is the following:
/usr/local/Cellar/mono/4.6.2.7/lib/mono/xbuild/14.0/bin/Microsoft.Common.targets: warning : Unable to find framework corresponding to the target framework moniker '.NETPortable,Version=v4.5,Profile=Profile78'. Framework assembly references will be resolved from the GAC, which might not be the intended behavior.
The error is this:
/usr/local/Cellar/mono/4.6.2.7/lib/mono/xbuild/14.0/bin/Microsoft.Common.targets: error : PCL Reference Assemblies not installed.
I am unsure why this is happening because when I open the project in Xamarin studio and build it, it will be successful, and when I run it the app is fully functional with no problems at all. I have located the file location of the profile 78 in the version 4.5 and it exists, I have the latest installed version of Mono Development Kit (MDK). How can it build correctly in Xamarin but not in Bamboo, is it do with how I locate the files?
I have also tried to create the APK file on the terminal but got the same error as well. I have tried a lot of fixes like uninstalling mono and reinstalling, I added .NETPortable from windows to Mac but that didn't work, why can't my mac find the profile 78 it is located on my mac.
The file /usr/local/Cellar/mono/4.6.2.7/lib/mono/xbuild/14.0/bin/microsoft.common.targets seems to be looking for the .NetPortable,Version=v4.5,Profile=78 but I have that in this location: Library/Frameworks/Mono.framework/Versions/4.6.2/lib/mono/xbuild.frameworks/.NetPortable/v4.5/Profile/Profile78 and I have pasted the .NetPortable folder in multiple locations to try and fix this error. Where am I going wrong?
Although I have not touched Bamboo for quite some time(3+ years), one thing I personally do is to ensure your xbuild command works like a charm in a local environment with a similar setup. Seeing that you tried to create an .apk through the terminal and got the same error sounds like an installation error. The PCL Reference Assemblies should be apart of the MDK on MacOS. Seeing that you have it installed, it sounds like a potential issue with file permissions of the Bamboo user account.
To create an .apk file, you need to use the /t:PackageForAndroid target against your Android project when invoking xbuild.
EX:
xbuild XamarinAndroidApplication.csproj /p:Configuration=Release /t:PackageForAndroid
You can also use the SignAndroidPackage target given the notes here:
https://developer.xamarin.com/guides/android/under_the_hood/build_process/#Build_Targets
xbuild XamarinAndroidApplication.csproj /p:Configuration=Release /t:SignAndroidPackage
If you wanted to use the MSBuild equivalents, it would look like this:
msbuild MyAndroidApp.sln
msbuild /t:SignAndroidPackage MyAndroidApp.csproj
Im building the Phonegap App using Phonegap Build.
Phonegap Build cant create Android APK, build is failing with below error, Morning I was able to create the APK but now below error is thrown. Note that there is no config file changes between morning and now.
Please help
App Id: 2074580
https://build.phonegap.com/apps/2074580/builds
Could not resolve all dependencies for configuration ':_debugCompile'.
Could not find com.android.support:support-v4:23.4.0.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/support/support-v4/23.4.0/support-v4-23.4.0.pom
https://repo1.maven.org/maven2/com/android/support/support-v4/23.4.0/support-v4-23.4.0.jar
file:/android-sdk/extras/android/m2repository/com/android/support/support-v4/23.4.0/suppo rt-v4-23.4.0.pom
file:/android-sdk/extras/android/m2repository/com/android/support/support-v4/23.4.0/suppo rt-v4-23.4.0.jar
file:/android-sdk/extras/google/m2repository/com/android/support/support-v4/23.4.0/suppor t-v4-23.4.0.pom
file:/android-sdk/extras/google/m2repository/com/android/support/support-v4/23.4.0/suppor t-v4-23.4.0.jar
Required by:
:project:unspecified
I had a similar problem with this plugin. I needed to update some android libraries. This command solved it all for me:
android update sdk --no-ui --all --filter "extra-android-m2repository"
If you don't have the android command in your command line, you can navigate to the SDK directory.
Answered here; https://github.com/phonegap/phonegap-plugin-push/issues/928. You need to switch back to Cordova version 1.6.3 or 1.6.4. But I just checked and upgrading to the latest nightly build also seems to fix it. When working in Visual Studio, clear the cordova cache too (after setting the correct version):
Tools => Options => Tools for Apache Cordova => Clear Cordova Cache.
Until now, all of my experience compiling PhoneGap apps has been via the excellent PhoneGap:Build service. However, I now find myself in a situation where I need to compile locally, because I need to use a plugin that includes a binary file, which precludes it from being included for use with PG:B.
So for these reasons, I need to compile locally. "Great!" I thought, I'll just use the new CLI...
I have developed my app, and I can test it on-device via deploy over USB from Xcode, but trying to get a release build, and sign it, with the provisioning profile embedded, has been a nightmare.
For completeness, this is the basic outline of everything I've done, aside from the app development itself.
$ pwd
/users/adam/dev/myapp/mobile/
$ cordova create build_local com.foo.bar MyApp
Creating a new cordova project with name "MyApp" and id "com.foo.bar" at location "/Users/adam/DEV/myapp/build_local"
$ cd build_local
$ cordova platform add ios
Creating ios project...
$ cordova platform add android
Creating android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.foo.bar
Name: MyApp
Android target: android-19
Copying template files...
<snip>
Project successfully created.
$ cordova plugin add https://github.com/hazemhagrass/BackgroundJS
Fetching plugin "https://github.com/hazemhagrass/BackgroundJS" via git clone
Installing com.badrit.BackgroundJS (android)
Fetching plugin "https://github.com/apache/cordova-plugin-device.git" via git clone
Installing org.apache.cordova.device (android)
Installing com.badrit.BackgroundJS (ios)
Installing org.apache.cordova.device (ios)
$ cordova plugin add de.appplant.cordova.plugin.local-notification
Fetching plugin "de.appplant.cordova.plugin.local-notification" via plugin registry
Installing de.appplant.cordova.plugin.local-notification (android)
Installing de.appplant.cordova.plugin.local-notification (ios)
$ cordova plugin add https://github.com/kdzwinel/phonegap-estimotebeacons
Fetching plugin "https://github.com/kdzwinel/phonegap-estimotebeacons" via git clone
Installing pl.makingwaves.estimotebeacons (android)
Installing pl.makingwaves.estimotebeacons (ios)
For what it's worth, this last plugin is the reason that I have to compile locally.
Now, here's one other potential monkey wrench: This app is actually two apps. It's the same core codebase, merged into two different deployment branches of the repo, one for each client. So each app will have its own id, name, and config stuff. Because of this, I actually have more than one cordova project folder (1 for each final app) and after creating each project through the steps above, I remove the generated www folder and replace it with a symlink to the shared www folder that exists outside of these phonegap project directories.
This is supported behavior; the CLI allows you to generate your app with a symlink via the --link-to flag (see cordova help create for details). However, doing so seems to have issues; so I've resorted to doing all of the app config up front and then replacing the generated www folder with a symlink after everything is ready to compile.
At this point, I can deploy to either the iOS simulator or Android emulator, and I can deploy to devices over USB, and everything works just fine; all of my plugins are available and function as expected. So I'm ready to compile a release build. Android is easy. iOS, not so much.
$ cordova build ios
<snip>
** BUILD SUCCEEDED **
However, this is a DEV build. The generated file is in the build/emulator/ folder, and when I attempt to sign it, I'm told that it's not signed because of the I386 architecture (which indicates that it's a development build).
$ xcrun -sdk iphoneos PackageApplication -v "platforms/ios/build/emulator/MyApp.app" -o "/users/adam/dev/myapp/MyApp.ipa" --sign "iPhone Distribution: {our cert name} ({our cert id})"
<snip>
Codesign check fails : platforms/ios/build/emulator/MyApp.app: code object is not signed at all
In architecture: i386
<snip>
I've attempted to generate a release build from the cordova CLI. I haven't been able to find the --release flag documented anywhere, but the CLI doesn't complain, and it usually does if it doesn't recognize a flag.
$ cordova build ios --release
<same result as previously>
Attempting to sign this build results in the same problem.
At this point, I started attempting to work directly in Xcode. I've set the .mobileprovision file and the signing credentials up appropriately, to the best of my knowledge:
With these values set, Xcode no longer allows me to build:
So I'm stuck: I have no choice but to build locally, and I can't figure out how to get it to build for release and sign! Please help!
Additionally, if I attempt to embed a provisioning profile, that fails because of an issue with entitlements. I'm not exactly sure what this means, but I'm hopeful that it's a result of working with a dev build, and resolving that will resolve this as well.
$ test -e ~/.ios/DEV.mobileprovision && echo exists
exists
$ xcrun -sdk iphoneos PackageApplication -v "platforms/ios/build/emulator/MyApp.app" -o "/users/adam/dev/myapp/MyApp.ipa" --embed "~/.ios/DEV.mobileprovision"
<snip>
error: Failed to read entitlements from '/var/folders/zs/j2hmt69n12sbjm6gyn0m_q4c0000gn/T/tyYvYPQKf3/Payload/MyApp.app'
Update 1:
This SO question helped in one regard. I don't know how the active scheme (I'm not really sure what that means, but that's the tooltip when I hover over the control) got changed as part of specifying keys/etc, but clearly it did. Changing this back to an iOS Device, like iPhone, allows me to build my project, and even Archive (which, to the best of my understanding, means it's creating the .ipa file I need to submit to the app store), but I can't find the archived file. Where should it be? Can I define this in a setting somewhere in Xcode?
Update 2:
By fiddling with certificates and provisioning profiles I've finally been able to create an archive from Xcode, which I've been told is a release build (is it?). Ideally I would like to be able to build from the command line so that I can automate it as much as possible, so that's where I'll be picking up in the morning. Any advice on that front would be quite welcome!
If you managed to create an archive in Xcode, then your signing certificate and provisioning profiles are known to Xcode, so cordova build ios --release --device should make it.
The steps are:
1) Import your iOS developer certificate for production to the keychain by downloading and double clicking on it in Finder (or get it via Xcode)
2) Download your provisioning profile (with the App ID set to the id attribute of the widget element in config.xml) and double click it on Finder so it goes to the Xcode provisioning profile store
3) cordova build ios --release --device
it looks like you're trying to sign the app with a wildcard provisioning profile (the XCode screenshot). Can you try creating and downloading a distribution certificate and provprofile to your Mac? Then import the .cer file in the keychain access app (doubleclicking should suffice) and doubleclick the provprofile as well.
Now you should be able to select the appropriate values from the release dropdowns in the XCode build settings.
Hope this helps somewhat...
Eddy
One other issue I am seeing from your screenshot is I don't think you can Build an Archive (Release) version using the Developer Signing Idenetity, you would need to create a Distribution certificate and use that one for the Release (Archive) version.
Can anyone tell me why I'm getting this error with AndroidStudio?
Execution failed for task ':sampleapp:preBuild'.
> Build Tools Revision 19.0.0+ is required.
I have installed Android Build-tools 19.0.1 from the Android SDK manager
Check all your build.gradle files whether they are using the 19.0.x version or not.
buildToolsVersion will be defined under the android tag inside the build.gradle file, like this:
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
// Other Configuration
}
You can find a list of versions for the Android Build Tools here as well as in the SDK Manager.
Go to Window->Android SDK Manager and run it
You will see Android Build-Tools version installed...
Change build.gradle to reflect the installed version of build tools
This worked for me
OR
Install the version which is shown in error
This seemed to work for me. I had to update the Default settings then restart the IDE:
File->Other Settings->Default Project Structure
Under Project Settings: Project, set Project SDK as Android SDK.
Click Edit button
For Android SDK, set Build target to Android 4.4.2
Click Ok.
Restart IDE
Then rebuild. Seemed to work after that..
This is assuming you've already installed Android-19 and still having difficulties.
If you have installed the required version of the build tools and it does not work:
Eclipse and the Android Studio likely use two different copies of the SDK, and you have updated the other copy.
Edit your project level build.gradle file and set gradle version to the latest version now it is 3.2.1
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
It's helpful to remember that you will have build.gradle files for each module in your Android Studio Project.
I kept hitting my head against the wall - "Where the heck is that line everyone's telling me to change?!" - until I looked in the ~/dev/AndroidProjects/xxprojectnamexx/app folder and looked at the build.gradle file there.