Android Studio - Gradle build settings


#1

The build.gradle version numbers generated by Projucer need some extra options.

A default project results in something like

android { 
    compileSdkVersion = 10 
    buildToolsVersion = "23.0.1" 
    defaultConfig.with { 
        applicationId = "com.yourcompany.animatedandroidtest" 
        minSdkVersion.apiLevel = 11 
        targetSdkVersion.apiLevel = 10 
    } 
}
​

On my setup this fails to compile. I am also using level 21 support library. I manually set the build.gradle file to:

android { 
    compileSdkVersion = 23 
    buildToolsVersion = "23.0.2" 
    defaultConfig.with { 
        applicationId = "com.yourcompany.nativenavigation" 
        minSdkVersion.apiLevel = 11 
        targetSdkVersion.apiLevel = 23 
    } 
}

Setting it to the latest build tools version seemed to get it to work, after setting the compile and target SDK version.

I can't see in Projucer where to set the compile or target SDK version. This is important for those of us wishing to use recent Android support libraries alongside JUCE in our app. 

Also, importantly when compiling with SDK versions of 21 and later, we need to set

android.ndk.platformVersion = 19

if we are targeting earlier versions of Android, as version 21 and later no longer provide inline math functions and so compiling JUCE gets lots of compile errors e.g. 

dlopen failed: cannot locate symbol "atof"​

(There is an alternative which I'm exploring, using the Crystax NDK which is supposed to be a drop-in replacement for Android NDK with much better C++ support inc C++14 and Objective C ... )


#2

Seems like a reasonable request, I'll add something that allows you to specify the build tools and platform version soon! Thank you.


#3

There is something amiss here - the "Minimum SDK version" seems to set "compileSdkVersion" and "targetSdkVersion" not
 "minSdkVersion.apiLevel" as I would expect.  "minSdkVersion.apiLevel" is always 11. 


#4

I'll fix this too! :) Thanks again


#5

Thanks, I would move it so it sits next to the minimumSDK version field. 

I also think that the Activity sub-class option is a little pointless now that the whole folder gets trashed on each project save - I originally requested that so that I could subclass the JuceActivity and customise it for my needs without having to checkout my customised version from Git after each project save. I also found that I need to inherit from AppCompatActivity and so I need to alter the main generated activity anyway. 


#6

What exactly are you tweaking? If it's missing JUCE features / bugs, we might (no promises) be able to help!


#7

I am adding native UI from the recent Android support libraries to the JuceActivity  - thats why I need it to inherit from AppCompatActivity rather than plain Activity. If I could just have that option, and be able to subclass it to my custom Activity class (ideally the whole folder being overwritten each time!) then I think that would be enough for me. That way I could keep up to date with changes to the generated activity class from Jucer.