Android studio project created from JUCE4.3 on Win7 compile faild

Hi, I’m newer to Juce and would like to use juce to create android studio projects, but compile failed,errors like

Error:(301, 1) error: expected ‘)’
Information:(225, 13) expanded from macro ‘DECLARE_JNI_CLASS’
Information:(264, 66) expanded from macro ‘JNI_CLASS_MEMBERS’
Information:(301, 1) to match this ‘(’
C:\Users\zhouqi\Documents\NewProject4\Builds\AndroidStudio/…/…/JuceLibraryCode/modules\juce_core/native/juce_android_JNIHelpers.h:225:32: note: expanded from macro ‘DECLARE_JNI_CLASS’
Error:(301, 1) error: expected ‘)’
Information:(265, 63) expanded from macro ‘JNI_CLASS_MEMBERS’
Error:(301, 1) error: expected ‘)’
Information:(266, 69) expanded from macro ‘JNI_CLASS_MEMBERS’
Error:(301, 1) error: expected ‘)’
Information:(274, 149) expanded from macro ‘JNI_CLASS_MEMBERS’
Information:(301, 1) to match this ‘(’
C:\Users\zhouqi\Documents\NewProject4\Builds\AndroidStudio/…/…/JuceLibraryCode/modules\juce_core/native/juce_android_JNIHelpers.h:225:51: note: expanded from macro ‘DECLARE_JNI_CLASS’
Error:(301, 1) error: expected ‘)’
Information:(290, 76) expanded from macro ‘JNI_CLASS_MEMBERS’
Error:(301, 1) error: expected ‘)’
Information:(291, 74) expanded from macro ‘JNI_CLASS_MEMBERS’
Error:(301, 37) error: use of undeclared identifier ‘TizerTest4’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Information:(221, 49) expanded from macro ‘DECLARE_JNI_CLASS’
Error:(301, 37) error: use of undeclared identifier ‘TizerTest4’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 37) error: use of undeclared identifier ‘TizerTest4’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 37) error: use of undeclared identifier ‘TizerTest4’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Error:(301, 1) error: expected ‘)’
Information:(Unknown) In file included
C:\Users\zhouqi\Documents\NewProject4\JuceLibraryCode\modules\juce_opengl\native\juce_OpenGL_android.h
Error:(31, 71) error: expected ‘)’
Information:(31, 1) to match this ‘(’
Error:(31, 39) error: use of undeclared identifier ‘TizerTest4’
Error:Execution failed for task ‘:app:compileJuce_jniArmeabiDebugArmeabiSharedLibraryJuce_jniArmeabiDebugArmeabiSharedLibraryMainCpp’.

Multiple build operations failed.
C++ compiler failed while compiling juce_events.cpp.
C++ compiler failed while compiling juce_core.cpp.
C++ compiler failed while compiling juce_graphics.cpp.
C++ compiler failed while compiling juce_gui_basics.cpp.
C++ compiler failed while compiling juce_opengl.cpp.
See the complete log at: file:///C:/Users/zhouqi/Documents/NewProject4/Builds/AndroidStudio/app/build/tmp/compileJuce_jniArmeabiDebugArmeabiSharedLibraryJuce_jniArmeabiDebugArmeabiSharedLibraryMainCpp/output.txt

Hmmm I can’t seem to re-produce this. Which Android SDK version are you using? Which build-tools version?

Thanks for your reply, I test it on android studio 2.2.2 and gradle 2.14.1 ,maybe I changed something this problem occurred, but after I re-produce new project with JUCE4.3, and use gradle build command anything works well. I will re-test this case.

Hi fabian,
I have repeated this case when I open one old juce project(maybe created with JUCE4.0) and created android studio project, I can’t compile with gradle in android studio, some errors like:

Information:(Unknown) In file included
G:\WCTS\V50_Mult8_SOURCE\JuceLibraryCode\modules\juce_audio_devices\native\juce_android_Midi.cpp
Error:(32, 72) error: expected ')'
Information:(32, 2) to match this '('
Error:(32, 40) error: use of undeclared identifier 'com’
Error:(32, 40) error: use of undeclared identifier 'tizer’
Error:(32, 40) error: use of undeclared identifier 'NewProject’
Error:(32, 2) error: expected ')'
Information:(28, 84) expanded from macro 'JNI_CLASS_MEMBERS’
Information:(32, 2) to match this '('
G:\WCTS\V50_Mult8_SOURCE\Builds\AndroidStudio/…/…/JuceLibraryCode/modules\juce_core/native/juce_android_JNIHelpers.h:225:32: note: expanded from macro 'DECLARE_JNI_CLASS’
Error:(32, 2) error: expected ')'
Information:(29, 85) expanded from macro 'JNI_CLASS_MEMBERS’
Error:(40, 67) error: expected ‘)’


G:\WCTS\V50_Mult8_SOURCE\JuceLibraryCode\modules\juce_core\native\juce_android_Network.cpp
Error:(46, 64) error: expected ')'
Information:(46, 1) to match this '('
Error:(46, 32) error: use of undeclared identifier 'com’
Error:(46, 32) error: use of undeclared identifier 'tizer’
Error:(46, 32) error: use of undeclared identifier 'NewProject’
Information:(Unknown) In file included
Information:(Unknown) In file included
Information:(Unknown) In file included
Information:(Unknown) In file included
Information:(Unknown) In file included

