Are Android gradle tasks open sourced? - android

I use ./gradlew connectedAndroidtest to test my android app.
When the connectedAndroidtest task running, from the terminal, I can get the task that ran many sub-tasks.
:assembleDebugAndroidTest UP-TO-DATE
:connectedDebugAndroidTest ...
but I don't understand the sub-tasks details.
I try to find gradle source code but can't find any about connectedDebugAndroidTest tasks.
Are android tasks open source? Or where I can know more details?
Thanks.

If you would like to see Android Build Tools source code, there is open Google repository with it: android/platform/tools/build/master
Specifically Android Gradle Plugin: build/gradle.
If you would like to see manual for specific task, you could execute:
./gradlew help --task "${taskName}"
In your case it should be:
./gradlew help --task connectedAndroidTest
Output:
Detailed task information for connectedAndroidTest
Path
:app:connectedAndroidTest
Type
Task (org.gradle.api.Task)
Description
Installs and runs instrumentation tests for all flavors on connected devices.
Group
verification

Related

KtLint Execution failed for task ':app:ktlintAndroidTestDebugSourceSetCheck'

I am using gradle version 7.0.0-beta01 and following this guide to setup KtLint to my project. But I am facing error while running following command
./gradlew ktlintFormat
Running with -stacktrace etc also doesn't seem to help much. Here is the error I am getting. Any help is much appreciated.
Execution failed for task ':app:ktlintAndroidTestDebugSourceSetFormat'.
> Querying the mapped value of task ':app:ktlintAndroidTestDebugSourceSetFormat' property 'reporterOutputDir' before task ':app:ktlintAndroidTestDebugSourceSetFormat' has completed is not supported
This was fixed in a later version of the ktlint gradle plugin. You can go down to 9.2.1 or up to 10.0.0. See this issue.

Android Execution failed for task ':app:compileDebugJavaWithJavac'. - React Native

