Search code examples
fluttergradleandroid-gradle-pluginflutter-dependenciesgradle-plugin

How To Fix "Could not find core-1.1.0.jar (androidx.core:core:1.1.0)" Error. Flutter


Every Developer have encountered this kind of errors, and especially with this specific file core-1.1.0.jar.

The problem is that google for some reason removed the file from it's servers I guess, because the whole error is saying that it didn't find the file anywhere online.

There are a lot of solutions online that unfortunately won't work, these solutions include:

  • Migrating your project to AndroidX.
  • Downgrading the gradle plugin version.
  • Using some permissions in the AndroidManifest.xml file.
  • Downgrading the flutter version.
  • Using JCenter() and google() repositories.

And so on..., you get the idea.

Below I will share my experience of how I fixed this error.


Solution

  • you have to understand that the problem is not with your code or project, the problem is simply in a plugin your project is using, this is exactly why when I tried migrating my project to AndroidX I got a message that says:

    No AndroidX usages found.

    Now Below are the steps to solve this error.

    First: you need to add this code to your app's gradle.build file, it is found in this path android/app/gradle.build:

    dependencies {
        def core_version = "1.3.2"
    
        // Java language implementation
        implementation "androidx.core:core:$core_version"
        // Kotlin
        implementation "androidx.core:core-ktx:$core_version"
    
        // To use RoleManagerCompat
        implementation "androidx.core:core-role:1.0.0"
    
        // To use the Animator APIs
        implementation "androidx.core:core-animation:1.0.0-alpha02"
        // To test the Animator APIs
        androidTestImplementation "androidx.core:core-animation-testing:1.0.0-alpha02"
    }
    

    The code above is simply changing the core.jar version your going to use.

    Second: You need to go to the plugin folder that is causing this error to you, you can easily know which plugin is causing the error by just reading the error, and here's an example:

    Execution failed for task ':image_picker:compileDebugJavaWithJavac'. > Could not resolve all files for configuration ':file_picker:debugCompileClasspath'. > Could not find core-1.1.0.jar (androidx.core:core:1.1.0).

    Now as you can see, the image_picker plugin is causing the error. So we need to go to this plugin's folder.

    All the plugins' folders can be found in this path: %FLUTTER_SDK_PATH%\flutter\.pub-cache\hosted\pub.dartlang.org

    Just replace %FLUTTER_SDK_PATH% with your flutter SDK actual path.

    Now in this folder we find the image_picker folder.

    Third: After going to the plugin's folder, you need to change the version of the core.jar file this plugin is using, and this is how:

    You navigate to the android folder inside the plugin's folder and open the gradle.build file, in my case this is the path: %FLUTTER_SDK_PATH%\.pub-cache\hosted\pub.dartlang.org\image_picker-0.7.4\android

    Now scroll al the way down, and you'll find this code:

    dependencies {
            implementation 'androidx.core:core:1.1.0'
            implementation 'androidx.annotation:annotation:1.0.0'
            implementation 'androidx.exifinterface:exifinterface:1.3.0'
        }
    

    Change the implementation 'androidx.core:core:1.1.0' into implementation 'androidx.core:core:1.3.2':

    dependencies {
            implementation 'androidx.core:core:1.3.2'
            implementation 'androidx.annotation:annotation:1.0.0'
            implementation 'androidx.exifinterface:exifinterface:1.3.0'
        }
    

    And you are done.

    Please note that:

    • I first tried all the solutions mentioned above, and my last try was to edit the plugin's files.

    • The edits I made didn't affect the plugin in any way.

    • The core.jar file version that I used in the last step must be equal to the core.jar version specified in the first step.

    Thanks, and I hope you all errorless coding.