error found in line like:
DECLARE_JNI_CLASS (MidiDeviceManager, JUCE_ANDROID_ACTIVITY_CLASSPATH “$MidiDeviceManager”)

You probably have a space in you activity name or something like that.

I set Android activity class name as “com.tizer.NewProject” in juce 4.3, I checked it.

Just set it to NewProject.

OK, I will test right now and report result to you. thanks

Oh, sorry, I can’t fix this problem.

build.gradle script is:

apply plugin: 'com.android.model.application’
model {
android {
compileSdkVersion = 21
buildToolsVersion = “23.0.2"
defaultConfig.with {
applicationId = “com.ruiyun.gameproject"
minSdkVersion.apiLevel = 21
targetSdkVersion.apiLevel = 21
}
}
android.ndk {
moduleName = “juce_jni"
toolchain = “gcc"
stl = “gnustl_static"
cppFlags.add(”-fsigned-char”)
cppFlags.add(”-fexceptions”)
cppFlags.add(”-frtti")
cppFlags.add("-std=c++11")
cppFlags.add("-DJUCER_ANDROIDSTUDIO_4330F05B=1")
cppFlags.add("-DJUCE_APP_VERSION=1.0.0")
cppFlags.add("-DJUCE_APP_VERSION_HEX=0x10000")
cppFlags.add("-I${project.rootDir}/…/…/Source".toString())
cppFlags.add("-I${project.rootDir}/…/…/…".toString())
ldLibs.add(“android”)
ldLibs.add(“EGL”)
ldLibs.add(“GLESv2”)
ldLibs.add(“log”)
}
android.sources {
main {
jni {
source {
exclude “**/JuceModules/”
}
}
}
}
android.buildTypes {
debug {
ndk.with {
debuggable = true
cppFlags.add("-g")
cppFlags.add("-DDEBUG=1")
cppFlags.add("-D_DEBUG=1")
cppFlags.add("-O0")
cppFlags.add("-I${project.rootDir}/…/…/JuceLibraryCode".toString())
cppFlags.add("-I${project.rootDir}/…/…/JuceLibraryCode/modules".toString())
cppFlags.add("-I${project.rootDir}/JuceModules".toString())
cppFlags.add("-DJUCE_ANDROID=1")
cppFlags.add("-DJUCE_ANDROID_API_VERSION=21")
cppFlags.add("-DJUCE_ANDROID_ACTIVITY_CLASSNAME=NewProject")
cppFlags.add("-DJUCE_ANDROID_ACTIVITY_CLASSPATH=“NewProject”")
}
}
release {
signingConfig = ("android.signingConfigs.releaseConfig") ndk.with { cppFlags.add("-DNDEBUG=1") cppFlags.add("-O3") cppFlags.add("-I{project.rootDir}/…/…/JuceLibraryCode".toString())
cppFlags.add("-I${project.rootDir}/…/…/JuceLibraryCode/modules".toString())
cppFlags.add("-I${project.rootDir}/JuceModules".toString())
cppFlags.add("-DJUCE_ANDROID=1")
cppFlags.add("-DJUCE_ANDROID_API_VERSION=21")
cppFlags.add("-DJUCE_ANDROID_ACTIVITY_CLASSNAME=NewProject")
cppFlags.add("-DJUCE_ANDROID_ACTIVITY_CLASSPATH=“NewProject”")
}
}
}
android.signingConfigs {
create(“releaseConfig”) {
storeFile = new File(“C:\Users\zhouqi/.android/debug.keystore”)
storePassword = "123456"
keyAlias = "androiddebugkey"
keyPassword = "123456"
storeType = “jks”
}
}
android.productFlavors {
create(“armeabi”) {
ndk.abiFilters.add(“armeabi”)
}
create(“armeabi-v7a”) {
ndk.abiFilters.add(“armeabi-v7a”)
}
create(“x86”) {
ndk.abiFilters.add(“x86”)
}
}
}
dependencies {
compile “com.android.support:support-v4:+”
}

Hi,

I had exactly the same problem this morning trying to compile one of my apps under Android Studio/Windows.

The cause is the declaration of JUCE_ANDROID_ACTIVITY_CLASSPATH in app/build.gradle.

Projucer creates this line, causing the build error:
cppFlags.add("-DJUCE_ANDROID_ACTIVITY_CLASSPATH=“com/brand/project”")

and replacing the simple \ by \ \ \ fixes the problem:
cppFlags.add("-DJUCE_ANDROID_ACTIVITY_CLASSPATH=\ \ "com/brand/project\ \ “”)

[EDIT: I had to add a space character between the \ to get it displayed properly here. Remove the space between the \ in build.gradle]

Don’t ask me why… I have no idea. But under Windows it looks like the \ which is escaping the " should be escaped itself.

Finally I created a batch file based on fart in order to update the build.gradle file after Projucer saving, here is the command line:

fart -C app\build.gradle \x5C\x22 \x5C\x5C\x5C\x22

But it would be great if Projucer could be fixed in order to generate the right build.gradle content.

/Phil