Android Studio

Hi

Trying to get an app to compile on Android. ios was super easy with the introjucer but Android is proving a bit more fiddely.

As I understand it exports files for Eclipse?

But on the android website it now says:

http://developer.android.com/tools/help/adt.html

Note: If you have been using Eclipse with ADT, be aware that Android Studiois now the official IDE for Android, so you should migrate to Android Studio to receive all the latest IDE updates. For help moving projects, see Migrating to Android Studio.

So is are there any plans to make the Introjucer export files that open straight away in Android Studio (like in vs or xcode)

Or are there a straight forward way to import a project to Android Studio and update all paths etc..

 

Nikolai

The easiest way is to use the command line tools. Make sure you've set the correct paths to your Android SDK and NDK in Introjucer, and then

  1. Navigate to Builds/Android
  2. Run "ant debug" or "ant release" (I always run in release mode as debug compile runs a lot slower)

I do almost all my debugging in Xcode. 

Thank you for getting back to me.

Yes since Eclipse is beeing faded out by android, and Android Studio vs Juce is not yet easy I have been trying all day to compile in using different guides on the net. Including Ant.

So here is what I did:

I´m on OSX, I have the SDK and the NDK, I have set the paths in Introjucer, and I have set the Juce module path (also tried with "Copy mode")

So I go to terminal, the android folder, type ant release (or debug or clean debug)

and this is the result, same with juce demo.

I have though been able to compile and run other andoid apps (non juce) from Android studio and run on emulator.

Copy from Terminal:

 

$ ant release

Buildfile: /Users/Nikolai/Documents/MyMobileApp/Builds/Android/build.xml


-set-mode-check:


-set-release-mode:


-release-obfuscation-check:

     [echo] proguard.config is ${proguard.config}


