Unable to make a pull in gradle file - android

i´m trying to make a task in Gradle for my Android project ( using Kotlin DSL ) where I need to do an automatic pull for my "develop" branch.
This are the commnand I want to run :
git pull origin develop:develop
In the terminal this works just fine.
I`m using "commandLine" with "exec" in my gradle file and I´m having this error message:
code:
tasks.register<ReleaseTask>("makePull") {
exec { commandLine("git", "pull", "origin develop:develop") }
}
error message:
ssh: Could not resolve hostname origin develop: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
FAILURE: Build failed with an exception.
I don´t have any issue if I try this commands in the terminal, do you know what i´m doing wrong ?

You haven't separated the origin and the develop:develop arguments in the gradle version. Use this instead:
commandLine("git", "pull", "origin", "develop:develop")

Related

Not able to git push or pull in android studio 3.6

I'm getting the following error while trying to push or pull or anything with ssh in android studio 3.6
Update failed Invocation failed Unexpected Response from Server: Unauthorized java.lang.RuntimeException: Invocation failed Unexpected Response from Server: Unauthorized at org.jetbrains.git4idea.nativessh.GitNativeSshAskPassXmlRpcClient.handleInput(GitNativeSshAskPassXmlRpcClient.java:34) at org.jetbrains.git4idea.nativessh.GitNativeSshAskPassApp.main(GitNativeSshAskPassApp.java:30) Caused by: java.io.IOException: Unexpected Response from Server: Unauthorized at org.apache.xmlrpc.LiteXmlRpcTransport.sendRequest(LiteXmlRpcTransport.java:231) at org.apache.xmlrpc.LiteXmlRpcTransport.sendXmlRpc(LiteXmlRpcTransport.java:90) at org.apache.xmlrpc.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:72) at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:194) at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:185) at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:178) at org.jetbrains.git4idea.nativessh.GitNativeSshAskPassXmlRpcClient.handleInput(GitNat..................
looks like the problem is with native ssh and we cannot change it to built-in like previous versions... how to fix this ???
any help would be appreciated
WORKAROUND:
1. In Android Studio go to Help - Find Action - Registry...
2. Find git.use.builtin.ssh and enable it
3. Check that git works again
Not straight solution - but you can change your git url from ssh to https, and it will work.
git remote set-url origin YOUR_REPOSITORY_HTTPS_URL
I have found an alternative way to make SSH actually work...
rate up if it worked for you!!!
using putty plink for ssh instead of the Git ssh(openSSH)
1.set the system env-variable GIT_SSH and let it point to plink.exe
download links available here: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
2.start pageant and add your private key to it (needs to be converted to another format to be used)(use puttygen to convert id_rsa to ppk)
3.use command in terminal based on github or gitlab : plink -v git#github.com or plink -v git#gitlab.com
congrats now you can work with ssh

error while pushing to GitHub

i want to commit changes to GitHub
i can do it with GitHub desktop but i get this error when i try with android studio commit changes button :
"Failed with error: fatal: unable to access 'https://github. ... .git/': The requested URL returned error: 403"
You need to first find the correct SSH/ HTTP address to the repository that you would like to commit to then you can run this command in your terminal:
git remote add origin [remote repository URL]
once connected, you should be able to commit the changes.

React-native unable to run-android

Following this: https://facebook.github.io/react-native/docs/getting-started.html ,
I've created an empty project and am trying to run it by doing:
sudo react-native run-android
This is what is produced:
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug...
Downloading https://services.gradle.org/distributions/gradle-2.4-all.zip
Exception in thread "main" javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
(I can post the rest of the error if that would be useful). Does anyone have any advice?
Change the distribution url in:
android/gradle/wrapper/gradle-wrapper.properties
from https to http.
Using the following steps i resolved the error :
Open build.gradle (node-modules/react-native/ReactAndroid)
Change src path of task downloadBoost with
http://mirror.nienbo.com/boost/1.57.0/boost_1_57_0.zip
task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
// Use ZIP version as it's faster this way to selectively extract some parts of the archive
//src 'https://downloads.sourceforge.net/project/boost/boost/1.57.0/boost_1_57_0.zip'
// change
src 'http://mirror.nienbo.com/boost/1.57.0/boost_1_57_0.zip'
onlyIfNewer true
overwrite false
dest new File(downloadsDir, 'boost_1_57_0.zip')
}
Perform Gradle Sync
Tools -> Android -> Sync Project with Gradle Files
Chang the distribution url in /android/gradle/wrapper/gradle-wrapper.properties from https to http and also change the gradle version from 5.4 to 5.5

TeamCity, Android, Gradle Script failure

I have been struggling to get TeamCity to build my Android Project. I have finally gotten the server to be able to compile the project with Gradlew (although I have to ignore lint errors, which I am not happy about - it will not tell me which lint errors are being violated EDIT: I found it in ..\build\outputs\lint-results.html)
But now I can see that it is trying to execute the following:
C:\TeamCity\buildAgent\work\284714bad9f1a533\MyProject>gradlew.bat --init-script C:\TeamCity\buildAgent\plugins\gradle-runner\scripts\init.gradle clean build
And I am getting the following error:
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\TeamCity\buildAgent\plugins\gradlerunner\scripts\init.gradle' line: 31
* What went wrong:
A problem occurred evaluating initialization script.
> Cannot invoke method split() on null object
I have checked this line and it seems fairly standard:
initscript {
dependencies {
def teamCityInitLib = System.getenv("TEAMCITY_BUILD_INIT_PATH")
println "Init lib: ${teamCityInitLib}"
def classPathFiles = teamCityInitLib.split(File.pathSeparator) //line 31
classpath files(classPathFiles)
}
}
Can anyone help me? NOTE: the following command works without a problem:
gradlew.bat clean build
Seems that you don't have TEAMCITY_BUILD_INIT_PATH variable in your PATH on your build machine. You can add it either by standart ways, depending on OS, or by adding it to Build Parameters in Configuration Steps of your build.
It seems like the build file is not being found. At least, that is what support is telling me. To me this is a TeamCity bug and not on my side. When I find out more, I'll post it.
Found this post while looking for a way to emulate a TC build from the command line and trying to understand how to set TEAMCITY_BUILD_INIT_PATH.
In my environment I determined that it's set to:
/apps/teamcity-agent/agent/lib/serviceMessages.jar:/apps/teamcity-agent/agent/lib/runtime-util.jar:/apps/teamcity-agent/agent/plugins/gradle-runner/lib/gradle-runner-common.jar
Where /apps/teamcity-agent is the my TC install path.
Hope this helps.

Gradle in Android Studio 0.44 can't find process on path to run in an Exec Type task

I used to have the following gradle build task:
task buildWebApp(type: Exec) {
executable = Os.isFamily(Os.FAMILY_WINDOWS) ? "grunt.cmd" : "grunt"
args = ["build"]
}
This would pick the appropriate grunt command and run it with the argument "build".
This worked without any kind of issue
I've just tried this in Android Studio 0.4, using Gradle 1.9 and it's no longer working. Instead I get the following error:
Execution failed for task ':BrowserPages:buildWebApp'.
A problem occurred starting process 'command 'grunt''
Normally at this point I would debug with gradlew, but running the following command, throws no errors:
$ ./gradlew buildWebApp
I've also tried running the full task list to still not find any problems.
The way this is executed is from my main build.gradle file with this dependency
copyWebApplication.dependsOn ':BrowserPages:buildWebApp'
Anyone have any ideas?
I've tried to run executable = "node" with arg = ["-v"] and get the same error where it can't find node. Node is globally accessible on my terminal, so I can only assume that the command is being run in a different environment to the terminal. There is the option for setting the environment but I can't find any examples of how it should be used.
Try using a fully-qualified path to the grunt executable. Perhaps something in the path has changed between Android Studio/Gradle/Android Plugin versions.

Categories

Resources