How to Sync Project with Gradle Files? - android

change gradle.properties by a script ;
manual Sync Project so the resVal and BuildConfig will refresh.
so, what does the manual Sync Project button do?
how to manual write it in my cmd script

May bellow tow thing will do your work
If you want to sync just project without rebuild then use bellow command
./gradlew --recompile-scripts
And if you want to rebuild your full project
./gradlew build
And Also if you want to see your all task then use bellow commands
./gradlew tasks

Related

How to sync gradle in React Native (android)?

I tried ./gradlew build but that didn't work, because it doessnt see the changes made in gradle file. The only thing that works for me is restarting and invalidating cache, but there must be a better way to do it.
Thank you
You should try running ./gradlew clean before building.
change directory to /{your project}/android then run below commands
./gradlew clean
./gradlew build
Note :-
you will get error : ./gradlew: No such file or directory
if you are trying gradlew commands outside android folder.
also check this : Why run 'gradle clean build' instead of 'gradle build'?

How to clean a module in AOSP?

This is the same question as previously another one which I found the solution in is invalid.
Because the command mm -B is invalid.
So how could I clean one specific module in AOSP with clean the other part?
how to make clean module in android
$ make clean-<moudlename>
eg: make clean-libxyz (to clean libxyz.so)
https://dolinux.blogspot.com/2012/05/how-to-make-clean-module-in-android.html
or
NINJA_ARGS="-t clean" mm
You cannot do that , we can build a simple module with this command:
mmm “path to build”
but we cannot clean a module with this command. to perform cleaning source , you should use this command:
make clean

Gradle test run fails after class rename

We have Gradle set up to build and test our Android app. Now we ran into the problem, that Gradle test runs fail reproducibly after a class was renamed somewhere in the project:
Execution failed for task ':PROJ:compileDebugUnitTestJavaWithJavac'.
> Unable to read class file: '/path/to/class/with/the/name/before/renaming.class'
This error is reproducible both..
locally (run gradle tests from Android Studio, or on command line using ./gradlew test), and
remotely, when the tests run on our CI (a Teamcity server).
What solves the issue, is manually triggering a rebuild locally (e.g. in Android Studio Build > Rebuild Project) or re-running the Teamcity task with the flag clean all files in the checkout directory before the build set.
Is there any way we can get our tests to not fail after a class has been renamed?
While the above solution is simple enough it is kinda annoying that a simple rename which makes it to our repo will blow up the CI builds... We really want those to stay green. :)
This is a known issue in Gradle 2.14 and 2.14.1 and there will be a workaround for it in upcoming Android Gradle plugin release.
As a workaround you can do a clean build for your project. For a CI build, a clean build is a good idea anyway.
You could use the Swabra build feature of TC that cleans out the working directory either before or after each build, so that all generated files are blown away and the build always starts with a clean working copy. For reproducible builds this is a must-be-used feature in my opinion.
Alternatively you can of course also add the clean Gradle task to your TC configuration so that Gradle cleans away previous build artefacts. But if using TC I'd prefer Swabra as it restores VCS state reliably.

Using custom tasks to build android modules

My project on Android Studio has multiple modules(MyApp1,MyApp2 etc.) and i want to create a custom task so that instead of calling ./gradlew :MyApp1:assembleDebug: , i want to call something like ./gradlew releaseMyApp1.
I want to customize that task, so it will clean the projects first, and then edit the sub project's build informations (version name,version number etc.).
First i want to ask if i can i can put all those custom tasks inside the root projects build.gradle file? Secondly how can i call the subproject assembleDebug or assembleRelease tasks from another gradle script? I tried something like this(inside root project build.gradle but it doesnt do anything for me:
task releaseMyApp1{
finalizedBy ':MyApp1:assembleDebug'
// clean the projects, change version name, number etc
}
Thanks for all the help.
Something like this:
task releaseMyApp1(dependsOn: ':MyApp1:assembleDebug')

In Android Studio, building one project of a multi-project setup with Gradle, can I make it only build one of the projects?

I have a multi-project setup in Gradle and work in Android-studio. The setup contains two apps (each one has its own project directory with its own build.gradle) and some libraries shared by those apps.
The directory structure looks like this:
/workspace/
/workspace/app1/
/workspace/app2/
/workspace/app3/
/workspace/library1/
/workspace/library1/
When I build from the command line I can limit the build to only one of the apps via
gradle assembleDebugApp1
When I build from within Android Studio, it seems to build all projects that have a build.gradle file and are inside of workspace.
In Android Studio, when I run Build->Make Project, I see on the bottom what gradle does:
Gradle build using tasks: [:app1:assembleDebug, :app2:assembleDebug, library1:bundleDebug, (...)].
I would like it to only run the assemble task for my "current project".
I'm new to AndroidStudio, so maybe the question is : How do I set the "current project'?
How do I tell Android Studio to only build what I need for app1?
Edit based on replies:
I do want to run gradle via make so it does give feedback back to the IDE, because I'd like to see the "Make Messages" window:
Open Gradle tasks tab and select task to run. You can select a task from subprojects.
On command line:
gradle :app1:assembleDebug
I'm not sure if there is an "official" way of handling this yet but I got around it by creating a new "Run Configuration" and replacing the default "Build" option in the "Before Launch" section with my own command that calls Gradle with the relevant command line options.

Categories

Resources