Error while building an android app using flutter and vscode - android

I am trying to build an android app with flutter and vscode but I am continuously getting an error.
Launching lib\main.dart on Micromax Q427 in debug mode...
Error running Gradle: Exit code 1 from:
E:\Flutter\mytestapp\android\gradlew.bat app:properties: Starting a
Gradle Daemon, 2 busy Daemons could not be reused, use --status for
details Download
https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.0.1/builder-3.0.1.jar
Download
https://repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar
Download
https://dl.google.com/dl/android/maven2/com/android/tools/external/com-intellij/intellij-core/26.0.1/intellij-core-26.0.1.jar
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project
'android'.
Could not resolve all files for configuration ':classpath'. Could not
download builder.jar (com.android.tools.build:builder:3.0.1)
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.0.1/builder-3.0.1.jar'.
Premature end of Content-Length delimited message body (expected: 26945712; received: 8650688 Could not download intellij-core.jar
(com.android.tools.external.com-intellij:intellij-core:26.0.1) Could
not get resource
'https://dl.google.com/dl/android/maven2/com/android/tools/external/com-intellij/intellij-core/26.0.1/intellij-core-26.0.1.jar'.
Premature end of Content-Length delimited message body (expected: 8234273; received: 6553552
Try: Run with --stacktrace option to get the stack trace. Run with
--info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 14m 39s Please review your Gradle project setup in the
android/ folder. Exited (sigterm)
I have tried many solutions but nothing worked also flutter doctor shows no issue and I am not able to understand why I am getting this error while building my app.
I have also asked this query in github but got no reply so far here is the link: https://github.com/flutter/flutter/issues/19614

Related

Issue on building flutter apk with flutter_tts dependency

I was building a flutter app in a Windows machine and I stopped working on it for several months, after that I now get issues on running the app. It shows those two errors:
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
Where:
Build file 'C:\Users\okeyr\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_tts-3.6.3\android\build.gradle' line: 31
What went wrong:
A problem occurred evaluating project ':flutter_tts'.
org/gradle/api/services/BuildService
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.
==============================================================================
2: Task failed with an exception.
Where:
Script 'C:\Program Files\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 463
What went wrong:
A problem occurred configuring project ':flutter_tts'.
Failed to notify project evaluation listener.
Cannot invoke method substring() on null object
compileSdkVersion is not specified.
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
Flutter doctor shows everything fine except:
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
But I don't think the issue is related with that.
I've I look in depth at failure number 1. I have check the file that gives the error and I found that in line 31:
apply plugin: 'kotlin-android'
So I just went to the file and deleted all the entries related with kotlin, because I am not using Kotlin (I guess).
Then if I rerun the app it now shows another error (related with tts again), but doesn't show the previous ones (not sure if I've moved forward or backwards)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\Users\okeyr\AndroidStudioProjects\fluttertestapp\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java:24: error: cannot find symbol
flutterEngine.getPlugins().add(new com.tundralabs.fluttertts.FlutterTtsPlugin());
^
symbol: class FlutterTtsPlugin
location: package com.tundralabs.fluttertts
1 error
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app: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 16s
Exception: Gradle task assembleDebug failed with exit code 1
After doing a search I found many people with that similar issue (even though none was related to tts plugin) which had adressed it with a flutter pub cache repair or a flutter clean. However, a flutter clean gives me no changes and error persists and when I have executed flutter pub cache repair it had shown:
Failed to repair flutter_tts 3.6.3. Error:
Pub failed to delete entry because it was in use by another process.
This may be caused by a virus scanner or having a file
in the directory open in another application.
Reinstalled 29 packages.
Failed to reinstall 1 package:
flutter_tts 3.6.3
pub finished with exit code 69
Now, if I rerun the code it gives me new error:
The plugin flutter_tts doesn't have a main class defined in C:\Users\okeyr\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_tts-3.6.3\android\src\main\java\com\tundralabs\fluttertts\FlutterTtsPlugin.java or C:\Users\okeyr\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_tts-3.6.3\android\src\main\kotlin\com\tundralabs\fluttertts\FlutterTtsPlugin.kt. This is likely to due to an incorrect androidPackage: com.tundralabs.fluttertts or mainClass entry in the plugin's pubspec.yaml.
If you are the author of this plugin, fix the androidPackage entry or move the main class to any of locations used above. Otherwise, please contact the author of this plugin and consider using a different plugin in the meanwhile.
This error also appears when running pub get or pug upgrade. But if I run pub outdated it gives me that:
Showing outdated packages.
[*] indicates versions that are not the latest available.
Package Name Current Upgradable Resolvable Latest
direct dependencies: all up-to-date.
transitive dependencies:
characters *1.2.1 *1.2.1 *1.2.1 1.3.0
collection *1.17.0 *1.17.0 *1.17.0 1.17.1
js *0.6.5 *0.6.5 *0.6.5 0.6.7
meta *1.8.0 *1.8.0 *1.8.0 1.9.0
path *1.8.2 *1.8.2 *1.8.2 1.8.3
transitive dev_dependencies:
matcher *0.12.13 *0.12.13 *0.12.13 0.12.14
test_api *0.4.16 *0.4.16 *0.4.16 0.4.18
all dependencies are up-to-date.
Process finished with exit code 0
I can't see any dependency related with tts.
Now here I am stucked in that error, I don't know how to proceed. If there is someone who could help me see the light I'd be grateful. Thanks in advance.
I am trying to run the code but it seems tts package is not well defined, anyone that could bring me some help?

A problem occurred configuring root project 'android'. Unexpected lock protocol found in lock file. Expected 3, found 0

I recently changed my flutter project folder into a new one which will be used for production but after recopying everything back into the the new one i keep gettting this error
Launching lib\main.dart on Samsung Galaxy S10 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not create service of type OutputFilesRepository using ExecutionGradleServices.createOutputFilesRepository().
> Unexpected lock protocol found in lock file. Expected 3, found 0.
* 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 24s
Exception: Gradle task assembleDebug failed with exit code 1
I have followed other way to to resolve eg like what someone said here in stack-overflow. i have also deleted the gradle from cache restarted my app still showing this error
Some of the build.gradle files can be found here github. Please how do i fix this, Thanks. Also if you need more explanation or code tell me
A useful answer from this post Error:Unexpected lock protocol found in lock file. Expected 3, found 0
cd path/to/.gradle/
find . -name "*.lock" -delete

This App Bundle contains native code, and you've not uploaded debug symbols

This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug
FAILURE: Build failed with an exception.
Where:
Build file 'H:\Flutter_Projects\xylophone_app\android\app\build.gradle' line: 1
What went wrong:
A problem occurred evaluating project ':app'.
Could not get unknown property 'android' for project ':app' of type org.gradle.api.Project.
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
As a requirement in uploading debug symbol files, version of the Android Gradle plugin is 4.1 or higher as mentioned in this SO post:
Before you can upload debug symbols files, you must be using Android
Gradle plugin version 4.1 or higher.
Looks like it will come only with Android Studio 4.1, because I can
only get Gradle 4.0.0 automatically now.
So I suggest you to return classic Play console and it will let you
through :)
And for the Flutter side, there is actually an open GitHub ticket that's being monitored by the Flutter team.

