What I am trying to do: I am trying to install ktlint on windows locally
What I tried:
Used below command in command prompt
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.38.1/ktlint && chmod a+x ktlint
Also tried above command by using in below steps in link
https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/
What is happening: Not able to install in windows.
How to install in windows ?
I was having trouble installing ktlint for Windows 10. What worked for me was going to the Releases page, downloading the ktlint file, renaming the ktlint file to ktlint.jar and adding it inside my Android project root folder (in reference to this GitHub issue) (Note: Java must be installed so that the file extension can be recognized), then running java -jar ktlint.jar --apply-to-idea-project (in the command line, from the Android project root directory). Then finally I was able to get it to work, resulting in the following text:
The following files are going to be updated:
.\.idea\codeStyles\codeStyleConfig.xml
.\.idea\codeStyles\Project.xml
.\.idea\inspectionProfiles\profiles_settings.xml
.\.idea\inspectionProfiles\ktlint.xml
.\.idea\workspace.xml
Do you wish to proceed? [y/n]
(in future, use -y flag if you wish to skip confirmation)
y
(updated)
Please restart your IDE
(if you experience any issues please report them at https://github.com/shyiko/ktlint)
Without updating the file to have the .jar extension and adding .jar to the filename command line parameter, I kept getting the following error:
Error: Unable to access jarfile ktlint
To run ktlint immediately, run java -jar ktlint.jar in the command line (in the directory where the ktlint.jar file resides).
You can install a git hook to automatically check files for style violations on commit by entering the following command in the Command Line (run "ktlint installGitPrePushHook" if you wish to run ktlint on push instead):
java -jar ktlint.jar installGitPreCommitHook
But this will only allow you to set hook for your current command line session. If you close out of Command Prompt, the settings will be reset. If you want to have the ktlinter run on every session for your project, you have to add the java -jar ktlint.jar command to your project's .git/hook/pre-commit file and paste the ktlint.jar file into the .git/hook folder as well.
Download the ktlint jar ffile from the lib and add it in your project
Run java -jar ktlint on the command line
From that point and then gradlew ktlintCheck should work
Related
Getting error - 'gradlew' is not recognized as an internal or external command. operable program or batch file. inside Android Studio terminal.
Can anyone please tell why it's not recognizing gradlew
gradlew command is available in your project directory. If you are trying to run this command from somewhere else it will throw error.
Also gradlew command package is automatically generated by Android studio when you create a new project. It will also prompt you to generate new gradle wrapper when you open the project.
you have to use ./gradlew instead of gradlew , if you are using Mac or Linux
It's under the Android folder, so you have to do cd Android first from your project root folder, then :
PS C:\code\my_app\android> ./gradlew signingReport
in vscode do this step
go to your project directory
cd to android
type ./gradlew in your terminal instead of gradlew
voila, it works for windows user
Assume that you app's name is video_compresser, so when you open terminal on Windows PC(because I am trying this on Windows) it shows the prompt like this.
C:\Users\Nuwan\StudioProjects\video_compresser>
If you run gradlew from here you will get the below message
'gradlew' is not recognized as an internal or external command,
operable program or batch file.
so you have to go to android directory by typing cd android command from terminal.
then the prompt should be like this,
C:\Users\Nuwan\StudioProjects\video_compresser\android>
then type gradlew followed by other commands you need and the error should be gone.
Try using,
./gradle clean
./gradle assembleRelease
worked for me.
make sure you have debug.keystore file in
PS C:\code\my_app\android>
before you run
./gradlew signingReport
Instead of the powershell, use the Windows Command Prompt to run the command.
(This is an accidental finding. I used the visual studio code terminal to run the command gradlew assembleRelease to build the apk of a react-native project, but it outputs an error similar to above. I tried bash terminal, again failed to run. Out of curiosity, I used the Windows command prompt, then it worked. Hope this will help if other solutions are not working).
If you use powershell, and the gradlew file is in the terminal current work directory, try .\gradlew instead of gradlew. Powershell don't run the command in the current work directory automatically.
ionic cordova build android --prod --release --alias=cos-android --password=abcd --versionCode=00001 --versionName=00001 -- -- -- --packageType=bundle
cordova build android --prod --release --alias=cos-android --password=abcd --versionCode=00001 --versionName=00001 -- -- --packageType=bundle
gradlew command is only available in your project directory or gradlew file location. If you are trying to run this command from somewhere else it will throw error.
so go to that particular location where gradlew file available
go to android directory by typing
"cd android" in terminal.
then the prompt should be like this,
PS C:\src\offx> cd android
PS C:\src\offx\android>
(//then type) ".\gradlew signinReport"
PS C:\src\offx\android> .\gradlew signinReport
Then you will get your sha keys
I am using windows OS and have to run a Java project in IntelliJ. I used the command prompt in admin mode then it worked for me.
I am trying to set up continuous code integration with the help of jenkins v1.592
I have an android hybrid code, which I'm, trying to build with jenkins.
I have set up environment variables for ANT_HOME, JAVA_HOME, ANDROID_HOME, and added then to the PATH respectively. I also have added nodejs and npm to the PATH.
ant version 1.9.2
java version 1.8.0_25
npm version 1.4.28
cordova android version 3.5.1
C:\Users\userName>path
gives
C:\Users\userName\AppData\Roaming\npm;C:\Program Files\nodejs;C:\whateverElse...
jenkins $WORKSPACE = C:\Program Files (x86)\Jenkins\jobs\myProject\workspace\
now I set my cmd prompt to jenkins workspace and execute the following commands
cd myProject
cordova build android
I get BUILD_SUCCESSFUL after 24 seconds
Similarly, when I go to my local jenkins server
The jenkins dashboard is shown and I have set up myProject there and
in the project configuration I have added the lines
"cd myProject
cordova build android"
in the build step and saved the configuration.
When I try to build I get the following error
Started from command line by anonymous
Building in workspace C:\Program Files (x86)\Jenkins\jobs\myProject\workspace
Updating repository at revision '2014-12-02T15:20:23.437 +0530'
At revision 263
no change for repository since the previous build
[workspace] $ cmd /c call C:\Windows\TEMP\hudson3297478415472069526.bat
C:\Program Files (x86)\Jenkins\jobs\myProject\workspace>cd myProject
C:\Program Files (x86)\Jenkins\jobs\myProject\workspace\myProject>cordova build android
'node' is not recognized as an internal or external command,
operable program or batch file.
Build step 'Execute Windows batch command' marked build as failure
Archiving artifacts
Finished: FAILURE
Any help would be appreciated
The same issue exists on mac OSX
Best Regards
Several things can be at play here
Did you add node to %PATH% through command line, or through the Windows UI? If done through UI, it can take affect immediatelly. If done through command line, it doesn't take affect until the next process spawns from shell, therefore Jenkins server restart is required.
Jenkins runs as "Local System" by default on Windows. You are listing C:\Users\userName as part of your paths, i.e. a user specific path. Did you set the %PATH% for all users, or just for your user userName? If it's not set for all users (or a specific user that Jenkins runs with), then Jenkins won't see it. You can change what user the service runs as.
2a. If Jenkins is running as "Local System" user, does that account have access to C:\Users\userName?
And lastly, if you set the %PATH% from command line, did you set it as a permanent entry using setx command?
In either case, from your job configuration, add a build step "Execute Windows Batch Command" and type just set (to display all environment variables) or #echo %PATH% (to see just the %PATH%) and verify that the environment is set correctly
I read these instructions:
BaseGameUtils import using Eclipse
It says you need to run "make_eclipse_compat" script.
Stupid question: How do I run the script on windows?
I tried the following:
start key
cmd.exe (run as administrator)
cd c:\android-basic-samples-master\scripts
run make_eclipse_compat
But that writes not output (no error message either) and does not create the eclipse_compat folder.
I cannot simply double click the script as it has no file ending.
From looking at the file in text editor I'd say it looks rather like a batch file. But appending .bat and running that does not work either.
What is the correct way to run the script?
I looked into the file and the first line says #!/bin/sh
According to the internet that means it is a bourne shell script which you run using bash.exe
So I installed cygwin, copied bash.exe to the android-basic-samples-master folder,
then in cmd.exe executed
bash Scripts/make_eclipse_compat
and the script finished successfully.
Get rid of the run. In Windows, if there is a .bat script, you simple execute:
make_eclipse_compat
or
make_eclipse_compat.bat
In the directory that has the script.
I have been trying to get my head around using uiautomator and I understand creating the test cases. I tried the first two steps of building the JAR according the the Android developer guide for UI Testing (http://developer.android.com/tools/testing/testing_ui.html) and that worked fine, but I am unsure on how to follow the next steps and building the JAR file with ant. Please can anyone help me with this issue.
Here are the steps that I have done so far:
<android-sdk>/tools/android create uitest-project -n <name> -t 1 -p <path>
set ANDROID_HOME=<path_to_your_sdk>
This is the step that I am stuck on:
ant build
The error I get when I use the command prompt is:
'ant' is not recognized as an internal or external command, operable program or batch file.
In the terminal run
which ant
It seems you do not have ant installed. If no location like /usr/bin/ant shows up after you run the command above, use this to install it:
sudo apt-get install ant
Try again after. It should work.
If you're using ADT, I recommend downloading Apache ant and placing it within the sdk/tools/ant folder. Then change your PATH variable to direct to the ant bin folder.
you have this error because you wrote "ant build" from incorrect path.
I did (this command generate build.xml, local.properties, project.properties files):
<android-sdk>/tools/android create uitest-project -n <name> -t 1 -p <path>
I changed in build.xml first line like:
<project name="name" default="build">
after that I run ant from eclipse. Build was success.
Have you installed ant? If not then do it from this site: http://ant.apache.org/manual/install.html
If yes then follow these steps:
Navigate to your project directory and means (go to bin of your project)
Using command window execute the function: ant build
Ensure that your default JAVA_HOME points to JDK installation, not the JRE, and check if your compiler is in the PATH. Try to type “javac” in the command prompt. If javac is not found, then you should put your bin directory in the PATH.
For example, in Windows:
SET PATH=c:/jdk1.5.0_07/bin;%PATH%
This site might help further: http://looksok.wordpress.com/2014/02/08/uiautomator-in-eclipse/
If you have ADT with Eclipse then you can find ant in the plugins directory of Eclipse.
How can I build and signed (keystore) the .apk file using 'apkbuilder.bat' via windows command-line ?
I try to run the following line:
apkbuilder.bat %APK_File_Name% -u -z %Project_Path%\bin\resources.ap_ -f %Project_Path%\bin\classes.dex -rf %Project_Path%
but I'm getting the following exception:
java.lang.ArrayIndexOutOfBoundsException: 1
at com.android.sdklib.build.ApkBuilderMain.main<ApkBuilderMain.java:61>
Please help. Thanks
You can do it in command line (.bat) in windows using ant.
with:
"ant release"
You build the apk unsigned.
Then you need to add the call to "jarsigner" and "zipalign" in the bat to complete the task.
You can find an example of the command line to call these tools here:
http://developer.android.com/guide/publishing/app-signing.html#signapp
Best,
I would suggest using Ant and the build files generated by the Android tools rather than trying to handroll your own. If nothing else, you can use the build files as a reference to determine how it uses the various tools to perform each step.