Android Tutorial Fails

I’m trying to build the Android Tutorial App

I have followed the guide as best I could but it seems to be out of date and the Projucer already made some changes to the code (as per the tutorial)

it fails on the build

    org.gradle.internal.UncheckedException: Build command failed.
Error while executing process D:\Android\android-sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build D:\___SOURCE_TREE\__droid\droidtry01\Builds\Android\app\.externalNativeBuild\cmake\debug_Debug\x86 --target juce_jni}
[1/2] Building CXX object CMakeFiles/juce_jni.dir/D_/___SOURCE_TREE/__droid/droidtry01/JuceLibraryCode/include_juce_gui_extra.cpp.o
FAILED: D:\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe  --target=i686-none-linux-android23 --gcc-toolchain=D:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=D:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot  -DDEBUG=1 -DJUCER_ANDROIDSTUDIO_7F0E4A25=1 -DJUCE_ANDROID=1 -DJUCE_ANDROID_API_VERSION=23 -DJUCE_ANDROID_GL_ES_VERSION_3_0=1 -DJUCE_APP_VERSION=1.0.0 -DJUCE_APP_VERSION_HEX=0x10000 -DJUCE_PUSH_NOTIFICATIONS=1 -D_DEBUG=1 -Djuce_jni_EXPORTS -I../../../../../../../JuceLibraryCode -I"D:/___SOURCE_TREE/JUCE Builds/development/modules" -ID:/Android/android-sdk/ndk-bundle/sources/android/cpufeatures -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -fexceptions -frtti -fsigned-char -std=c++14 -O0 -fno-limit-debug-info -O0 -fPIC -MD -MT CMakeFiles/juce_jni.dir/D_/___SOURCE_TREE/__droid/droidtry01/JuceLibraryCode/include_juce_gui_extra.cpp.o -MF CMakeFiles\juce_jni.dir\D_\___SOURCE_TREE\__droid\droidtry01\JuceLibraryCode\include_juce_gui_extra.cpp.o.d -o CMakeFiles/juce_jni.dir/D_/___SOURCE_TREE/__droid/droidtry01/JuceLibraryCode/include_juce_gui_extra.cpp.o -c D:\___SOURCE_TREE\__droid\droidtry01\JuceLibraryCode\include_juce_gui_extra.cpp
In file included from D:\___SOURCE_TREE\__droid\droidtry01\JuceLibraryCode\include_juce_gui_extra.cpp:9:

In file included from D:/___SOURCE_TREE/JUCE Builds/development/modules\juce_gui_extra/juce_gui_extra.cpp:77:

D:/___SOURCE_TREE/JUCE Builds/development/modules\juce_gui_extra/native/juce_android_PushNotifications.cpp:1655:39: error: use of undeclared identifier 'JUCE_PUSH_NOTIFICATIONS_ACTIVITY'

     DECLARE_JNI_CLASS (JavaActivity, JUCE_PUSH_NOTIFICATIONS_ACTIVITY)

                                      ^

1 error generated.

ninja: build stopped: subcommand failed.


	at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:67)
	at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:76)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:48)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:704)
	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:671)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$2.run(ExecuteActionsTaskExecuter.java:284)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:273)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:258)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:67)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:145)
	at org.gradle.internal.execution.impl.steps.ExecuteStep.execute(ExecuteStep.java:49)
	at org.gradle.internal.execution.impl.steps.CancelExecutionStep.execute(CancelExecutionStep.java:34)
	at org.gradle.internal.execution.impl.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:69)
	at org.gradle.internal.execution.impl.steps.TimeoutStep.execute(TimeoutStep.java:49)
	at org.gradle.internal.execution.impl.steps.CatchExceptionStep.execute(CatchExceptionStep.java:33)
	at org.gradle.internal.execution.impl.steps.CreateOutputsStep.execute(CreateOutputsStep.java:50)
	at org.gradle.internal.execution.impl.steps.SnapshotOutputStep.execute(SnapshotOutputStep.java:43)
	at org.gradle.internal.execution.impl.steps.SnapshotOutputStep.execute(SnapshotOutputStep.java:29)
	at org.gradle.internal.execution.impl.steps.CacheStep.executeWithoutCache(CacheStep.java:134)
	at org.gradle.internal.execution.impl.steps.CacheStep.lambda$execute$3(CacheStep.java:83)
	at java.util.Optional.orElseGet(Optional.java:267)
	at org.gradle.internal.execution.impl.steps.CacheStep.execute(CacheStep.java:82)
	at org.gradle.internal.execution.impl.steps.CacheStep.execute(CacheStep.java:36)
	at org.gradle.internal.execution.impl.steps.PrepareCachingStep.execute(PrepareCachingStep.java:33)
	at org.gradle.internal.execution.impl.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:38)
	at org.gradle.internal.execution.impl.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:23)
	at org.gradle.internal.execution.impl.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
	at org.gradle.internal.execution.impl.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
	at java.util.Optional.map(Optional.java:215)
	at org.gradle.internal.execution.impl.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:52)
	at org.gradle.internal.execution.impl.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:36)
	at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:34)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:91)
	at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:91)
	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:119)
	at org.gradle.api.internal.tasks.execution.ResolvePreviousStateExecuter.execute(ResolvePreviousStateExecuter.java:43)
	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:93)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:45)
	at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:94)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:56)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:67)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:315)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:305)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:101)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:745)
