'gradlew.bat' is not recognized as an internal or external command - react-native

So i am trying to start a react native android project in windows 10 based on the Getting Start React Native.
I am stuck at the last step->react-native run-android
ps: Im using genymotion for my android emulator marshmallow 6.0

Got it,
Add the file location to environment variable PATH
C:\Users\user\AppData\Local\Android\Sdk\tools\templates\gradle\wrapper

Another version of the #Kai Jie findings, that works for me.
Compiling previous answers I did the following to get Android SDK and gradle working (You need gradle working anyway to compile your Android project):
Prerequisites. You have gradle installed in the folders like I found on my computer. Please, check it:
C:\Program Files\Android\Android Studio\gradle\gradle-X.X\
Set a new system variable (Control Panel\System and Security\System Advance system ->settings->environment variables-system variables). Do not forget to change a gradle version.
GRADLE_HOME C:\Program Files\Android\Android Studio\gradle\gradle-X.X\
Add the following path to system paths (Control Panel\System and Security\System Advance system ->settings->environment variables-system variables):
%GRADLE_HOME%\bin
You might want to REBOOT your computer, to make sure, that the system sees the variables.
Check if gradle works properly with the terminal commands
$ gradle -v

If the environment variables are set. I found that you need to actually start gradle. Then you can use the gradlew command.
If you are learning from Spring.io. Their site says to just run
./gradlew build && java -jar build/libs/gs-spring-boot-0.1.0.jar
That will fail unless you first run
gradle
Intellij had me in the correct directory so I just deleted
./
and run
gradlew build && java -jar build/libs/gs-spring-boot-0.1.0.jar
The app started right up.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.6.RELEASE)

if your gradlew.bat file is being generated but delete itself after a few second than it's a problem of your android studio .
steps to follow :
1 . open your android studio and click on configure.
2. Go to setting there.
3.Click on Build,Execution,Deployment => Build Tools => Gradle.
4. check Gradle user home if it's pointing to .gradle file location or not .If it's not than give the correct path of .gradle file like this in my case C:/Users/Your_PC_Name/.gradle .
5. And than create new reactproject.

You probably have to do something like:
./gradlew assembleDebug

Add code below to the bottom of build.gradle file
task createWrapper(type: Wrapper) {
gradleVersion = '4.9'
};
then run gradle createWrapper in terminal
This will generate gradlew.bat file and corrospondinf gradlew files

in my case, I had a & sign in the name of the folder that I had put in the flutter project. removing it solved the problem for me.

Related

How to format code using IntelliJ format using a precommit hook?

I'm trying to configure a precommit hook to automatically format the code using IntelliJ code formatter.
Indeed, IntelliJ permit to run the formatter using the command line outside the IDE: https://www.jetbrains.com/help/idea/command-line-formatter.html
So I've created my precommit file:
git diff --name-only --cached --diff-filter=ACM | xargs -L 1 format
So to run format on each staged file. The problem is when I try to execute this command, the IDE shows an error message:
Message: Only one instance of IDEA can be run at a time.
Do you have an idea how to run format outside the IDE even leaving the IDE open?
You can automate the required instructions to allow running a separate instance:
cat >/tmp/format.properties <<EOF
idea.config.path=\${user.home}/.IntelliJIdea/format/config
idea.system.path=\${user.home}/.IntelliJIdea/format/system
EOF
git diff --name-only --cached --diff-filter=ACM | xargs env IDEA_PROPERTIES=/tmp/format.properties format
/tmp/format.properties: idea.properties location changes after each upgrade of IntelliJ.
In my case, I also retrieve format.sh location from idea command:
format_command=$(grep idea.sh $(which idea)|sed "s,idea.sh,format.sh,")
eval "env IDEA_PROPERTIES=/tmp/format.properties $format_command $(git diff --name-only --cached --diff-filter=ACM|xargs)"

java.io.IOException: Couldn't create PTY when opening the terminal in WebStorm

I am using WebStorm for an Angular project from past 6 months and suddenly now when I try to access terminal in WebStorm I am getting an error message
java.io.IOException: Couldn't create PTY
could not actually understand the cause of this.
This error occurs because the IDE is not finding the correct shell path for your installed git version.
To solve this, go to the File -> Settings -> Tools -> Terminal menu and change the Shell path based on the installed git version.
On Windows do:
for 64bit:
"C:\Program Files\Git\bin\sh.exe" -login -i
for 32bit:
"C:\Program Files (x86)\Git\bin\sh.exe" -login -i
Don't forget the quotes around the command.
And Linux:
/usr/bin/zsh,/usr/bin/bash or the Shell path for your system.

Use specific package name when setting up a react-native project

