Android studio - errors and errors

Hi,

 

At first I tried the android ant build. I was finally (after some tweaking) able to build my project for Android. I tried running the apk on some chinese tablet. After I clicked the icon, it always said the application stop working (don't know the exact error message in English, it is a czech language version). It happened immediately without even showing anything from the application. Well that was kind of too general a problem to ask here. So I decided I need some way to debug the code. I gave up ant build and installed Android studio. That's where the real troubles start. So far, I'd say that it is a pretty crappy software. It installed everything all over again - SDK and NDK, even though those already had been installed. So I ended up with 2 copies of SDK and NDK. Great. After some more tweaking I was able to finally run Android studio using this tutorial:

 

http://www.juce.com/doc/tutorial_android_studio

 

I proceeded with the steps until I came to the phase where you launch the application in emulator. Basically I found I am out of luck with x86 emulator as it only supports Intel processors. Great, although I have the highest AMD CPU I can possibly have, I just cannot run the emulator as it seemes to use Intel seciffic HW virtualization and the AMD virtualization instruction set can be used just on Linux based systems. Right. That is not a JUCE related problem of course.

 

I could probably use the ARM based emulator if I was able to build the project at all. Now this situation is pretty non-deterministic. And I cannot even describe what is wrong. When I open the project, the run button is grayed out in Android Studio. Also there is no rebuild button, which I would expect might solve this. There is only the make button, which just says everything is up to date (which is obviously not true). When I try to resave/reopen the project from the Introjucer, It also behaves pretty nondeterministic. There's about 50% chance the Introjucer will hang showing the saving popup. In this case I need to kill the Introjucer process from the TaskManager. By the way, if this happens it takes up 4 GB of memory. I am quite sure this is not an intended behaviour. In the remaining 50 % of cases, it opens Andoid Studio, but I get some other error like this:

 

Or I get this window:

And right after that the previous error message.

 

I also tried running introjucer as administrator, so it is able to create the symlinks. It did, but it still wouldn't open the project in Android Studio. If I open the Android studio and try to open the project from there it takes like 10 minutes and then I still cannot do anything as the run button is grayed and trying to make the project says it is up to date.

 

I know that this is kind of too general a problem but if you have any suggestions I might try, I would be greatful.

 

//Edit: I suppose the jucer project is somehow broken. If I create new Hello World GUI application and export it to Android studio it "just" doesn't compile (see bellow), but it is opened with no problems. I also tried removing the Android exporter from the project above, deleting the Android folder manually and adding it again but that does not help.

 

When I create a new GUI application I get these errors:

Error:(40, 57) ../juce_core/native/juce_BasicNativeHeaders.h: No such file or directory

Error:(43, 44) native/juce_BasicNativeHeaders.h: No such file or directory

... and so on for all the modules.

That relative path is strange because the JUCE library and the project are on a different drive. For example the first error is caused by this include:


#include "../juce_core/native/juce_BasicNativeHeaders.h"

included from app/src/main/jni/juce_gui_basics.cpp

Well, it is a symlink but my guess is that ../ relates to the symlink path and not to where it points.
 

 

It may have something to do with this problem (JUCE path containing space character):

http://www.juce.com/forum/topic/android-ant-build-bug/problem

 

Opening the project in Visual Studio is - of course - without any problems.

 

I'm on the latest tip.

 

//edit 2: After some reopening with Android Studio and Introjucer I managed to break the newly created project I was talking about as well. Now I get this window while trying to open the Android Studio project from Introjucer:

Now this error is definitelly related to this problem I mentioned in the first edit:

http://www.juce.com/forum/topic/android-ant-build-bug/problem

 

I think that you represent the spaces in the path in a wrong way. Please don't ignore this thread, this really needs to be fixed.

OK, created a duplicate JUCE directory that does not contain spaces in the path just to test this. It still throws compilation errors like this:

D:\Dokumenty\Projects\Vyuka\AndroidTest\Builds\AndroidStudio\app\src\main\jni\juce_core.cpp
Error:(43, 44) native/juce_BasicNativeHeaders.h: No such file or directory

There is one such error for each JUCE module. Well, all these juce_*.cpp are symlinks to the files in JUCE directory. But it cannot find the files and subdirectories within the target location. My guess is that this does not change the current directory and it searches for e.g.
native/juce_BasicNativeHeaders.h in the jni folder. Can anybody tell me, what should I do to fix this? I suppose I could force the Introjucer to make local copies of the files but I don't want to do that as I would have to recreate the project everytime I checkout a new version of JUCE (which is going to be quite often since this is about Android...)

 

P.S. Quite often when I try to open the Android Studio from Introjucer, I get the error message saying that it cannot load the .idea file and that it does not exist. In this case I need to delete the Android Studio exporter and add it again (which means setting everything all over again and it is very frustrating...).

Please, why do I get those compile errors. I am at my whits end...

There's about 50% chance the Introjucer will hang showing the saving popup. In this case I need to kill the Introjucer process from the TaskManager. By the way, if this happens it takes up 4 GB of memory.

This happens quite often. See here:

 

... but I could live with that. But the problems is I am still not able to compile anything in Android Studio. See above.

Hi Aros,

I'm looking into it right now, please have a little bit more patience.

Thanks I will be patient then. Now that I now you read the thread... I was just concerned nobody seemed interested in suggesting some things I could try.

One more thing might interest you. I got this error when I set the checkbox in Introjucer to make a local copy of the modules:

That does not make any sense... The part from Projects_TEMP and so on is a path to the project but it's of course not located in Java directory. It seems like it concatenates the JDK path and a part of the project path. Very strange. This is a new error. I think I now have the entire collection Android studio has to offer... :-)

 

Also the high memory usage and Introjucer freeze only seems to happen when there is an Android Studio exporter.

 

Hi Aros,

Unfortunately some of the screenshots you posted are not displayed here. This is a problem in the forum software. Would you mind posting a link to those image files instead of inserting them into your posts? Thanks & sorry.

Hi Aros,

semi-good news: I can now reproduce both of your problems, the whitespace thing and the "juce_BasicNativeHeaders.h" one. Unfortunately this is not something I can fix quickly right now (especially the second one - it's some problem with the way we have to generate those links on Windows). But I'll get back to it as soon as possible.

One piece of advice though: seriously, don't use Android Studio on Windows if you can avoid it. To be honest it just doesn't work very well. The recommendation is to run it on Ubuntu, in which case the emulator will also work fine with your AMD processor so you can kill two birds with one stone.

Thanks Timur,

I could probably install Ubuntu in VirtualBox if you think that helps. And I completely agree that Android Studio on Windows is a piece of crap. Seriously, nothing works as expected.

 

If I run Android Studio in VirtualBox will I be somehow able to debug the code or do you think I need "hard installation".

 

Thanks again

 

//Edit: Hm, would that actually help? Could I run the emulation which is in fact a virtual machine within virtualized Ubuntu? Something tells me this is not going to work...

It should work just fine. I am running Ubuntu in Parallels on my Macbook and it's awesome. I only ever open Android Studio on Windows if I have to look into issues like this one here ;-) Never tried the emulator myself though, so I guess you should just try!

Hi Aros,

I believe I just fixed those Android Studio Windows issues (it works here now, even if the project paths include whitespaces).

Unfortunately I can't push it right now, as we are preparing a larger JUCE update and as a result our JUCE master branch is currently not in a state where we could push it to github right now. We'll sort this during the next few days. Can I ask you to wait just a little bit more until we can roll out the update. Sorry for this!

Thanks you so much Timur. I'll try to run it in VirtualBox in the meantime then...

Hi,

while trying to build on Ubuntu (running in VirtualBox) I get this error in Android Studio while trying to compile:

 

Error:Execution failed for task ':app:processArmeabi-v7aDebugAndroidTestResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/aros/Android/Sdk/build-tools/23.0.1/aapt'' finished with non-zero exit value 127

I have absolutly no idea what this is about. I tried to google it but with no luck. I guess it has something to do with the emulator but I just don't know what's wrong. ARM EABI v7a System image is installed (at least the SDK manager says so) and anyway this is a compile time error so it should not be emulator related...

//edit: by the way this happens even if I try to clean or rebuild. aapt just always returns 127.

 

Any guess?

Thanks again

Well I have propably solved the Ubuntu gradle problem by installing lib32z1. I don't understand what exactly it had to do with gradle (again, I couldn't even make clean, so it didn't seem as compilation related problem) but I can build now. I can't launch any emulator though. There are none in the ComboBox, although I have installed many emulator images from the SDK manager. It is proably caused by the fact the Ubuntu itself is a VirtualMachine. I will make some more research...

 

Edit: Seems I am cursed somehow... I have created 2 new emulator devices (they are not there by default as on Windows version - don't know how), but the ARM emulator does not run because of some VirtualBox OpenGL bug (https://www.virtualbox.org/ticket/12941) and the x86 does not run because I cannot use HW accelerated virtualization within Virtual Machine (at least i think I cannot - in /proc/cpuinfo, hw acceleration is not listed).

 

Conclusion: On Windows I cannot build JUCE projects because of the Introjucer bug (hope to pull the updated version soon) and I cannot run x86 emulator because I have AMD processor. On linux I am finally able to build but I can launch no emulator at all because of some VBox bugs. The third option is probably installing a native Ubuntu. But I don't have a spare computer to do that at this point. And I had enough with dual bBoot not to try it again. Or I can swap HDDs in my main PC. Hm, I'll proably wait for the Introjucer fix and try to run the project in ARM emulator...

Hi Timur, aby progress on that fix commit? I guess you have a holiday at ROLI so no problem, I just don't want to miss the release :-)

Hi Aros,

Sorry for not answering immediately, yes I was away on holiday with no access to the internet.

I did push the fix commit before I left, and we did include it in the JUCE 4.1 release, so it should be working on the newest tip. Could you please check that?

Thanks, I will let you know...

Good news and bad news.

 

I am finally able to build&run on Windows with Android Studio. But it has several problems still:

First of all either the whitespace problem is still present or it is something else that has a similar result. The project doesn't build with the "juce_BasicNativeHeaders.h" problem described on the first page, if it is not on the same drive as JUCE modules (the difference is probably that the relative path cannot be used). It's a bit strange because from what you wrote, those two things did not seem to be the same problem. So if I have the project and the modules folder on the same drive (and therefore those whitespaces are hidden in something like ../../.. ), there is just one problem to get rid of. The Android Activity class name probably cannot contain underscores.

See here:

http://www.juce.com/forum/topic/android-activity-class-names-underscores-and-hair-loss

 

If i hadn't found that thread I would have probably lost some hair too... :-)  Could you please check whether this is a JUCE related or Gradle related problem? It the former, it should be fixed, if the latter, Introjucer should not let you name the Activity class that contains underscores (it should generate the name so that it does not contain them). I was not able to find anything else on the subject.

 

Thanks a lot Timur

 

Ehm, Timur?

I can confirm that the path related problems still persist in some form. If I have the JUCE modules folder on another drive than the project itself, i cannot build the project with the "juce_BasicNativeHeaders.h" problem. The problem is solved if I select the option to copy the JUCE modules in the project folder. If you need to me to perform some test to isolate the problem more specifically, just say the word...