Running flutter while offline - stuck on Resolving Dependencies - android

I'm trying to set up Flutter on a PC without internet connection.
I get stuck on "Resolving Dependencies" when trying to run an app (on a physical Nexus 5), and after some time I get a "Build failed with an exception" and a lot of failed download messages.
I installed the required software (inc. VSCode) as well as copied the flutter and gradle folders from my other PC where I normally use Flutter to develop.
Flutter doctor says I'm all good. I created the app offline using "flutter create --offline name_of_app".
This happens even if I try to run the app using Android Studio with gradle set to offline work and a path is directing to a full gradle distribution.
The error is:
* Error running Gradle:
ProcessException: Process "C:\name_of_app\android\gradlew.bat" exited abnormally:
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 download gradle.jar (com.android.tools.build:gradle:3.2.1)
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar'.
> Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar'.
And it continues to mention other file names as well.
What am I missing? I can run the app on my other PC when I disconnect it from the internet.
Thanks in advance.

As a beginner both in programming and in flutter I commit this answer with caveats. It worked on my machine (a Lenovo laptop), on Manjaro Linux.
First problem I had encountered during the compilation phase was the -beta01 problem. The gradle offline plugin available for download from android studio site has currently version number 3.5.0-beta01. By some automatism 'flutter create --offline' sets the dependency to gradle:3.5.0 in the global build.gradle file. I solved that part of the problem by replacing 3.5.0 with 3.5.0-beta01.
Second problem was a number of missing dependencies compiler complained about. I downloaded them all and put them in the gradle plugin folder (in Linux it's /home/username/.android/manual-offline-m2/android-gradle-plugin-3.5.0-beta01/ - the recommended path from the Android studio configuration walk-through). They were mostly gradle and kotlin related.
When I resolved the second order dependencies the work was done. The base flutter app compiled with no errors , with all the offline settings (online repositories' paths in global build.gradle commented out, internet disconnected).
For offline use, which is solely for learning purposes, I plan not to update flutter channels, nor the maven and gradle plugin, being that the only reason one would use a computer with no internet access for flutter is for learning in the beginner's phase ... Up in the mountains of Croatia... At least that's where I plan to use it :D

Related

React-native app offline with android studio

I'm develeoping react-native app on a computer without internet connection(I can't connect it to the internet),
I have configure the local repository and the android plugin according to android studio guide here
and also linked the gradle localy.
All the configures worked fine but the project is still not compiled, I get unresolved dependencies of the react native modules(example here) that I used.
I'm trying to solve this issue for two weeks and failed.
I didn't find any solution for this yet
The android studio version is 3.5.2 and the gradle version is 5.4.1
Any idea? Any help would be appreciated
Well, working offline with gradle will prove a little hard unless you build the project once when you have internet.
The problem is that gradle needs to resolve the dependencies and for this it's not only looking in node_modules, but also at different online repositories.
If you don't have internet - gradle isn't able to fetch the required packages and you get a build error.
In your case you've configured android studio to use offline versions of gradle and maven, but what your build can't find is soloader, yoga etc - those are libraries that are not available in the offline maven build you downloaded. As far as I can see from the content of that build it only contains the android dependencies.
You'll need to get the soloaded, yoga etc and provide those to your build for offline use. I guess that the easiest thing would be to build the project once when online... Afterwards gradle should reuse the cached packages.

Cordova build error: "Could not resolve all dependencies for configuration ':_debugApkCopy' > Could not find com.android.support:appcompat-v7:27.0.2."

It's been now two days I'm fighting with this issue.
I'm trying to build a cordova project that built marvelously like 1 month ago.
In between these time periods I had to change my PC so I installed again Java, Android Studio and Cordova, setting it up as usual.
I installed Google Repository (v58) as well as Android Support Repository (v47.0.0) in the SDKManager.
They appears to be the latest since I tried to uninstall and reinstall them twice.
I didn't change my project's configuration since I took a backup of it when it was working to start again.
When I run cordova build android, I got this error:
A problem occurred configuring root project 'android'.
Could not resolve all dependencies for configuration ':_debugApkCopy'.
Could not find com.android.support:appcompat-v7:27.0.2.
Searched in the following locations:
file:/C:/Users/Pierrick/AppData/Local/Android1/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom
file:/C:/Users/Pierrick/AppData/Local/Android1/extras/android/m2repository/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
file:/C:/Users/Pierrick/Desktop/hAz4rd0uS-uphair-1af95815ef72/hAz4rd0uS-uphair-1af95815ef72/platforms/android/sdk-manager/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.jar
These files are needed by plugins cordova-plugin-mapbox (v1.2.3) and cordova-plugin-facebook4 (v1.9.1). Obviously, I checked the "extras" folder in my Android SDK directory, and the last version of Android support I got is 26.0.0-alpha1.
How can I manage to download the requested files in the good location ?
Is it supposed to be done automatically ?
I really don't see what I am missing here, some help would really be appreciated.
I tried to:
-Reinstall cordova-android by cordova platform rm android and cordova platform add android#6.2.3;
-Delete gradle's android support's cache and metadatas as stated here;
-Reinstall Google repository and Android Support repository twice from Android Studio SDK Manager as stated here.
This is drivin' me nuts.
I just cam accross my problem and since I didn't see doublons of this thread I'm posting the answer here.
As stated in this thread the issue is caused by the facebook sdk. If you run in cordova CLI you simply have to modify the platforms/android/project.properties file.
Change this line:
cordova.system.library.1=com.facebook.android:facebook-android-sdk:4.+
into this line:
cordova.system.library.1=com.facebook.android:facebook-android-sdk:4.26.0
As stated in the relative thread, this is a hack.

App installation failed when transfered code

So i started my project on Mac OS and than with USB i transfered to MacOS, using same version of Android studio, but on Mac it doesn't want to run i tried to delte gradle and idea folders build a gradle and all but no success. The error i get is Application Installation Failed:
Installation failed with message Invalid File: /Users/myuser/Code/App/E:\Android\apps\build\intermediates\split-apk\debug\slices\slice_2.apk
Do you want to uninstall this existing application?
So as it looks like its picking up my Windows things from somewhere any idea how i can fix this?
Just Clean & Rebuild the project.
So i just run: ./gradlew clean and disabled instant run and its working now.

Ionic Gradle failure "Could not find com.android.tools.build:gradle:2.2.3"

I am attempting, in Windows 7, to compile my Ionic project Android platform using the Ionic CLI. This is something that previously worked, and now does not. The only thing that has changed is that I upgraded Android Studio. However, I am not compiling with Android studio, so I am surprised that I am getting Gradle errors. For:
$ ionic run android
The output is:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugApk'.
> A problem occurred configuring project ':CordovaLib'.
> Could not resolve all dependencies for configuration ':CordovaLib:classpath'.
> Could not find com.android.tools.build:gradle:2.2.3.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
Required by:
android:CordovaLib:unspecified
Though the output claims that I can gain additional error info with the --stacktrace and --debug flags, this is untrue.
I have seen threads suggesting that the problem is that one or more of mavenCentral() or jcenter() are missing from the repositories list in the build.gradle. These are both present.
I tried just throwing an HTTP GET at the addresses and it comes back 404. Is there somewhere else that I can direct Gradle to look for these files?
Possibly the strangest thing is that the files that it claims it can't find, actually do get downloaded into the Gradle cache each time (if I clear them, they appear the next time I execute the command). They appear in:
~/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle/2.2.3/88b4934c958cfe74ff5559c1a33707a562af59d2/gradle-2.2.3.pom
and
~/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle/2.2.3/7b8f79621d95e3ce1e95c0852db14d9d7e1d1951/gradle-2.2.3.jar
Steps I've taken so far:
upgrade Gradle
clear both gradle and Maven repositories
Try it off the company intranet with the --no-proxy flag on
I'm not sure what the next troubleshooting step should be.
I had same issue on mac, what worked for me was fresh install of android studio and ionic.
So probably first uninstall everything, then install android studio update it install whatever tools required, install gradle THEN install cordova and ionic.
This is maybe due to the path.Ionic is not able to find the path of the sdks in the same folder as u are giving there in your environment variables .
Try to change environment variables. Maybe you have given a local path instead of global hence it was not able to find sdks of your android studio.

Gradle build failed with an error 'timeout waiting to connect to the Grade daemon'

My new project is displaying this error on first run. I've not changed any project files android creates. Android Studio version 2.2 (Canary build), Gradle version 2.14.1 and plugin version 2.2.0.
Error: Failed to complete Gradle execution.
Cause: Timeout waiting to connect to the Gradle daemon.
Daemon uid: c788c7c1-86fc-45e7-9981-345127b657de with diagnostics:
Daemon pid: 5044 log file: C:\Users\red\.gradle\daemon\2.14.1\daemon-5044.out.log
Unable to read from the daemon log file: C:\Users\red\.gradle\daemon\2.14.1\daemon-5044.out.log,
because of: java.io.FileNotFoundException: C:\Users\red\.gradle\daemon\2.14.1\daemon-5044.out.log (The system cannot find the file specified)
Note: The app level build.gradle file is not displayed in Gradle scripts. Also the file is not opening within Android Studio. The 'build project' option is not displayed in 'Build' menu (probably because the build was not successful).
Finally I myself have found the solution. After a little search, I've learned that firewall interrupts gradle processes. I turned off Windows firewall and closed antivirus. But still it is not solved. So, I've uninstalled my antivirus and installed Avira. Now everything works fine.
Also earlier when I tried deleting .gradle folder, it said that the folder was being used by other programs. So, I guess some antivirus programs mess with Android files and folders.
Note: Keeping the question for anyone with similar problem.
I had the same problem, but it helped to colse the project and reopen it.

Categories

Resources