When creating a react-native app with react-native init MyApp the Android and iOS package names are automatically set to com.myapp.
Changing the Android package name (especially if you need something longer like com.organisation.propject.app) later in the development is pretty fiddly and I was wondering if there was a way to set the package name when setting up a project with react-native init?
Note: it's working only in RN 0.37 and maybe one or two versions up, in 0.40+ this feature was removed.
You need to specify a --package option:
$ react-native init MyApp --package=com.organization.project.app
The below worked for me. Substitute your own app name for "Foo App" and your own package name for org.newpackage.app.
NEW_APP_NAME="Foo App"
NEW_PACKAGE_NAME=org.newpackage.app
OLD_PACKAGE_NAME=org.reactjs.native.example
npx react-native init rndemo && \
cd rndemo && \
npx react-native-rename "${NEW_APP_NAME}" -b ${NEW_PACKAGE_NAME} && \
rm -rf ios/Pods && \
pod install --project-directory=./iOS && \
grep -rl ${OLD_PACKAGE_NAME} * | \
xargs sed -i '.bak' "s/${OLD_PACKAGE_NAME}/${NEW_PACKAGE_NAME}/g"
I've created a gist that does this, prompting interactively for the app name and package name. The gist is a tiny bit more sophisticated, in that (in the above example) it would initially create the app fooapp instead of rndemo.
Explanation:
Create a react-native app. It's called rndemo temporarily; we need to know what it's going to be called so we can change to it.
Run react-native-rename to rename the new project to whatever you specified; this lets us replace the package name too.
Remove the installed cocoa pods and reinstall them (so they'll pick up the new folder locations etc).
Search for the default package name org.reactjs.native.example and replace it with your new package name. Currently this will only find ios/FooApp.xcodeproj/project.pbxproj. The old project.pbxproj file will be saved with a '.bak' extension. This step would probably be better done with find . -name project.pbxproj -exec ..... but this was good enough for my needs.

Jython 2.7b4 will not webstart: ImportError: No module named site

I injected my application into jython-standalone-2.7-b4.jar. Here is what I see in the webstart console of the client machine when I webstart my app:
Java Web Start 11.31.2.13
Using JRE version 1.8.0_31-b13 Java HotSpot(TM) 64-Bit Server VM
User home directory = C:\Users\me
...
#### Java Web Start Error:
#### null
When I click on 'Details', I find the following exception stack trace:
ImportError: No module named site
at org.python.core.ImportError(Py.java:328)
at org.python.core.imp.import_first(imp.java:842)
at org.python.core.imp.load(imp.java:695)
at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:118)
at org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:94)
at org.python.util.InteractiveInterpreter.<init>(InteractiveInterpreter.java:39)
at org.python.util.InteractiveInterpreter.<init>(InteractiveInterpreter.java:28)
at org.python.util.InteractiveConsole.<init>(InteractiveConsole.java:67)
at org.python.util.InteractiveConsole.<init>(InteractiveConsole.java:53)
at org.python.util.InteractiveConsole.<init>(InteractiveConsole.java:33)
...
Jython2.7b1 worked for me. I tried Jython2.7b3, but that fails as well.
Due to class loader differences in the Web Start environment, Jython can't find the files in the Lib directory inside the standalone jar file. To fix this, you need to rearrange the contents of the standalone jar a bit. The following script will convert a standalone jar into something workable in a Web Start environment:
#!/bin/sh
# Converts a Jython standalone jar into something usable with Java Web Start
if [ -z $1 ]; then
echo "Please give the path to the standalone jar as the first argument."
exit 1
fi
CURRDIR=$(pwd)
JAR_PATH="$CURRDIR/$1"
CONVERTED_JAR_PATH="$CURRDIR/jython-webstart.jar"
TEMPDIR=$(mktemp -d)
cd "$TEMPDIR"
jar xf "$JAR_PATH"
rm -rf Lib/test # including Jython's own unit tests is pointless
java -jar "$JAR_PATH" -m compileall Lib
find Lib -name "*.py" -delete
mv Lib/* .
rmdir Lib
jar cf "$CONVERTED_JAR_PATH" *
rm -rf "$TEMPDIR"
Next you'll probably run into Jython bug 2283. To work around it, set the python.home system property to point to any existing directory.

Installing manually PHPDocumentor on Mac

After trying to install PHPDocumentor with PEAR install with no success, i tried it manually as is detailed on the official website: http://www.phpdoc.org/docs/latest/for-users/installation.html
I downloaded the files and i make an alias on /usr/bin/ but when i try to execute phpdoc.php via terminal y it shows an error.
This is what i try:
> cd /usr/bin/
> ./phpdoc.php
And this is the error:
PHP Warning: include_once(/Applications/MAMP/htdocs/phpdocumentor/src/phpDocumentor/../../vendor/autoload.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/phpdocumentor/src/phpDocumentor/Bootstrap.php on line 72
PHP Warning: include_once(): Failed opening '/Applications/MAMP/htdocs/phpdocumentor/src/phpDocumentor/../../vendor/autoload.php' for inclusion (include_path='/Applications/MAMP/bin/php/php5.3.6/lib/php/:/Applications/MAMP/bin/php/php5.3.6/lib/bin/') in /Applications/MAMP/htdocs/phpdocumentor/src/phpDocumentor/Bootstrap.php on line 72
PHP Fatal error: Class 'phpDocumentor_Task_Runner' not found in /Applications/MAMP/htdocs/phpdocumentor/bin/phpdoc.php on line 37
I am using Mac Os X and as you can see, i use MAMP to run Apache.
What's going on here? Why it tries to open a file which doesn't exist? (because it really doesn't exist inside PHPDocumentor folder)
Thanks.
Did you try :
curl -s http://getcomposer.org/installer | php
php composer install
on phpdocumentor2 directory (you should find composer.json)
Composer is a dependency manager for php. So it will populate phpdocumentor projet with external/vendor dependencies
Try this to install Composer into your MAMP php bin:
cd yourapp/ && curl -s http://getcomposer.org/installer | /Applications/MAMP/bin/php/php5.3.6/bin/php