Run "Instant Run" from command line - android

I'm running my Android app from Android Studio, and Instant Run kicks in, which is great. I want to run the exact same thing from the command-line.
In Android Studio's Event Log, I see
22:00:28 Executing tasks: [:app:incrementalDevDebugSupportDex]
22:00:48 Gradle build finished in 20s 286ms
22:00:51 Instant Run applied code changes and restarted the current Activity.
So, I expected I would be able to run that task from the command line: ./gradlew :app:incrementalDevDebugSupportDex. However, it's not found:
FAILURE: Build failed with an exception.
* What went wrong:
Task 'incrementalDevDebugSupportDex' not found in project ':app'.
Is there a way to run with Instant Run from the command line?

It is currently not possible to use instant run outside of Android Studio. This was mentioned at the Android Dev Summit, but I can't recall exactly in which talk that was.

You can run instant-run from command line like this:
./gradlew clean :sample-app:assembleDebug -Pandroid.optional.compilation=INSTANT_DEV -Pandroid.injected.build.api=24

As of now it is possible. You can run the below command to make an instant run :
./gradlew :app:incremental"buildvarientname"DebugJavaCompilationSafeguard
You can add the same in gradle task also by adding incremental"buildvarientname"DebugJavaCompilationSafeguard inside the task on the run configuration window,

Related

How can i clone from git for try to testing in my android?

I want to try to run this airbnb clone app in my android studio
but the problem is it's not working in my android studio
https://github.com/mdy0501/Airbnb
It just show in my console
!-- console --!
7:01:05: Executing task...
> Task :help
Welcome to Gradle 5.1.1.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
To see more detail about a task, run gradle help --task <task>
For troubleshooting, visit https://help.gradle.org
BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed
7:01:05: Task execution finished.
I want to know how to run that app in my android AVD
Is that possbile..? running in my android studio that app ?
i can't find how to run...
Make sure the repository you have cloned is Android project
Before Run the demo you should sync your project
You will see a lot output in the Build window at the Android Studio bottom.
Project sync successfully the Run button will look like this.
If sync operation failed it means project did not configure correctly just try to fix the error according to the sync output.

Execution error while building android phone gap build

when i Run the command phonegap build android it gives me the the error execution failed for task 'mergeDebugResources' I am implementing the plugin cordova-background-geolocation-lt and following the same as explained there and install the same SDK's.
complete error
Here is some more info about DEBUG after running the command gradlew.bat --info build clean
I think this is a clash with some other plugin. I have tried adding the diagnostic plugin to a brand new project and tried building. That worked fine.

How to run 'rebuild project' from the command line

Some Context:
I am working on a Continuous Integration pipeline with MSBuild for a large project that includes an Android application. This application includes some automatically generated files that need to be integrated into the project regularly. This is usually accomplished by manually copying them over and selecting Build->rebuild project in android studio.
This step is necessary since the project also makes use of AndroidAnnotations, which generates classes at compile time.
The Problem:
I haven't found any documentation for what is run when you select 'rebuild project' in android studio.
What I Have Tried:
How to Rebuild and Run android project from command line
as well as:
What is happened after I run rebuild project in Android studio?
But the doccumentation here doesn't talk about the rebuild command, and a 6 week udacity course isn't a helpful resource either.
When I hit 'rebuild project' the Android Studio event log reads:
Executing tasks: [clean, :app:generateDevelopmentDebugSources, :app:generateDevelopmentDebugAndroidTestSources, :app:prepareDevelopmentDebugUnitTestDependencies, :app:mockableAndroidJar, :app:compileDevelopmentDebugSources, :app:compileDevelopmentDebugAndroidTestSources, :app:compileDevelopmentDebugUnitTestSources]
Which I have run in the command line as follows:
gradlew.bat clean :app:generateDevelopmentDebugSources :app:generateDevelopmentDebugAndroidTestSources :app:prepareDevelopmentDebugUnitTestDependencies :app:mockableAndroidJar :app:compileDevelopmentDebugSources :app:compileDevelopmentDebugAndroidTestSources :app:compileDevelopmentDebugUnitTestSources
The command executes, but the build finishes with several hundred errors, which also occur when you try to compile or clean without first running rebuild. Obviously this command is incomplete.
When I look at the Gradle Console in Android Studio I see a couple of dozen targets that are run, but I'm hesitant to copy-paste those, as I have no idea what small changes to the project will necessitate different targets to be run.
I've narrowed down my issue to the :app:compileDevelopmentDebugUnitTestJavaWithJavac target. This target requires one of the other targets listed in the Gradle Console, but I don't know which one.
Those targets have to be coming from somewhere, but where?
tl;dr:
How can I do all the things that Android Studio does when I run 'rebuild project' from the command line?
Please open build view in Android Studio, when you select from menu: Build -> Rebuild Project on the top in build view you will see which tasks were triggered by Android Studio: Executing tasks: [clean, :assembleDebug] in project ...
And now you can try to do this from command line:
./gradlew clean assembleRelease
Rebuild and build are the same thing. You can list all the gradle tasks by running a command gradle task --list or gradle -q :tasks --all . There you can see different types of gradle tasks. For example, install tasks, build tasks, assemble tasks, publishing tasks, verification tasks, build setup tasks, clean tasks, android task, or your own custom named tasks etc. Run on the build tasks from your module (e.g., MyModule:build) like this gradle MyModule:build (or ./gradlew MyModule:build if you wanna use inside gradle wrapper)
Note: you can see your runnable/buildable module from Run Configurations also.

Gradle Build Running in Android Studio for too long

Whenever I Start or run my project the gradle build running never stops.I have tried creating new project nothing is happening. Some projects are working fine but some of them are not and taking forever in gradle build running. Also whenever I open the project this cmd appt.exe file opens.
Open the terminal tab and try building the project manually gradle --stop clean build --stacktrace
The --stop param will kill any running instances of the gradle daemon. Its also possible gradle ran into a .lock file that is blocking its execution. This can happen if a build is terminated before completion. When you run on the command line it may take as long as 3 minutes before gradle gives up and fails. The error message provided by --stacktrace should tell you where the file causing the problem is.
Just delete the lock file: rm <pathToLockFile> then rebuild. This could happen a few times before the build completes.
It would be nice if there was a way to clean up all locks but to my knowledge this doesn't exist.

Gradle tasks log during run build apps

I build my Android app using Gradle as build system. There is some idea run/debug configurations that I can run. What's interesting for me is the debug configuration of my android app and gradle run tasks configurations.
When I start gradle configuration for executing, I can see in run window all outputs and logs of gradle tasks running at that moment. But when I start my Android app debug configuration, I do not see any gradle tasks output at all. But I know that some of its steel run before compiling java source code.
Is there is any setting or options that I can add to always show gradle tasks output, when I start Android ap run configuration? Thanks a lot!

Categories

Resources