Davoud
Davoud

Reputation: 2963

Why I get this error when adding `url_launcher: ^6.1.5` to flutter app?

I've created a new flutter project and added url_launcher: ^6.1.5 to yaml file as dependency, when I run the app I get the following error. I have only this dependency. Checked different VPNs, Can open and download the jar files in Chrome, but still with no clue and can't run the app.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':url_launcher_android'.
> Could not resolve all files for configuration ':url_launcher_android:classpath'.
   > Could not find gradle-3.4.2.jar (com.android.tools.build:gradle:3.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.jar
   > Could not find builder-3.4.2.jar (com.android.tools.build:builder:3.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.4.2/builder-3.4.2.jar
   > Could not find tracker-26.4.2.jar (com.android.tools.analytics-library:tracker:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/tracker/26.4.2/tracker-26.4.2.jar
   > Could not find shared-26.4.2.jar (com.android.tools.analytics-library:shared:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/shared/26.4.2/shared-26.4.2.jar
   > Could not find crash-26.4.2.jar (com.android.tools.analytics-library:crash:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/crash/26.4.2/crash-26.4.2.jar
   > Could not find lint-gradle-api-26.4.2.jar (com.android.tools.lint:lint-gradle-api:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle-api/26.4.2/lint-gradle-api-26.4.2.jar        
   > Could not find gradle-api-3.4.2.jar (com.android.tools.build:gradle-api:3.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle-api/3.4.2/gradle-api-3.4.2.jar
   > Could not find databinding-compiler-common-3.4.2.jar (androidx.databinding:databinding-compiler-common:3.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-compiler-common/3.4.2/databinding-compiler-comm
on-3.4.2.jar
   > Could not find manifest-merger-26.4.2.jar (com.android.tools.build:manifest-merger:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/manifest-merger/26.4.2/manifest-merger-26.4.2.jar       
   > Could not find sdk-common-26.4.2.jar (com.android.tools:sdk-common:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/sdk-common/26.4.2/sdk-common-26.4.2.jar
   > Could not find builder-test-api-3.4.2.jar (com.android.tools.build:builder-test-api:3.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/builder-test-api/3.4.2/builder-test-api-3.4.2.jar       
   > Could not find ddmlib-26.4.2.jar (com.android.tools.ddms:ddmlib:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/ddms/ddmlib/26.4.2/ddmlib-26.4.2.jar
   > Could not find sdklib-26.4.2.jar (com.android.tools:sdklib:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/sdklib/26.4.2/sdklib-26.4.2.jar
   > Could not find layoutlib-api-26.4.2.jar (com.android.tools.layoutlib:layoutlib-api:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/layoutlib/layoutlib-api/26.4.2/layoutlib-api-26.4.2.jar       
   > Could not find dvlib-26.4.2.jar (com.android.tools:dvlib:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/dvlib/26.4.2/dvlib-26.4.2.jar
   > Could not find repository-26.4.2.jar (com.android.tools:repository:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/repository/26.4.2/repository-26.4.2.jar
   > Could not find common-26.4.2.jar (com.android.tools:common:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/common/26.4.2/common-26.4.2.jar
   > Could not find bundletool-0.7.2.jar (com.android.tools.build:bundletool:0.7.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/0.7.2/bundletool-0.7.2.jar
   > Could not find protos-26.4.2.jar (com.android.tools.analytics-library:protos:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/protos/26.4.2/protos-26.4.2.jar
   > Could not find builder-model-3.4.2.jar (com.android.tools.build:builder-model:3.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/builder-model/3.4.2/builder-model-3.4.2.jar
   > Could not find apkzlib-3.4.2.jar (com.android.tools.build:apkzlib:3.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/apkzlib/3.4.2/apkzlib-3.4.2.jar
   > Could not find apksig-3.4.2.jar (com.android.tools.build:apksig:3.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/apksig/3.4.2/apksig-3.4.2.jar
   > Could not find annotations-26.4.2.jar (com.android.tools:annotations:26.4.2).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/annotations/26.4.2/annotations-26.4.2.jar
   > Could not find databinding-common-3.4.2.jar (androidx.databinding:databinding-common:3.4.2).

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
Running Gradle task 'assembleDebug'...                              3.9s
Exception: Gradle task assembleDebug failed with exit code 1

Flutter Doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.19044.1826], locale en-US)
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK 
version 33.0.0)

** build.gradle**

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        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
}

Upvotes: 0

Views: 2229

Answers (4)

mahDyar Z
mahDyar Z

Reputation: 33

Add androidx settings on your app... go to android/app/build.gradle and add these on dependencies

dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

then go to android\gradle.properties and add these

android.useAndroidX=true
android.enableJetifier=true

At the end execute flutter clean then flutter pub get and run the app.

Upvotes: 1

Davoud
Davoud

Reputation: 2963

I couldn't find where the exact problem was. I went through bellow steps and could build the app on Android.

  1. Deleted All Installed JDKs and JREs.
  2. Deleted All environmental variables related to Android studio, JDK, and Flutter
  3. Deleted .gradle and .android folder in C:\Users\<you>\
  4. Deleted Android studio folder

  1. Installed new Android studio stable version
  2. Opened the existing flutter app deleted all the platform related folders, I mean android, ios, linux, macos, web, and windows inside the app. ran this command flutter create ., then ran the app on android phone. It went through all the necessary downloads and finally the app ran successfully. Note that I didn't installed any JDK, the Android studio picked the bundled JDK itself.

Upvotes: 0

Bilal Almefleh
Bilal Almefleh

Reputation: 376

see if this helps you build fail when adding url_launcher to my project

Upvotes: 0

Kaushik Chandru
Kaushik Chandru

Reputation: 17792

In pubspec.yaml add version of url launcher as any and try again. It should fetch an appropriate version of the package

url_launcher: any

Upvotes: 0

Related Questions