-pre-build:

     [exec] [armeabi] Compile++ thumb: juce_jni <= MainComponent.cpp

     [exec] [armeabi] Compile++ thumb: juce_jni <= Main.cpp

     [exec] In file included from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/juce_core.h:164:0,

     [exec]                  from ../../JuceLibraryCode/modules/juce_core/juce_core.h:7,

     [exec]                  from ../../JuceLibraryCode/JuceHeader.h:17,

     [exec]                  from jni/../../../Source/MainComponent.h:24,

     [exec]                  from jni/../../../Source/MainComponent.cpp:23:

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h: In function 'bool juce::juce_isfinite(NumericType) [with NumericType = float]':

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h:360:27: error: 'isfinite' was not declared in this scope

     [exec]      return isfinite (value);

     [exec]                            ^

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h:360:27: note: suggested alternative:

     [exec] In file included from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/system/juce_StandardHeader.h:69:0,

     [exec]                  from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/juce_core.h:144,

     [exec]                  from ../../JuceLibraryCode/modules/juce_core/juce_core.h:7,

     [exec]                  from ../../JuceLibraryCode/JuceHeader.h:17,

     [exec]                  from jni/../../../Source/MainComponent.h:24,

     [exec]                  from jni/../../../Source/MainComponent.cpp:23:

     [exec] /Users/Nikolai/Documents/SDKs/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/include/cmath:596:5: note:   'std::isfinite'

     [exec]      isfinite(_Tp __x)

     [exec]      ^

     [exec] In file included from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/juce_core.h:164:0,

     [exec]                  from ../../JuceLibraryCode/modules/juce_core/juce_core.h:7,

     [exec]                  from ../../JuceLibraryCode/JuceHeader.h:17,

     [exec]                  from jni/../../../Source/MainComponent.h:24,

     [exec]                  from jni/../../../Source/MainComponent.cpp:23:

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h: In function 'bool juce::juce_isfinite(NumericType) [with NumericType = double]':

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h:372:27: error: 'isfinite' was not declared in this scope

     [exec]      return isfinite (value);

     [exec]                            ^

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h:372:27: note: suggested alternative:

     [exec] In file included from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/system/juce_StandardHeader.h:69:0,

     [exec]                  from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/juce_core.h:144,

     [exec]                  from ../../JuceLibraryCode/modules/juce_core/juce_core.h:7,

     [exec]                  from ../../JuceLibraryCode/JuceHeader.h:17,

     [exec]                  from jni/../../../Source/MainComponent.h:24,

     [exec]                  from jni/../../../Source/MainComponent.cpp:23:

     [exec] /Users/Nikolai/Documents/SDKs/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/include/cmath:596:5: note:   'std::isfinite'

     [exec]      isfinite(_Tp __x)

     [exec]      ^

     [exec] In file included from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/juce_core.h:164:0,

     [exec]                  from jni/../../../Source/../JuceLibraryCode/modules/juce_core/juce_core.h:7,

     [exec]                  from jni/../../../Source/../JuceLibraryCode/JuceHeader.h:17,

     [exec]                  from jni/../../../Source/Main.cpp:11:

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h: In function 'bool juce::juce_isfinite(NumericType) [with NumericType = float]':

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h:360:27: error: 'isfinite' was not declared in this scope

     [exec]      return isfinite (value);

     [exec]                            ^

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h:360:27: note: suggested alternative:

     [exec] In file included from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/system/juce_StandardHeader.h:69:0,

     [exec]                  from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/juce_core.h:144,

     [exec]                  from jni/../../../Source/../JuceLibraryCode/modules/juce_core/juce_core.h:7,

     [exec]                  from jni/../../../Source/../JuceLibraryCode/JuceHeader.h:17,

     [exec]                  from jni/../../../Source/Main.cpp:11:

     [exec] /Users/Nikolai/Documents/SDKs/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/include/cmath:596:5: note:   'std::isfinite'

     [exec]      isfinite(_Tp __x)

     [exec]      ^

     [exec] In file included from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/juce_core.h:164:0,

     [exec]                  from jni/../../../Source/../JuceLibraryCode/modules/juce_core/juce_core.h:7,

     [exec]                  from jni/../../../Source/../JuceLibraryCode/JuceHeader.h:17,

     [exec]                  from jni/../../../Source/Main.cpp:11:

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h: In function 'bool juce::juce_isfinite(NumericType) [with NumericType = double]':

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h:372:27: error: 'isfinite' was not declared in this scope

     [exec]      return isfinite (value);

     [exec]                            ^

     [exec] /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/maths/juce_MathsFunctions.h:372:27: note: suggested alternative:

     [exec] In file included from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/system/juce_StandardHeader.h:69:0,

     [exec]                  from /Users/Nikolai/Dropbox_Personal/Programering/JUCE_lib/modules/juce_core/juce_core.h:144,

     [exec]                  from jni/../../../Source/../JuceLibraryCode/modules/juce_core/juce_core.h:7,

     [exec]                  from jni/../../../Source/../JuceLibraryCode/JuceHeader.h:17,

     [exec]                  from jni/../../../Source/Main.cpp:11:

     [exec] /Users/Nikolai/Documents/SDKs/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/include/cmath:596:5: note:   'std::isfinite'

     [exec]      isfinite(_Tp __x)

     [exec]      ^

     [exec] make: *** [obj/local/armeabi/objs/juce_jni/__/__/__/Source/MainComponent.o] Error 1

     [exec] make: *** Waiting for unfinished jobs....

     [exec] make: *** [obj/local/armeabi/objs/juce_jni/__/__/__/Source/Main.o] Error 1


BUILD FAILED

/Users/Nikolai/Documents/MyMobileApp/Builds/Android/build.xml:23: exec returned: 2


Total time: 3 seconds

 

Can anyone make any sense of this ?

Yes you need to update your JUCE version I had this error a couple weeks ago! 

 

http://www.juce.com/forum/topic/error-isfinite-was-not-declared-scope

Thanks for pointing that out.

