How to disable *sources.jar download during Sync in Android Studio project - android

IDE keeps sending *-sources.jar requests on each sync. This files are missing on server, so it leads to waste of time on each sync (especially on multi module projects). Is there a gradle or IDE option to disable this file requests? or optimize number of requests for multi module project?

There are few solutions how to build project offline:
Do it in terminal
gradle --offline build
Change it in gradle window (Android Studio 3.6.1)

Related

Gradle doens't work offline in Android Studio 2021.2.1

I'm trying to use Android Studio offline because in the place I work, IT policy doesn't allow me to download .jar or .zip or some similar files though I can request the files which I want to download from IT team. I tried to create a hello world project offline but gradle didn't synchronised so I couldn't even run a simple project.
Here are the things I tried for running android studio offline;
I downloaded gradle version 7.2 complete build from official website,
Specified Gradle location using the menu File --> Settings --> Build, .. --> Gradle,
Choose version 7.2. for both Android Gradle plugin and Gradle versions in File --> Project Structure --> Project menu.
Added the zip of gradle version 7.2 to gradle-wrapper.properties as;
...
distributionUrl=file\:/gradle-7.2-all.zip
...
Switched to gradle offline mode
Downloaded offline-gmave-stable.zip from offline sources on the official website and set a gadle script according to https://gist.github.com/eladkarako/a4ffac49e21b02356246604917911f9c
At the end of all of the steps above, I still get connection errors.
Here is the error I got;
Could not resolve all artifacts for configuration ':classpath'.
Could not download gradle-7.2.0.jar (com.android.tools.build:gradle:7.2.0): No cached version available for offline mode
... (around 80 more jar files)
Possible solution:
Disable offline mode and rerun the build
It's third day and I couldn't even started to write a line of code. Could you please help me out?

What is gradle plugin (for example gradle plugin 4.1.1)?And Where is it stored on computer?

I am using Android Studio. And I have come across the term called gradle plugin. I know what the gradle is and I have already downloaded it on my pc. Actually I want to know where does the gradle plugin 4.1.1 go after the project build successfully. I am successfully to use gradle locally into my project but when it comes to use gradle plugin I have to connect my computer to the internet everytime I create a new project. Is there any way I can use gradle plugin locally?
At least one time you should need to sync with your gradle plugins when you creating a new project then after you can use offline gradle option

Stop build from Android Studio 2.2 sync and build automatically

I was working on android studio 1.4, there clicking on gradle sync icon ("Sync Project with gradle files") on the top middle , performed only sync for gradle scripts, no build.
Now in Android Studio 2.2, clicking on gradle sync perform sync and build both.
Is there a way to stop AS from doing that, no build, only sync.
Found it myself, we have to tick the "skip source generation.." in gradle experimental settings. For my purpose I have given the value 0 in module numbers.

Difference between "default gradle wrapper " and "local gradle distribution" in android studio project

In android studio when we build the project there are two options for building the project in:
settings->build Tools->Gradle->Project-level settings
The first option is "Use default gradle wrapper" and the second option is "Use local gradle distribution"
My question is which option is faster and when will it be used?
You can read about Gradle Wrapper in the official user guide.
The main thing about the wrapper - it cares about the Gradle version used to build your project. So, if one has configured the project to use a wrapper, then everyone will build it with the same version of Gradle. The version of Gradle could be specified in the configuration file called gradle-wrapper.properties.
One more important thing is that Gradle distribution will be included in your project and if someone will try to build it, no local Gradle installation will be needed.
But if you choose use local gradle distribution, then your project will be built with the version of Gradle you have currently installed and it doesn't guarantees, that your project will be built correctly, since Gradle version may differ.
I don't think, that time is different for this two cases, but wrapper usage seems to be preferable. Sure, in this case, you have to store wrapper distribution in your version control system, but you can set build tool version exactly used to build your project and make no one install Gradle manually if he doesn't have Gradle installed yet.
I want to add a very important point to the Stanislav's answer. Gradle could be used not only for building your project from Android Studio, but also the from command line. This is especially important if you want to build it in CI environment. In that case, you don't need to care about specific gradle version on your server. The project will be built with the same version for both IDE and CI and this will make your build stable and predictable.

How to compile backend without android app in Android Studio

So I have an android app with an app engine backend (App-Engine Connected Android Project). Back when I used to work in Eclipse, I could compile the backend, then generate the endpoints for android, and then work on android. But now on Android Studio I don’t seem to be able to build the server without it building the android app as well. The problem with that is my android app is not ready to compile. So how do I work on the server and compile it and deployment apart from the android app? Needless to say I am extremely new to Android Studio. But I know the eclipse workflow, which is
Work on server code (develop, compile, test)
Generate client endpoints for android
Your Android Studio Project is likely to be a multi-module project i.e. it will be having a server side app and an Android app.
Android Studio uses Gradle as its build tool and hence you have the option on working on specific Gradle tasks (clean, compile, build, etc) on each of the projects separately. You need not always launch or run the overall Build process that will try to look at dependencies and then build all the stuff.
Since you want to work on the Server app separately and make that ready, I suggest that you can run the build tasks specific to that project. In the commander view you will see Gradle tasks for each project separately and you can run that. Alternately, you can also go to the terminal and look at the tasks and/or run those separately.
For e.g. let's say that you have an Android Studio project named MyApp and it has two modules in it called app and api. The app is the Android module and api is the Server side module with Cloud Endpoints. If you visit the terminal or command line and go to the root folder you can run Gradle specific tasks for each of the modules via gradle <modulename>:<taskname>.
Hope this helps.
Assuming a project structure of MyApplication (root) with app (android) and backend (appengine)
If you want to build only the backend. You should run the assemble task on that gradle module. Unfortunately running the task directly from the "Gradle" tab doesn't seem to run the task against the module alone, it runs it on everything. So you have two options.
run build from the command line : ./gradlew :backend:assemble
create a run configuration in the IDE for your gradle build, with the values
Name:Backend Build (or something),
Gradle project: MyApplication:backend (pick from dropdown),
Tasks :backend:assemble
and use that to build your backend by itself.
Both seem kind of annoying. You can also try to initiate an individual module rebuild directly when you run.
If you take a look at your backend run configuration (Run -> Edit Configurations), in the section Before launch:, you see a Make which does a project rebuild. You might need to remove that from the run configuration so it doesn't try to rebuild the whole project before deploying. To replace that with a gradle assemble of your module, click the +, and add a new Run Gradle task and configure it as above in "2".
I've filed a bug against this : https://code.google.com/p/android/issues/detail?id=168875&thanks=168875&ts=1429554595 I think the default behavior should be switched (use gradle assemble instead of make).
Generating Client libraries is done with some magic in Gradle. If you look at the build file for your Android App, it should reference a configuration on your backend called android-endpoints so the endpoint are generated as a compile dependency of your app module

Categories

Resources