0

I am trying to add a Flutter module to my Android project. For that, I follow the relevant flutter docs, and everything seemingly works fine.

However, when I run a Gradle sync after following all the steps in above link, the sync returns the following warnings

Failed to resolve: io.flutter:flutter_embedding_debug:1.0.0-57d3bac3dd5cb5b0e464ab70e7bc8a0d8cf083ab
Failed to resolve: io.flutter:armeabi_v7a_debug:1.0.0-57d3bac3dd5cb5b0e464ab70e7bc8a0d8cf083ab
Failed to resolve: io.flutter:arm64_v8a_debug:1.0.0-57d3bac3dd5cb5b0e464ab70e7bc8a0d8cf083ab
Failed to resolve: io.flutter:x86_64_debug:1.0.0-57d3bac3dd5cb5b0e464ab70e7bc8a0d8cf083ab
Failed to resolve: io.flutter:x86_debug:1.0.0-57d3bac3dd5cb5b0e464ab70e7bc8a0d8cf083ab

It seems it cannot find some needed packages in any of the repositories I have specified. And indeed, I cannot use

import io.flutter.embedding.android.FlutterFragment;

from my Android Java code.

What repository do I have to specify to make sure the needed packages are found?

derpda
  • 1,093
  • 8
  • 16

1 Answers1

1

Solution

I looked through a bunch of questions here on StackOverflow, but nothing seems to really match the problem I ran into. The closest would be this question, but its answer did not quite work in my case.

Instead I stumbled upon this blog post, where it is recommended to add the following repository:

    repositories {
        ...
        maven { url "https://storage.googleapis.com/download.flutter.io" }
    }

In my case, I added the repository to settings.gradle in the host Android project (not in the one generated by Flutter). Where you add the repository may vary in your case, and I am not 100% confident that this is the best place.

However, this indeed fixes the problem for me. The packages are found, and I can use the Flutter module as expected.

Details

The repository mentioned in the SO question I mentioned above is accessed via http which may be an issue for some. Accessing it with https give the following in Firefox:

Websites prove their identity via certificates. 
Firefox does not trust this site because it uses a certificate that is not valid for download.flutter.io. 
The certificate is only valid for the following names: 
*.storage.googleapis.com, *.googleapis.com, commondatastorage.googleapis.com, 
*.commondatastorage.googleapis.com, storage.googleapis.com, storage.mtls.googleapis.com,
 *.appspot.com.storage.googleapis.com, *.content-storage.googleapis.com, 
*.content-storage-p2.googleapis.com, *.content-storage-upload.googleapis.com, 
*.content-storage-download.googleapis.com, *.storage-upload.googleapis.com, 
*.storage-download.googleapis.com

This indicates to me that https://storage.googleapis.com/download.flutter.io is the correct URL to use for the Maven repository.

derpda
  • 1,093
  • 8
  • 16
  • 1
    had the same issue, and i followed the blog post you shared here, and it builds successfully! for me, I had to add the maven repo at the build.gradle under 'allproject' – Juvi May 22 '22 at 18:22