Flutter submodule in Android project - packages not resolved - android

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?

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.

Related

How to fix "Error:Cannot find JAR 'ivy-2.2.0.jar' required by module 'gradle-dependency-management' using classpath or distribution directory"?

I'm trying to create an Android application in Android Studio. When I try to create the project, it tells me that the Gradle refresh failed, with the error message
Error:Cannot find JAR 'ivy-2.2.0.jar' required by module 'gradle-dependency-management' using classpath or distribution directory 'C:\Gradle\gradle-2.10'
What is ivy-2.2.0.jar, and how do I fix this?
As of 7/19/2017, I have seen that the ivy-2.2.0.jar file is included in both the binaries-only and the complete installations for Gradle.
The file is located here:
gradle-4.0.1\lib\plugins\ivy-2.2.0.jar
Ironically, I received the same issue when attempting to build one of Oculus's VR sample projects.
When switching to the complete installation, I no longer received this specific error.
Perhaps try switching to the complete installation, or migrating the project to use any Gradle Wrappers that might be available.
This might happen if you are using the complete distribution with sources of Gradle. Try out the binary only distribution. It should work.

Configuration with name 'default' not found

I would like to start a project in Android Studio, using Simple Facebook library.
I used to develop in Eclipse and things were fine, but now i had to face an issue while trying to make the libraries work with gradle.
I made a new project.
I made a module for official Facebook SDK inside "libraries" folder
I made a module for Simple Facebook library inside "libraries" folder
I got the following error:
Error:A problem occurred configuring project ':app'.
> Cannot evaluate module simplefacebook : Configuration with name 'default' not found.
I did my research and as everybody experienced this error message is not really informative, and i also tryed to solve this problem from stack overflow's other smiliar questions but just coudnt get it work.
Please help if you can.
And please mention in comment which gradle file you would like to see, because there are 5 of them.
Look in the docs from Facebook!
You don't need to place the hole project as library module anymore in android studio.
Facebook and many other API Providers provide ther Libs now over Maven and you only have to add the dependcy to the correct artifact in your apps build.gradle file.
Here example for Facebook SDK:
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
Copied from here: https://developers.facebook.com/docs/android/getting-started
I havn't searched for the other lib, but you should find it your self on developers.facebook.com.

Unable to build Android app FabricGenerateResourcesDebug

I'm trying to integrate twitter's sdk with my app. I'm following this guide.
Unfortunately, when I try to build my project, I keep receiving this error:
Error:Execution failed for task ':app:fabricGenerateResourcesDebug'.
Crashlytics Developer Tools error.
Unfortunately because I don't have 10 reputation, I can't post my build.gradle file because it has links in it. Just trust the fact that it looks just like the build.gradle example in the top link provided.
Is there something that I'm missing that I may have overlooked?
Your problem should be caused due to that you did not create a “crashlytics.properties” file which is required to contain API Key and Build Secret in your app directory.
The solution is quite simple that you don't even have to manually setup anything on your original project. Just following this link:
https://fabric.io/settings/organizations
It will lead you to the Fabric official website, which helps you to download and install Fabric plugins into your IDE (Android Studio, IntelliJ or Eclipse). This might be a new magical method to integrate twitter's SDK within your app, it will automatically configure your project. You will see the magic when you get there.
Hope it helps.
The fix I found is that I did not place the meta-data tag with the API Key INSIDE the application tag in the androidmanifest.xml.

NoClassDefFoundError: org.slf4j.LoggerFactory on an Android applicaton with Graphhopper

I am currently developing an Android application and I'd like to use Graphhoper 0.3 embedded in the application (I have no way of setting up a server).
I am working with Android 4.0, Eclipse Kepler, Maven 3.2.1, Android for Maven Eclipse 1.0.1.
I first tried to pull branch 0.3 and set the "core" folder up as an Eclipse project, then adding it in the Build Path of my android project. I also tried to use the graphhopper-0.3-android.jar directly.
Android Project Main Activity onStart():
GraphHopper hopper = new GraphHopper().forMobile();
Unfortunately, everytime I got the following error:
java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
It does not pop in a regular Java project; only in Android.
I've tried to add the slf4j JAR's to the build path, with no success.
Any help would be greatly appreciated! It's my first post here, and I really don't know what I could try more. If you need any more information on my setup or anything, please ask!
Edit
Complete solution in comments of the validated answer.
Because you are trying to use Graphhopper directly, the Maven is not downloading all the dependencies of the Graphhopper. In order to fix this, you should either add the Graphhopper as Maven dependency, or try to resolve the dependencies 'by hand' - i.e. by adding missing classes to the build path and exporting them to the APK (if you are using Maven, then simply add the dependencies to the pom.xml without scope tag).

Run Robolectric in IDEA behind the proxy

I have corporate environment with all http and https calls are behind the proxy.
I was able to fix some issues with command line downloads by putting exporting http_proxy environment variable into .profile file.
But with Robolectric 2.2 which is downloading android sources or classes before first run I failed. I don't have CI setup yet so I'm just trying to run tests from idea.
Does anyone know hot to fix it?
I've tried to provide proxy in IDEA settings, I've tried to provide additional environment variable in run configuration. Nothing helps
UPD When I specify proxy in Mac settings it is producing another error:
Unable to find resource 'org.sonatype.oss:oss-parent:pom:7' in repository sonatype (https://oss.sonatype.org/content/groups/public/)
It looks like I'm probably using or missing wrong transitive dependency for Robolectirc (I don't use maven or ivy, I've just downloaded jars from maven central)
UPD2 Nope, It is just timeout again: Error transferring file: Operation timed out
I know that this is a little bit old Question but if you want to use proxy you should put the following file in your home/.m2 directory:
settings.xml
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>your_host_here</host>
<port>your_port_here</port>
</proxy>
</proxies>
</settings>
For gradle look here https://docs.gradle.org/current/userguide/build_environment.html
To add another late answer to an old question :) Since Robolectric 2.4 two properties were introduced to help in the scenario when your Robolectric tests in CI run behind a proxy server:
You have to specify robolectric.offline and robolectric.dependency.dir in your build.gradle file. Something like this:
afterEvaluate {
project.tasks.withType(Test) {
systemProperties.put('robolectric.offline', 'true')
systemProperties.put('robolectric.dependency.dir', "${project.rootDir}/.robolectric/")
}
}
Then you need to download the necessary jars from maven or sonatype and place it in the directory you specified...
I wrote a blog post with more details.
In case this helps someone. Setting the proxy in settings.xml (I tried both possible paths for this file) did not work for me. I ended up passing that as a gradle arguments:
gradle cleanTest test -Dhttps.proxyHost=<proxy-host> -Dhttps.proxyPort=<proxy-port>

Categories

Resources