In a Java application for Android, made in JavaFX under Eclipse Neon2, I want to use the android media SoundPool class.
To do that, I have added, in the Java Build Path:
the android-sdks platform : android-25 (called android.jar).
the jfxdvk-8.60.8.jar
Then, for instance, I create a SoundPool instance as follows:
import android.media.SounPool;
import android.media.MediaPlayer;
...
SoundPool sp = new SoundPool(MAX_STREAMS,AudioManager.STREAM_MUSIC,0);
The syntax is correct and the Eclipse editor does not notice any error.
But, when compiling the file, I have two errors "package android.media does not exist import android.media.AudioManager" and "package android.media does not exist import android.media.SoundPool;", and then, (it is a consequence), "cannot find symbols" at "AudioManager.STREAM_MUSIC" and at "new SoundPool" of the previous line code.
I don't understand these errors because I have added, in my JavaBuild Path, this android-sdks platform: android.jar (android-25) ad the Eclipse editor can fetch these two imports.
Thanks in advance for your response
Further information:
Errors raised on java compilation:
[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks:
[sts] androidInstall
[sts] -----------------------------------------------------
:validateManifest
:collectMultiDexComponents
:compileJavaC:\Users\pascal\workspaceNeon\JFX_withGluon_11.0gAvecSoundPoolKO\src\main\java\com\gluonapplication\GluonApplication.java:3: error: package android.media does not exist
import android.media.AudioManager;
^
C:\Users\pascal\workspaceNeon\JFX_withGluon_11.0gAvecSoundPoolKO\src\main\java\com\gluonapplication\GluonApplication.java:4: error: package android.media does not exist
import android.media.SoundPool;
^
C:\Users\pascal\workspaceNeon\JFX_withGluon_11.0gAvecSoundPoolKO\src\main\java\com\gluonapplication\GluonApplication.java:635: error: cannot find symbol
static SoundPool androidSoundPoolApplication = null;
----------------------
Related code:
package com.gluonapplication;
import android.media.AudioManager;
import android.media.SoundPool;
import com.gluonhq.charm.down.Services; // line 3
import com.gluonhq.charm.down.plugins.AccelerometerService; // line 4
......
final static int MAX_STREAMS = 10;
static SoundPool androidSoundPoolApplication = null; // line 635
And the build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.2'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.gluonapplication.GluonApplication'
dependencies {
compile 'com.gluonhq:charm:4.3.0'
}
jfxmobile {
downConfig {
version '3.2.0'
plugins 'accelerometer', 'compass', 'device', 'orientation', 'storage', 'vibration', 'display', 'magnetometer', 'lifecycle', 'statusbar', 'position'
}
android {
applicationPackage = 'com.gluonapplication'
manifest = 'src/android/AndroidManifest.xml'
androidSdk = 'C:/Users/pascal/AppData/Local/Android/sdk'
resDirectory = 'src/android/res'
compileSdkVersion = '25'
buildToolsVersion = '25.0.1'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}