Caused by: Build command failed.
Error while executing process D:\Android\android-sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build D:\___SOURCE_TREE\__droid\droidtry01\Builds\Android\app\.externalNativeBuild\cmake\debug_Debug\x86 --target juce_jni}
[1/2] Building CXX object CMakeFiles/juce_jni.dir/D_/___SOURCE_TREE/__droid/droidtry01/JuceLibraryCode/include_juce_gui_extra.cpp.o
FAILED: D:\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe  --target=i686-none-linux-android23 --gcc-toolchain=D:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=D:/Android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot  -DDEBUG=1 -DJUCER_ANDROIDSTUDIO_7F0E4A25=1 -DJUCE_ANDROID=1 -DJUCE_ANDROID_API_VERSION=23 -DJUCE_ANDROID_GL_ES_VERSION_3_0=1 -DJUCE_APP_VERSION=1.0.0 -DJUCE_APP_VERSION_HEX=0x10000 -DJUCE_PUSH_NOTIFICATIONS=1 -D_DEBUG=1 -Djuce_jni_EXPORTS -I../../../../../../../JuceLibraryCode -I"D:/___SOURCE_TREE/JUCE Builds/development/modules" -ID:/Android/android-sdk/ndk-bundle/sources/android/cpufeatures -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -fexceptions -frtti -fsigned-char -std=c++14 -O0 -fno-limit-debug-info -O0 -fPIC -MD -MT CMakeFiles/juce_jni.dir/D_/___SOURCE_TREE/__droid/droidtry01/JuceLibraryCode/include_juce_gui_extra.cpp.o -MF CMakeFiles\juce_jni.dir\D_\___SOURCE_TREE\__droid\droidtry01\JuceLibraryCode\include_juce_gui_extra.cpp.o.d -o CMakeFiles/juce_jni.dir/D_/___SOURCE_TREE/__droid/droidtry01/JuceLibraryCode/include_juce_gui_extra.cpp.o -c D:\___SOURCE_TREE\__droid\droidtry01\JuceLibraryCode\include_juce_gui_extra.cpp
In file included from D:\___SOURCE_TREE\__droid\droidtry01\JuceLibraryCode\include_juce_gui_extra.cpp:9:

In file included from D:/___SOURCE_TREE/JUCE Builds/development/modules\juce_gui_extra/juce_gui_extra.cpp:77:

D:/___SOURCE_TREE/JUCE Builds/development/modules\juce_gui_extra/native/juce_android_PushNotifications.cpp:1655:39: error: use of undeclared identifier 'JUCE_PUSH_NOTIFICATIONS_ACTIVITY'

     DECLARE_JNI_CLASS (JavaActivity, JUCE_PUSH_NOTIFICATIONS_ACTIVITY)

                                      ^

1 error generated.

ninja: build stopped: subcommand failed.

how can I fix this?

Anyone have any insight into this error?

i am having the same.

Just updated a project to latest develop (commit 937991) and getting this error now too.

The offending code:
(neither push notifications nor the JuceActivity are relevant in my case as I’m building a library)

struct JuceActivityNewIntentListener
{
    #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
     CALLBACK (appNewIntent, "appNewIntent", "(Landroid/content/Intent;)V")

     DECLARE_JNI_CLASS (JavaActivity, JUCE_PUSH_NOTIFICATIONS_ACTIVITY)
    #undef JNI_CLASS_MEMBERS

    static void JNICALL appNewIntent (JNIEnv*, jobject /*activity*/, jobject intentData)
    {
       #if JUCE_PUSH_NOTIFICATIONS && JUCE_MODULE_AVAILABLE_juce_gui_extra
        juce_handleNotificationIntent(static_cast<void*>(intentData));
       #else
        juce::ignoreUnused(intentData);
       #endif
    }
};

JuceActivityNewIntentListener::JavaActivity_Class JuceActivityNewIntentListener::JavaActivity;

I’m going back to master (commit dd9802)

it has been fixed.

The file containing that code will only be included if JUCE_PUSH_NOTIFICATIONS is defined, and that will only be set if the Android push notifications option is enabled (see this line). Is the push notifications option enabled in your project somehow? Have you re-saved with the latest build of the Projucer?

So I updated to the latest Projucer (5.4.4 on develop) and resaved the project. Looks like the Push Notifications issue is fixed but I get a runtime JNI error now. See ClassNotFoundException for JuceSharingContentProvider