Sorry rookie mistake to not check the git, but I just assumed I did something wrong.

It compiles now, although it seems to be picky on the folder structure. (helps with no spaces in folder names).

No I need to figure out how to run this thing in an emulator.

I wouldn't bother with an emulator personally...  The Android emulator is notoriously slow.  Get a real device to test with.  

I found emulation to be feasible if you compile your Android app as x86: in the Introjucer, go to the Debug or Release config pane and add x86 to "Architectures". In the android emulator, setup a new device with an x86 processor. Works very well on my laptop albeit OpenGL ES functions are known to not always work on Intel GPUs.

Hey Fabian

You seem to imply that we actually *can* use Android Studio (not command line) to generate a runnable app (on a physical device ?)

Could you save us poor mortal developers a few hours (days ?) and let us know the procedure ? I was able to compile and run it using command line from the IntroJucer project. This is great. But it would be even greater if we could use Android Studio IDE...

Please ?

:)

 

P.S. I was able to compile and generate the apk but get a "Unfortunately, JuceDemo has stopped" window when I launch it on my Nexus 10. Again the same code runs fine using "ant release" command line. Any particular trick to know ?

P.S.2 I am running A.S. on a Mac (10.10.2) with the latest version of Juce from GitHub. I did set the right paths for sdk and ndk...

Hi Alan,

I'm not using Android Studio. I only have the command line tools installed (which also includes the emulator).

Do I understand you correctly that the JuceDemo runs with "ant release" but not with "ant debug"? One reason for this migh be that JUCE is hitting an assertion. Assertions are disabled in release builds so wouldn't show up there. To investigate, you need to use the ndk debugger ndk-gdb which is located in the NDK folder. You need to invoke this from within your android's project build folder (the folder where you type-in ant release). Use ndk-gdb --start to automatically launch your app on the phone. Obviously, the JUCE demo should run on the Nexus 10 so I would be interested in what you find (the JUCE demo works fine on our Samsung Galaxy Nexus test device and on a "virtual" Nexus 10 device within the emulator). 

Also, I strongly recommend adding x86 to the list of architectures for the debug build and to do your debugging and testing in a "virtual" x86 android device in the emulator. x86 devices run very smoothly (with OpenGL support) inside the android emulator.

Does this help?

Fabian

Thank you for the answer Fabian.... and sorry for my bad explanation: ant debug works as well as ant release, and I was able to launch the debugger as you suggested. My question was more related to the IDE. I find it EXTREMELY frustrating not to be able to use this "official" tool by Google. It took me a (long) while to manage to use the cumbersome Eclipse with NDK (I need NDK to manage the MIDI interface via USB, which is yet another nightmare), and now I am back to point 0 (or 0.1) to change my dev environment to Android Studio.

Plus you are telling me that you actually do NOT use the thing (which I can't blame you for...). Arrrrrrgh !!! You were my last hope !!!

;)

Well ok then. I am not sure whether I should go the command line way or spend days trying to get the Android Studio environment working for my projects.  Any advice from anyone would be welcome...

P.S. I wish it were as simple as with Apple's XCode tools...

As far as I understand, the Android Studio way of organising the project is different to Eclipse and ANT. I initially also tried to get JUCE project working under Android Studio, and had lots of issues, but command line ant worked fine. When I need to work on Java stuff I just use Eclipse and ANT. 

I think Introjucer would need to have a different export type for Android Studio. I know you can import Eclipse style projects and convert them in Android Studio but to do this each time a project is saved in IJ would not be feasible. 

I guess it depends on if ROLI / JUCE team have time to do it or if someone else has the time / inclination to try and create an alternative Android project export type. 

Thanks for your comment Adamski.

Jules, Fabian, any insight view on this ? Are there any plans to support Android Studio ? I guess we are back to this post's original question....

We're certainly interested in investigating it - will obviously keep everyone posted if we have any news there.

This might help:

http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/