How a correct setup of Android Studio plus Java environment should be made?

I'm getting software conflict errors such as Gradle could not find the path to the JDK.
After much research and trial & error experiments I've gained more knowledge but still didn't get a straight solution to how that setup should be done correctly.

I've tried several software/settings combinations, hacks and answers I found on Stack Exchange and such sites. But then other issues pop up (and a Gradle scan shows more of them) and what is needed is the correct explanation of how that should be done to build a robust environment the way it was meant to be by the developers.

Android Developer site, the official site from which to download Android Studio, doen't state there's a need for additional JDK/JRE installation, and I also found within Studio a differed version than the latest and no JDK (which is the one that, as I understand, Studio actually needs).
C:\Program Files\Android\Android Studio\jre

I'm using the latest versions on a Windows 8.1 on a Lenovo Y50-70 (64 bit, 16GB RAM):
Android Studio 3.1.2
Gradle 4.4 through Gradle plugin 3.1.2
JDK 10.0.2 (Oracle states it includes the JRE).

I've already installed and uninstalled a couple of times and wouldn't like to further mess up anything (OS registry etc.), what's needed is an experienced expert on-point advise.

Thanks in advance.
Sam ElfassyFreelancerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
The script (not Windows) which starts Android Studio for me sets both ANDROID_HOME and JAVA_HOME (the installation directory of JDK 10)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sam ElfassyFreelancerAuthor Commented:
@CEHJ
Thank you! That seems to be the exact right solution. Please excuse my 'noobity', unfortunately I still need and would appreciate a few details, if possible. How is that done (it doesn't seem to be an automatic default for many developers)? Which script is that? Did you have to modify it? And if yes then how? Does a separate installation of the JDK is certainly needed in addition to the Studio one?
0
CEHJCommented:
Which script is that?
It's a bash script i wrote myself. You could get away with setting both those environment as global ones in Windows
Does a separate installation of the JDK is certainly needed in addition to the Studio one?
tbh, i don't know but i just installed one anyway so i'd have the latest
0
Sam ElfassyFreelancerAuthor Commented:
Thanks CEHJ.
I've added  JAVA_HOME="C:\Program Files\Java\jdk-10.0.2\bin"  to the path and it solved that issue. Now to the rest of them.
Have a great day.
0
CEHJCommented:
JAVA_HOME="C:\Program Files\Java\jdk-10.0.2"

Open in new window

PATH="C:\Program Files\Java\jdk-10.0.2\bin";<rest of PATH here>

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Software

From novice to tech pro — start learning today.