JAVA_HOME is not defined correctly.



  • I'm using Ubuntu 12.04 and I installed ant with
    @apt-get -u install ant@
    When I try to run my app in the android emulator I get this output:

    @20:59:48: The process "/usr/bin/make" exited normally.
    20:59:48: Copy Qt app & libs to Android package ...
    20:59:49: Creating package file ...
    20:59:49: Package deploy: Running command '/usr/bin/ant clean debug'.
    Error: JAVA_HOME is not defined correctly.
    We cannot execute /etc/java-6-openjdk/bin/java
    Packaging Error: Command '/usr/bin/ant clean debug' failed.Exit code: 1
    Error while building/deploying project Test (kit: Android for arm (GCC 4.6, Qt 5.1.1))
    When executing step 'Packaging for Android'
    20:59:49: Elapsed time: 00:05.@

    I read it's a java problem. I'm not an expert but, if the problem is Java, why I can run correctly java software (Eclipse)?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Disclaimer: I'm not yet proficient in Qt Android build

    Did you check the value of JAVA_HOME in your Build Settings ?



  • Thanks :)
    I search around and I try to execute ant form terminal and then I read that my JAVA_HOME was not set.

    So I installed JDK with
    @sudo apt-get install openjdk-6-jre@

    then I set
    @export JAVA_HOME="/usr/lib/jvm/java-6-openjdk-amd64;"@

    and now I have an ant problem:
    @ant
    Buildfile: build.xml does not exist!
    Build failed@

    and when I try from Qt-Creator to run my project I get
    @Error while building/deploying project Test (kit: Android for arm (GCC 4.6, Qt 5.1.1))
    When executing step 'Deploy to Android device'@


  • Lifetime Qt Champion

    You should not have a semi-colon in your JAVA_HOME path.

    Did you set it globally ? i.g. in your .profile file ?

    If not, it won't be available to program run outside the console where you set it.



  • I'm sorry, what and where I have to write....

    I hate java but I used it for 4 months for university in an other ubuntu installation without any of these problems...


  • Lifetime Qt Champion

    Since you just installed it, you could try to just logout/login to check wether your environment has been properly updated.



  • I removed java 6, reinstalled java 7 and then logout/login

    I retry and I get
    @23:26:32: The process "/usr/bin/make" exited normally.
    23:26:32: Copy Qt app & libs to Android package ...
    23:26:33: Creating package file ...
    23:26:33: Package deploy: Running command '/usr/bin/ant clean debug'.
    Error: JAVA_HOME is not defined correctly.
    We cannot execute /etc/java-7-openjdk/bin/java
    Packaging Error: Command '/usr/bin/ant clean debug' failed.Exit code: 1
    Error while building/deploying project Test (kit: Android for arm (GCC 4.6, Qt 5.1.1))
    When executing step 'Packaging for Android'@

    So I have to set JAVA_HOME.
    Now, I have to add:

    @export JAVA_HOME=/usr/lib/jvm/SOMETHING@

    But something what? I post the content of /usr/lib/Jvm
    @default-java java-1.7.0-openjdk-amd64 java-6-openjdk-common
    java-1.6.0-openjdk java-6-openjdk java-7-openjdk-amd64
    java-1.6.0-openjdk-amd64 java-6-openjdk-amd64 java-7-openjdk-common
    @

    and then, I have to add the line in which file? .bashrc? .profile?

    Thank you for the help....


  • Lifetime Qt Champion

    Did you check the JDK location in Options -> Android from QtCreator ?



  • It's set to /etc/java-7-openjdk but there are not a bin folder in it and that's probably why I get

    @Error: JAVA_HOME is not defined correctly.
    We cannot execute /etc/java-7-openjdk/bin/java@

    So is that what I have to change? Change in what?


  • Lifetime Qt Champion

    Change it to point to the folder where you have your java executable installed



  • Now the problem is elsewhere

    @BUILD FAILED
    /home/andrea/Android/adt-bundle-linux-x86_64-20130911/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
    /home/andrea/Android/adt-bundle-linux-x86_64-20130911/sdk/tools/ant/build.xml:734: Unable to find a javac compiler;
    com.sun.tools.javac.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to the JDK.
    It is currently set to "/usr/lib/jvm/java-6-openjdk-amd64/jre"

    Total time: 1 second
    Packaging Error: Command '/usr/bin/ant clean debug' failed.Exit code: 1
    Error while building/deploying project Test (kit: Android for arm (GCC 4.6, Qt 5.1.1))
    When executing step 'Packaging for Android'
    23:57:23: Elapsed time: 00:03.@



  • Maybe I should remove and reinstall java and all the components that I need to compile for android...


  • Lifetime Qt Champion

    Where is javac to be found ?


  • Moderators

    Can you post what you get when you fire "which java" command from the terminal ?



  • Ok, so:

    @$ which java
    /usr/bin/java
    @



  • If I retry from QtCreator, from Compile Output everything seems ok but I get:

    Application Output
    @Starting remote process.Unable to start 'org.qtproject.example.Test'.@


  • Moderators

    i think you also need to install the jdk.
    Try @apt-get install openjdk-6-jdk@



  • Yep it's installed:

    @sudo apt-get install openjdk-6-jdk
    [sudo] password for andrea:
    Lettura elenco dei pacchetti... Fatto
    Generazione albero delle dipendenze
    Lettura informazioni sullo stato... Fatto
    openjdk-6-jdk è già alla versione più recente.
    0 aggiornati, 0 installati, 0 da rimuovere e 0 non aggiornati.
    @


  • Moderators

    Try setting JAVA_HOME to "/usr/lib/jvm/java-6-openjdk-amd64/bin"
    As it contains both javac and java (symbolic link to ../jre/bin/java )



  • Ok so I have to add
    @export JAVA_HOME="/usr/lib/jvm/java-6-openjdk-amd64/bin"@

    but where? in .profile? .bashrc?
    Thanks


  • Moderators

    Yup. try in bashrc or /etc/environment



  • Done. Now if I run...

    "Application Output":http://pastebin.com/eqJCfW9p

    "Compile Output":http://pastebin.com/bGSZmun5

    I think it's not a Java problem anymore...



  • I'm not understanding anything.

    Last update, every time I click on "run" I get

    Application Output:
    @Starting remote process.Unable to start 'org.qtproject.example.Test'.@

    and General Messages
    @Could not read qmake configuration file /home/andrea/Qt5.1.1/5.1.1/android_armv7/mkspecs/android-g++/qmake.conf.@

    Maybe this is the problem now, I've never checked this tab before...


  • Moderators

    Well from the compile output it seems that the APK has been created
    @/home/andrea/Code/QML/Test/android/bin/Test-debug.apk@
    But on deployment to the emulator it crashes due to some OpenGL issues.
    I donot have much detailed idea about this.
    But just try to deploy this APK on a physical device and see if it works.



  • I tried in a physical device and it works!!!!!!!

    But I can't reupload the apk every time to check if it's working well....so maybe I should open a new topic for this issue, what do you think?

    Thanks a lot for the help!


  • Moderators

    Yes. You can try asking in new post with appropriate details



  • I've done it, thanks all for the help



  • I also struggled with the "Buildfile: build.xml does not exist!". It was because I only installed openjdk-7-jre. openjdk-7-jdk is also required.

    Qt Creator kept saying "/usr/lib/jvm/java-7-openjdk-i386" was invalid for the JDK location. I guess it looks for something that openjdk-7-jdk puts in the /usr/lib/jvm/java-7-openjdk-i386. After installing openjdk-7-jdk, Qt Creator was happy with the location.

    (Using Kubuntu 14.04, JAVA_HOME set in /etc/enviroment)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.