Running gradle task failed after very long time

I tried to run my first flutter project but i keep getting this error.
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
Could not resolve all artifacts for configuration ':classpath'.
Could not download gradle.jar (com.android.tools.build:gradle:3.5.0)
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.jar'.
Premature end of Content-Length delimited message body (expected: 4170314; received: 2359280
Could not download bundletool.jar (com.android.tools.build:bundletool:0.9.0)
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/0.9.0/bundletool-0.9.0.jar'.
Premature end of Content-Length delimited message body (expected: 5248142; received: 4456416
Could not download protos.jar (com.android.tools.analytics-library:protos:26.5.0)
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/protos/26.5.0/protos-26.5.0.jar'.
Premature end of Content-Length delimited message body (expected: 3432065; received: 2359280
Could not download kotlin-stdlib-common.jar (org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50)
Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.50/kotlin-stdlib-common-1.3.50.jar'.
Read timed out
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 20m 5s
Exception: Gradle task assembleDebug failed with exit code 1
[Screenshot1
I used free vpn proxy like hotspot shield.. For some reason i guess in your area those links are blocked unfortunately and unexpectedly.. like in my area.. so please use any free vpn and update your packages again..
If that problem still occurs then I think you are trying to create an android project in a flutter project.
Usually android studio shows a pop up box for that. Which you should not click okay..
if this is not the problem can you please clarify bit more? shuch from where you have get the project and what have you done before it was doing all the updates?

NativeScript on windows: Vanilla build of sample project failed

I am starting with hello world example to learn nativescript.
I am compiling and building code behind corporate explicit proxy. I am able to create project and add android platform in my project. but when i try to build the project I face below error.
D:\CurrentProjects\Android\NativeScript\simple>tns run android
Executing before-prepare hook from D:\CurrentProjects\Android\NativeScript\simpl
e\hooks\before-prepare\nativescript-dev-android-snapshot.js
Preparing project...
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'simple'.
Could not resolve all dependencies for configuration ':classpath'.
Could not download gradle-core.jar (com.android.tools.build:gradle-core:2.1
.2)
Could not get resource 'https://jcenter.bintray.com/com/android/tools/bu
ild/gradle-core/2.1.2/gradle-core-2.1.2.jar'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gr
adle-core/2.1.2/gradle-core-2.1.2.jar'.
This is usually a temporary error during hostname resolution and m
eans that the local server did not receive a response from an authoritative serv
er (jcenter.bintray.com)
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 21.159 secs
Processing node_modules failed. Error: Command D:\CurrentProjects\Android\Native
Script\simple\platforms\android\gradlew.bat failed with exit code 1
Gradle is accessible from browser. But "tns build android" or "tns run android" couldn't download and give above proxy error. This seems gradle error but don't have answer in gradle as well.
UPDATE: when network guy removed proxy authentication check at his end, gradle compiled. I guess issue is gradle is not taking up proxy settings as mentioned in other answers on stackoverflow.

Categories

Resources