I am trying to run my first sample flutter app in Intelij IDE, but I get an error which I am unable to resolve.
What I did was, File > New > Project, then I chose flutter, and gave the app name, and clicked Ok.
Next when the interface loaded, I connected my phone and then I saw it displayed in the top right corner, and beside it I selected main.dart and pressed the green play button, but int the console I got an error.
Initializing gradle...
Resolving dependencies...
Launching lib/main.dart on CP8676 I02 in profile mode...
Gradle task 'assembleProfile'...
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
> Could not resolve com.android.tools.build:aapt2:3.2.1-4818971.
Required by:
project :app
> Could not resolve com.android.tools.build:aapt2:3.2.1-4818971.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom'.
> dl.google.com: Name or service not known
> Could not resolve com.android.tools.build:aapt2:3.2.1-4818971.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom'.
> jcenter.bintray.com: Name or service not known
* 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 30s
Finished with error: Gradle task assembleProfile failed with exit code
My build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is my build.gradle file.I see that when I hover over the buildscript, intellij says, cannot resolve symbol 'buildscript', the same occours for other definitions such as repositories in this file.
Related
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':background_fetch:verifyReleaseResources'.
A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
Android resource linking failed
ERROR:/Users/musamaashraf/dev/projects/BuddyPark/build/background_fetch/intermediates/merged_res/release/values/values.xml:2520: AAPT: error: resource android:attr/lStar 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 1m 41s
Running Gradle task 'assembleRelease'... 102.3s
Gradle task assembleRelease failed with exit code 1
This error appeared when I added the background_fetch: ^1.1.1. Appears to be an issue with the gradle I upgraded from 7.1.0 to 7.2.0 and then to 7.3.0.
Also added the other fixes that I could find.
android/build.gradle file:
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.13'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
maven {
// [required] background_fetch
url "${project(':background_fetch').projectDir}/libs"
}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle.properties file:
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true
android.jetifier.ignorelist=bcprov-jdk15on
Tried the fixes in this guide: Flutter, background fetch package not working, androidx incompatibility
I have picked up an old flutter application from another developer and I am having difficulty getting it to build. When I try 'flutter run' I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:processDevDebugResources'.
> Could not resolve all task dependencies for configuration ':app:devDebugRuntimeClasspath'.
> Could not resolve androidx.window:window:[1.0.0-beta04].
Required by:
project :app > project :in_app_purchase > io.flutter:flutter_embedding_debug:1.0.0-57d3bac3dd5cb5b0e464ab70e7bc8a0d8cf083ab > androidx.window:window-java:1.0.0-beta04
> Failed to list versions for androidx.window:window.
> Unable to load Maven meta-data from https://google.bintray.com/exoplayer/androidx/window/window/maven-metadata.xml.
> Could not get resource 'https://google.bintray.com/exoplayer/androidx/window/window/maven-metadata.xml'.
> Could not GET 'https://google.bintray.com/exoplayer/androidx/window/window/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
* 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 6m 38s
Has anyone come across this before? Do you know what causes it and/or how to rectify the issue?
I am very new to flutter, so please let me know what further information is requried to diagnose this issue.
FYI, I have removed jcenter() from repositories, but it doesn't seem to help. Here is build.gradle:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
// mp035 removed
// jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.6.1'
}
}
allprojects {
repositories {
google()
mavenCentral()
/// mp035 removed
//jcenter()
}
}
ext.flutterFFmpegPackage = 'full'
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Ok, so after a lot of research, it turns out that flutter packages themselves can have a build.gradle, and one of those packages (in_app_purchase in this case) had a reference to jcenter (google.bintray.com) in it.
The solution was to upgrade to a later version of the plugin. Note however, that this started a snowball effect requiring me to upgrade most of the plugins in the project and go through the code and fix up the project to work with all of the API changes that were introduced in the newer plugins.
When I run flutter run --no-sound-null safety
This shows the output. I have tried all the solutions available. But not working.
Here is the 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 resolve com.android.tools.build:gradle:4.1.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:4.1.0.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom'.
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
* 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 37s
My android/build.gradle file
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My android/gradle/wrapper/gradle-wrapper.properties file content are:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
I don't know how to fix this please help!. I am trying it since 1 day. All worked fine but suddenly this error came!. Thanks in advance.
Check whether you have your internet on.
Secondly, upgrade ext.kotlin_version in andriod build. gradle to 1.5.31 or higher and try to run the app again
I am trying to run a default flutter app but when I run it gives the below error:
Running Gradle task 'assembleDebug'...
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 resolve com.android.tools.build:gradle:3.5.3.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.5.3.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Connect to 172.30.0.15:3128 [/172.30.0.15] failed: Connection timed out: connect
> Could not resolve com.android.tools.build:gradle:3.5.3.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Connect to 172.30.0.15:3128 [/172.30.0.15] failed: Connection timed out: connect
> Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50.
Required by:
project :
> Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50.
> Could not get resource 'https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.50/kotlin-gradle-plugin-1.3.50.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.50/kotlin-gradle-plugin-1.3.50.pom'.
> Connect to 172.30.0.15:3128 [/172.30.0.15] failed: Connection timed out: connect
> Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50.
> Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.50/kotlin-gradle-plugin-1.3.50.pom'.
> Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.50/kotlin-gradle-plugin-1.3.50.pom'.
> Connect to 172.30.0.15:3128 [/172.30.0.15] failed: Connection timed out: connect
* 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 25s
Exception: Gradle task assembleDebug failed with exit code 1
below is the build.gradle code:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The whole code of the app is default one, no changes have been done I have just connected an emulator and tried to run if it works and am stuuck at this assembleDebug error.
If anyone has any idea where Im going wrong please do comment...
One of the important CLI command in Flutter is flutter doctor. This command will check the current status of the flutter information. If some software is missing or not working then it will show a warning.
Check the documentation for an example (this is for Windows OS setup).
See also macOS setup, Linux and Chrome OS.
I've just created a new project in Android Studio for Flutter.
Now I get this strange error:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle... Resolving dependencies...
* Error running Gradle: Exit code 1 from: C:\Users\bruker\AndroidStudioProjects\flutter_app\android\gradlew.bat
app:properties: Project evaluation failed including an error in
afterEvaluate {}. Run with --stacktrace for details of the
afterEvaluate {} error.
FAILURE: Build failed with an exception.
Where: Build file 'C:\Users\bruker\AndroidStudioProjects\flutter_app\android\app\build.gradle'
line: 25
What went wrong: A problem occurred evaluating project ':app'.
Could not resolve all files for configuration 'classpath'.
Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
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
Finished with error: Please review your Gradle project setup in the
android/ folder.
I read that you should add some maven dependency, but I am not using maven at all. This is my build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I dont use maven for my project.
.packages file:
# Generated by pub on 2018-11-04 18:57:06.695056.
analyzer:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.32.4/lib/
args:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-1.5.0/lib/
async:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-2.0.8/lib/
boolean_selector:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib/
charcode:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/
collection:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/collection-1.14.11/lib/
convert:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/convert-2.0.2/lib/
crypto:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/crypto-2.0.6/lib/
csslib:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/csslib-0.14.5/lib/
cupertino_icons:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cupertino_icons-0.1.2/lib/
flutter:file:///C:/Users/bruker/flutter/packages/flutter/lib/
flutter_test:file:///C:/Users/bruker/flutter/packages/flutter_test/lib/
front_end:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/front_end-0.1.4/lib/
glob:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/glob-1.1.7/lib/
html:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/html-0.13.3+3/lib/
http:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http-0.11.3+17/lib/
http_multi_server:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_multi_server-2.0.5/lib/
http_parser:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_parser-3.1.3/lib/
io:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/io-0.3.3/lib/
js:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/js-0.6.1+1/lib/
json_rpc_2:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/json_rpc_2-2.0.9/lib/
kernel:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/kernel-0.3.4/lib/
logging:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/logging-0.11.3+2/lib/
matcher:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/matcher-0.12.3+1/lib/
meta:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/meta-1.1.6/lib/
mime:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mime-0.9.6+2/lib/
multi_server_socket:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/multi_server_socket-1.0.2/lib/
node_preamble:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/node_preamble-1.4.4/lib/
package_config:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/package_config-1.0.5/lib/
package_resolver:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/package_resolver-1.0.4/lib/
path:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path-1.6.2/lib/
plugin:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/plugin-0.2.0+3/lib/
pool:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pool-1.3.6/lib/
pub_semver:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pub_semver-1.4.2/lib/
quiver:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/quiver-2.0.0+1/lib/
shelf:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf-0.7.3+3/lib/
shelf_packages_handler:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_packages_handler-1.0.4/lib/
shelf_static:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_static-0.2.8/lib/
shelf_web_socket:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.2+4/lib/
sky_engine:file:///C:/Users/bruker/flutter/bin/cache/pkg/sky_engine/lib/
source_map_stack_trace:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_map_stack_trace-1.1.5/lib/
source_maps:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_maps-0.10.7/lib/
source_span:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_span-1.4.1/lib/
stack_trace:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib/
stream_channel:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stream_channel-1.6.8/lib/
string_scanner:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib/
term_glyph:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/term_glyph-1.0.1/lib/
test:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test-1.3.0/lib/
typed_data:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/
utf:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/utf-0.9.0+5/lib/
vector_math:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/
vm_service_client:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vm_service_client-0.2.6/lib/
watcher:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/watcher-0.9.7+10/lib/
web_socket_channel:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/web_socket_channel-1.0.9/lib/
yaml:file:///C:/Users/bruker/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/yaml-2.1.15/lib/
flutter_app1:lib/