I am working on a react native application. when I try to build the applications using react-native run-android the build fails. Here is the output of the error that occurs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 8s
253 actionable tasks: 5 executed, 248 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug
debug Error: Command failed: ./gradlew app:installDebug
at checkExecSyncError (child_process.js:607:13)
at execFileSync (child_process.js:627:13)
at runOnAllDevices (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runOnAllDevices.js:58:39)
at buildAndRun (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runAndroid.js:142:41)
at then.result (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runAndroid.js:104:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
The application was on a old version of react native (0.48.x) I have updated it to 0.59.10.
What I have done so far:
used jetifier to resolve issues with the plugins.
checked that the build tools version matches the compile sdk version
checked if the emulator is running.
Hence I have tried everything I could to resolve this but had no luck. Please do guide me on how to resolve this issue. Looking forward to your answers.
make sure you have followed all the necessary steps from the upgrade helper https://react-native-community.github.io/upgrade-helper/?from=0.48.0&to=0.59.10
also i would suggest you to upgrade to v0.60+ because there are breaking changes after v0.59.10.
having said that
before you run the app make sure your gradle is clean
run the following command to clean your gradle cd android && ./gradle clean
then later you can navigate back to your app folder cd .. and try and run again react-native run-android
Looks like your packages not working stable with Android side. It's better be update all packages and react native version to their last stable versions.
If you face with too much error while update, you can create fresh new react native project (with same package name with your current project), install all packages (and their dependencies) and copy your current project's source code to your new project.
Android in React Native does not allow similar packages to reside in the project.
In my case I had react-native-cookies and #react-native-cookies/cookies packages that add similar code to the Kotlin file upon build. This causes issue of similar imports in java JDK.
I removed one and it worked.
SOLVED at the same issue:
My solution was at /android/build.gradle file.
Somehow, the buildscript versions were wrong.
Follow the exact same step of RN documentation and make a totally new & clean project.
And compate the /android/build.gradle file > buildscript & dependencies part.
There should be some version differences.
It matters by your own local env settings.
After changing buildToolsVersion, ndkVersion, classpath, it worked fine again!!
also, remove duplicated libraries, as #Nimantha said.

Android build variants on travis.ci

I currently have an Android project using gradle and integrated with travis.ci which has different productFlavors and buildTypes. When the "connectedCheck" task is then executed on travis.ci, it tries to package all build variants (all combinations of flavors and types). Some of them fail as the release builds need password input which I can't automate at the moment. Is there a way to tell travis.ci to build and test only a certain build variant of an Android project?
Say you only want to run the product flavor Trial and the build type Debug.
Instead of running ./gradlew assemble connectedCheck, which is similar to what you're doing, run this instead:
./gradlew assembleTrialDebug connectedCheckTrialDebug
So here's how I made it work:
Run a connectedAndroidTest<productFlavor><buildType> task instead of connectedCheck.
Also set the assemble task in the install section of the .travis.yml:
install: - TERM=dumb ./gradlew -s assemble<productFlavor><buildType>

How do you use the gradle javafx android builder?

For the gradle javafx builder I've used the tutorial at: https://bitbucket.org/javafxports/android/wiki/Building%20and%20deploying%20JavaFX%20Applications
I downloaded the runtime from here: https://bitbucket.org/javafxports/android/downloads
I'm using javafx in eclipse. I have tried to build the project with theses parameters:
gradle -PDEBUG -PDIR=C:/Users/spencer/Desktop -PNAME=HelloAndroidWorld -PPACKAGE=com.helloworld -PJFX_SDK=C:/Users/spencer/Downloads/dalvik-sdk-latest/dalvik-sdk/android-tools -PJFX_APP=C:/Users/spencer/Documents/Eclipse/Work" "Space/Interactive" "JavaFX/src -PJFX_MAIN=application.Main.java
Here is the message I got afterwards:
C:\Users\spencer>gradle -PDEBUG -PDIR=C:/Users/spencer/Desktop -PNAME=HelloAndro
idWorld -PPACKAGE=com.helloworld -PJFX_SDK=C:/Users/spencer/Downloads/dalvik-sdk
-latest/dalvik-sdk/android-tools -PJFX_APP=C:/Users/spencer/Documents/Eclipse/Wo
rk" "Space/Interactive" "JavaFX/src -PJFX_MAIN=application.Main.java
:help
Welcome to Gradle 1.12.
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
BUILD SUCCESSFUL
Total time: 9.871 secs
I cannot find the file on my desktop! When i try adding "createProject" to the end i give me errors.
How do i build a android project?
I am not sure what id did wrong this is my first time trying this please help. All the help so far has been great!
Thanks
you have to give task to a gradle for creating a project give createProject task at the end of all parameters but before that you have to run gradle from your dalvik sdk into the android-tools folder
because it contain the build.gradle file in which createProject task is defined for example
into the command line:
c:\User\dalvik\dalvik-sdk\android-tools> gradle -PDEBUG -PDIR=C:/Users/spencer/Desktop -PNAME=HelloAndroidWorld -PPACKAGE=com.helloworld -PJFX_SDK=C:/Users/spencer/Downloads/dalvik-sdk-latest/dalvik-sdk/android-tools -PJFX_APP=C:/Users/spencer/Documents/Eclipse/Work" "Space/Interactive" "JavaFX/src -PJFX_MAIN=application.Main.java createProject
You haven't run any task. Run gradle tasks to see the list of available tasks. Then pick up a task from the list and run the command once again with task specified. There's also a detailed info:
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

Android gradle test only one flavor

I've currently set my TeamCity instance to run connectedCheck on all my Android-projects. This is fine, all tests run and everything is good. Except, connectedCheck runs all tests for all product flavors. I currently have a lot of flavors, so this is wasted work for my projects as I do not really have any different code in the flavors. Any idea how I can make connectedCheck only run for one flavor?
./gradlew connected[Flavor]DebugAndroidTest
./gradlew connectedBuildVariantAndroidTest
Example:
./gradlew connectedDevelopmentDebugAndroidTest
As vida said you can run ./gradlew tasks to check all possibilities to run gradle commands.
I'd like to suggest the following:
./gradlew tasks | grep connected.
This filter all connectedAndroidTest variants that can be runned.
I see there is a new task since I checked this the last time, "connectedAndroidTestProductFalvor_buildvariant".
I haven't had time to check this task yet, but the description reads "Installs and runs the tests for build ProductFlavor_buildvariant on connected devices."
Will post a result when I've been able to test this.
and if you want to generate the apk for the android test :
./gradlew assemble[flavour]DebugAndroidTest

Categories

Resources