Compilation problems

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
636
Did you try loading your project from within Android Studio? I opened it and it updated the gradle plugin and after that it compiled in android studio and ran fine and I didn't install any jdk.
Maybe we can somehow change the target to make it use the android studio jdk instead of the system default one.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
Followed it, It's strange to use bash I thought because Big Sur uses zsh as standard.
OpenJAVA 15 had security issues so it's taken down, but I picked the newer version but..

Still the same error! Enough for one day :mad: I'm a doctor not a bricklayer I shouldn't have to do this whatever this is.It's not programming anyway.

I'm not sure what to try next but it might be a complete re-install of macOS. I need this system so it might take a while.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
If I load build.gradle into Android Studio, it actually complains about version

Unable to start the daemon process.

The project uses Gradle 4.6 which is incompatible with Java 11 or newer.

Possible solution:
- Upgrade Gradle wrapper to 4.8 version and re-import the project
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
636
Just load the whole build/android folder as a project in Android Studio.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
If I understand correctly it wouldn't help to re-install Android Studio once again and it seem to compile perfectly alone as long as I don't import anything from Cerberus.

So, it is something to do with macOS and JAVA? But then again when I try to import the whole Android folder that Cerberus compiled (after I've uninstalled the Open JAVA16 failure and making sure that I reinstalled JAVA 8 JDK again, v301 which I know works... then this happens , I include a pic.

This time I won't update grade because that's not a solution and I don't have JAVA 11 or newer.
So the error must be an OS path being set to an old JAVA16?
But that does not make sense either because this all started when I updated macOS. I did nothing else.

I had the newest Android Studio, maybe an update happened.. and maybe that slight update might be the havoc but I don' t think so. I still had a working JAVA environment, and Android Studio, nothing touched.

I don't like Big Sur..

Screenshot 2021-08-16 at 13.28.28.png
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
If one looks at the error again :

> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

I'm now thinking; what if I force the path that CX complains about (which is a USER PATH btw and it SHOULD be empty) to a GLOBAL path (one which has JAVA) , maybe then it would work? Where can I set this path?
 

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
840
maybe then it would work? Where can I set this path?
In the hidden file located in the USER HOME directory. Used to be called .bashrc or .profile, but as apple have move to zsh from bash, it will be .zshrc. It may note exist by default, so edit it from the command line using nano ~/.zshrc or use Visual Studio Code.
DO NOT EDIT ANY FILE WITH THE DEFAULT TEXT EDITOR APPLICATION THAT COMES WITH MAC OS X UNLESS YOU KNOW HOW TO SET THE QUOTATION MARKS TO THE DEFAULT ASCII.

All you do is add something to the end of this file like:
export JAVA_HOME="path-to-root-director-of-jdk"
export PATH="$JAVA_HOME:$JAVA_HOME/bin:$PATH"

If you need a version of openJDK, then try
 
Last edited:

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
Learning a lot about JAVA today.

Was JAVA this programming language meant to easily be run everywhere? Sigh WHY so many VERSIONS..

JAVA does not want to run. We have to respect its wishes.
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
636
Was JAVA this programming language meant to easily be run everywhere?
I also don't like these kind of problems. That is why I am looking into how to make our gradle work with the inbuild jdk of android studio. If android studio can use it with a cx project, we should also be able to.
 

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
840
sudo apt install openjdk-8-jdk
Not for Mac OS X. And Linux has it's own versions of openJDK in the repositories.
For Linux, you'd only download a previous version if needed and manually set it up by editing the .bashrc/.profile to include the JDK bin directory in the PATH variable.

If you've installed Oracle's JDK/JRE for Mac OSX. It will usually be distributed as a .pkg file, which is Apples attempt at a package installer.
These are Oracles instruction for removing JDK 7,8.

To deal with the .pkg installs. There is the command line pkgutil.

NOTE: With Cerberus, gradle cache on Linux is in the hidden .gradle in the user home directory. I think Mac OSX does the same, but I cannot double check on that.

That is why I am looking into how to make our gradle work with the inbuild jdk of android studio.
Simple solution would be add another CONFIG variable to the host-config.txt files that give the end user the choice to set their own location for gradle. So transcc parses the host config file and it's not set or valid, then it uses the default. If it's set, then make sure that it set up the correct paths to be added to the shell's PATH environment to execute gradle. EDIT: Scratch that. It wouldn't work.
 
Last edited:

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
I think Mac OSX does the same, but I cannot double check on that
I think Android Studio got a menu for that.. "empty cache and restart", but I tried it several times after making various changes. I don't think that the left arm know what the right arm does when it comes to JAVA and mac..

I also don't like these kind of problems. That is why I am looking into how to make our gradle work with the inbuild jdk of android studio. If android studio can use it with a cx project, we should also be able to.
That would be so good. If you need to do experiments let me know I can sacrifice my Android Studio i don't use it except for cerberus anyways.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
There so much knowledge here!
Got it to work!!

What I did was, i first did a terminal command

/usr/libexec/java_home -V
And then I picked the version I know worked before, it might work with others but i picked v301'which I felt good about.

I deleted all the others using the command
sudo rm -rf jdk-11.0.12.jdk or whatever the name of yours will be that you want to delete.

I checked again, and when I had only one of them I made sure that the .bash_profile was set to the same, then I edited it by manually browsing to the user folder and toggling hidden files using shift + cmd + . (dot)
I dragged the profile file onto visual studio code, edited it and saved it. Then I toggled back hidden files mode using the same keys.

Now it works!
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
Thank you all so much!
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
I think that for using the JDK that used to be
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home and then java -version

I tried that but saw that there were no jdk it went directly to /Contents.

This changed happened with Arctic fox but not only that, the M1chip version and the Intel version are differen.
The new general way get inbuilt JDK I think is

cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
636
Simple solution would be add another CONFIG variable to the host-config.txt files that give the end user the choice to set their own location for gradle. So transcc parses the host config file and it's not set or valid, then it uses the default. If it's set, then make sure that it set up the correct paths to be added to the shell's PATH environment to execute gradle. EDIT: Scratch that. It wouldn't work.
Hm... Here it worked. I just had to add the config variable to transcc for macos to setenv JAVA_HOME.
What are your concerns?
 

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
840
@Phil7: I miss read what you had posted and was thinking of gradle.
transcc needs to be modified in the LoadConfig() method in the case/select for the macos host section to include.
Code:
If JDK_PATH path=JDK_PATH+"/bin;"+path    '    Make sure that the selected JDK is called before any system wide install.
SetEnv "PATH",path
If JDK_PATH SetEnv "JAVA_HOME",JDK_PATH

It's just a case then of setting JDK_PATH to the root directory of the JDK to whatever the end user installs.
e.g.
JDK_PATH="/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home"
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
I narrowed it down to that Big Sur needs JAVA_HOME to already be a valid JDK *or totally unset* for /usr/lib/java_home to output something sensible. If one of these criteras is not fulfilled it will only output /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home, which of course has no working JDK.

Unsetting before is a good idea therefore

unset JAVA_HOME
export JAVA_HOME=$(/usr/libexec/java_home -v "11.0.8")
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
So if I understood the whole situation correctly now

It used to be possible to just say :
export JAVA_HOME=/usr/libexec/java_home -v 1.8

but this broke in Big Sur

I solved this manually by picking what I thought was a working installed JDK using /usr/libexec/java_home -V (a complete list always works)
and then I edited ~/.bash_profile like so :
export JAVA_HOME=/Library/Java/JavaVirtualMachines/<your java version>/Contents/Home

You could do it automatically (proper way) like this
unset JAVA_HOME
export JAVA_HOME=/usr/libexec/java_home -v 1.8

So you can ask for all JAVA versions on a system once again, as long as you remember to unset JAVA_HOME before asking the path for another JAVA version.

Why Apple have not fixed this during a course of 6months+ I'm not sure, is it intentional??
 
Last edited:

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
840
Why Apple have not fixed this during a course of 6months+ I'm not sure, is it intentional??
From what I understand it was in v11.0.2.

As you are executing a command to set JAVA_HOME. The command line needs to be wrapped with back ticks. e.g.
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
 
Top Bottom