Can't access local storage service - gluon-mobile

Similar question but didn't help: JavaFXPorts(Gluon Plugin) Saving Files on Android
I want to access the local storage on desktop and mobile. For now I'm testing on desktop. Whenever i launch the program I get the following in the error stream:
Mar 18, 2017 3:57:47 PM com.gluonhq.charm.down.Platform <clinit>
SEVERE: javafx.platform is not defined. Desktop will be assumed by default.
Mar 18, 2017 3:57:48 PM com.gluonhq.impl.charm.a.c.a <clinit>
SEVERE: null
java.io.IOException: Private storage file not available
at com.gluonhq.impl.charm.a.c.a.c(SourceFile:37)
at java.util.Optional.orElseThrow(Optional.java:290)
at com.gluonhq.impl.charm.a.c.a.<clinit>(SourceFile:37)
at com.gluonhq.charm.glisten.application.MobileApplication.a(SourceFile:244)
at com.gluonhq.charm.glisten.application.MobileApplication.start(SourceFile:211)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
and Services.get(StorageService.class); return an empty optional.
The trimmed down gradle build file is
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.2'
}
}
apply plugin: 'org.javafxports.jfxmobile'
apply plugin: 'eclipse'
jfxmobile {
downConfig {
version = '3.0.0'
plugins 'display', 'lifecycle', 'statusbar', 'storage' // <-- storage included by default
}
android {
compileSdkVersion = 23
manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
eclipse {
classpath {
downloadJavadoc = true
downloadSources = true
}
}
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.foo.MainClass'
dependencies {
compile 'com.gluonhq:charm:4.3.1'
}
task wrapper(type: Wrapper) {
gradleVersion = '3.4'
}
Not sure what this version is
jfxmobile {
downConfig {
version = '3.0.0'
because if I change it to 4.3.1 Gradle gives me an error (can post if relevant).
Also I tried adding to dependencies {
desktopRuntime "com.gluonhq:charm-down-desktop:4.3.1"
like in the linked question but it did nothing.

Related

Adding jcenter() in rootlevel repositories breaks my build

I have a project with a Gradle buildscript and I added the bmuschko/gradle-docker-plugin to create and push image on new builds.
However I cant use the plugin if I don't specify jcenter() in root level repositories, but that breaks my build, so im kinda lost.
If I add the root level jcenter() it fails the build with:
Could not resolve all dependencies for configuration ':compileClasspath'.
Could not find com.sleepycat:je:7.0.6. Searched in the following locations:
https://jcenter.bintray.com/com/sleepycat/je/7.0.6/je-7.0.6.pom
https://jcenter.bintray.com/com/sleepycat/je/7.0.6/je-7.0.6.jar
https://repo1.maven.org/maven2/com/sleepycat/je/7.0.6/je-7.0.6.pom
https://repo1.maven.org/maven2/com/sleepycat/je/7.0.6/je-7.0.6.jar
https://nexus.company.com/content/groups/public/com/sleepycat/je/7.0.6/je-7.0.6.pom
https://nexus.company.com/content/groups/public/com/sleepycat/je/7.0.6/je-7.0.6.jar
Required by: project : > org.jpos:jpos:2.1.1
However if I don't add it i get this:
Could not resolve all dependencies for configuration ':dockerJava'.
Could not find com.aries:docker-java-shaded:3.1.0-rc-3. Searched in the following locations:
https://nexus.company.com/content/groups/public/com/aries/docker-java-shaded/3.1.0-rc-3/docker-java-shaded-3.1.0-rc-3.pom
https://nexus.company.com/content/groups/public/com/aries/docker-java-shaded/3.1.0-rc-3/docker-java-shaded-3.1.0-rc-3-cglib.jar
Required by: project :
Should I perhaps build Java shaded and include in our local Maven repo?
Here is the script:
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url = 'https://nexus.company.com/content/repositories/snapshots/'
credentials {
username 'na'
password 'na'
}
}
}
dependencies {
classpath group: 'com.company.gradle', name: 'cpmgradle', version: '0.1-SNAPSHOT'
classpath 'com.bmuschko:gradle-docker-plugin:3.4.4'
}
}
// ADDING THIS BREAKS MY BUILD BUT IS NECESSARY FOR DOCKER PLUGIN TO WORK
repositories {
jcenter()
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.company.gradle.java'
apply plugin: 'com.bmuschko.docker-remote-api'
projectinfo {
group = 'com.company.mesb'
artifact = 'MESB'
version = '1.29.DEV-SNAPSHOT'
description = 'MESB'
packaging = 'jar'
}
dependencies {
compile 'org.jpos:jpos:2.1.1'
compile 'org.jdom:jdom2:2.0.6'
compile 'org.json:json:20140107'
compile 'com.company.javasdk:JavaSDK:1.1.JDOM2-SNAPSHOT'
compile 'com.company.javasdk:Base64:1.0'
compile 'org.apache.wss4j:wss4j-ws-security-dom:2.0.3'
compile 'org.apache.santuario:xmlsec:2.0.3'
compile 'org.slf4j:slf4j-log4j12:1.7.10'
compile 'com.google.code.gson:gson:2.3.1'
compile 'org.bouncycastle:bcprov-jdk15on:1.54'
compile 'org.bouncycastle:bcpkix-jdk15on:1.54'
compile 'junit:junit:4.12'
compile 'org.jsoup:jsoup:1.9.2'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.ibm:mq:5.3.07'
compile 'com.ibm:mq.pcf:5.3.07'
compile 'com.ibm:mq.jmqi:5.3.07'
compile 'com.ibm:mq.headers:5.3.07'
compile 'com.ibm:mq.commonservices:5.3.07'
compile 'com.ibm:connector:1.0.0'
runtime 'jaxen:jaxen:1.1.6'
runtime 'xalan:xalan:2.7.2'
runtime 'org.postgresql:postgresql:8.0-311.jdbc3'
runtime 'commons-logging:commons-logging:1.2'
}
compileJava {
sourceCompatibility = 1.6
targetCompatibility = 1.6
options.fork = true
options.compilerArgs << '-XDignore.symbol.file'
options.forkOptions.executable = 'javac'
}
task libs(type: Copy) {
description = "Copies dependencies to the 'lib' directory of the deployment."
def libsDir = new File("$buildDir", 'libs')
libsDir.mkdirs()
def dockerDir = new File("$buildDir", 'docker')
dockerDir.mkdirs()
from project.configurations.runtime
into libsDir
}
task bundleZip(type: Zip) {
from projectDir
include 'xsl/**'
include 'conf/**'
include 'js/**'
include 'test/**'
include 'mesb.sh'
from(tasks.libs.outputs) {
include 'MESB*'
}
into project.projectinfo.version
}
tasks.bundleZip.dependsOn jar
tasks.bundleZip.dependsOn libs
def dockerUsername = project.properties['dockerUsername'] ?: ""
def dockerPassword = project.properties['dockerPassword'] ?: ""
docker {
registryCredentials {
username = dockerUsername
password = dockerPassword
}
}
task buildImage(type: com.bmuschko.gradle.docker.tasks.image.DockerBuildImage) {
doFirst {
copy {
from "${buildDir}/libs/MESB-${projectinfo.version}.jar"
into "${buildDir}/docker"
rename { String fileName ->
fileName.replace("-${projectinfo.version}", "")
}
}
copy {
from "docker/jdk/Dockerfile"
into "${buildDir}/docker"
}
copy {
from "xsl"
into "${buildDir}/docker/xsl"
}
copy {
from "conf"
into "${buildDir}/docker/conf"
}
copy {
from "test"
into "${buildDir}/docker/test"
}
copy {
from "${buildDir}/libs"
into "${buildDir}/docker/libs"
}
}
inputDir = project.file("${buildDir}/docker")
tag = "company/mesb:${projectinfo.version}"
}
tasks.buildImage.dependsOn build
task pushImage(type: com.bmuschko.gradle.docker.tasks.image.DockerPushImage) {
imageName = "company/mesb"
tag = "${projectinfo.version}"
}
tasks.pushImage.dependsOn buildImage
artifacts {
archives bundleZip
}
/* Remove the default JAR file from the uploaded artifacts */
configurations.archives.artifacts.with { archives ->
def jarArtifact
archives.each {
if (it.file =~ 'jar') {
jarArtifact = it
}
}
remove(jarArtifact)
}
jar {
dependsOn configurations.runtime
manifest {
attributes 'Main-Class': 'main.MESB'
}
}
tasks.build.dependsOn libs
sourceSets {
main {
java {
srcDir 'src'
}
}
}
Apparently moving root repository definitions benieth the apply plugins section solved this.
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.company.gradle.java'
apply plugin: 'com.bmuschko.docker-remote-api'
repositories {
jcenter()
mavenCentral()
}
Don't know whether you have solved your issue but either way...
I encountered a similar issue regarding:
Could not resolve all dependencies for configuration ':dockerJava'.
Could not find com.aries:docker-java-shaded:3.1.0-rc-3.
We solved it by adding the following
repositories {
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}

Can I use the recent Java 8 support for Android with Gluon Mobile?

Google released a few months ago a gradle plugin for java 8 support on Android API level 24 and up. This is achieved by adding the dependency to the gradle build file:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.4.0-alpha7'
}
}
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Is this supported with Gluon Mobile?
I have installed builds tools 25.0.3, and without any modification at all of the build.gradle file that the Gluon plugin generates on a Single View project:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.8'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.gluonandroid24.GluonAndroid24'
dependencies {
compile 'com.gluonhq:charm:4.3.7'
}
jfxmobile {
downConfig {
version = '3.6.0'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
I can include Java 8 streams:
public BasicView(String name) {
super(name);
Label label = new Label("Hello JavaFX World!");
Button button = new Button("Change the World!");
button.setGraphic(new Icon(MaterialDesignIcon.LANGUAGE));
button.setOnAction(e -> label.setText("Sum: " + Stream.of("1", "2", "5")
.mapToInt(Integer::parseInt)
.sum()));
VBox controls = new VBox(15.0, label, button);
controls.setAlignment(Pos.CENTER);
controls.getChildren().stream()
.filter(Label.class::isInstance)
.forEach(System.out::println);
setCenter(controls);
}
and run the project on Desktop and deploy it and run it successfully on Android (at least on my device with Android 7.1.1). Obviously not on iOS.
The jfxmobile plugin already looks for the latest build-tools version you have installed at $AndroidSdk/build-tools. In case you want to set some options, you could set:
jfxmobile {
...
android {
manifest = 'src/android/AndroidManifest.xml'
buildToolsVersion = '25.0.3'
compileSdkVersion = '25'
minSdkVersion = '25'
targetSdkVersion = '25'
}
}

Gluon javafx with netbeans error android install

Error while trying to to do android install
Execution failed for task ':mergeClassesIntoJar'.
Cannot expand ZIP 'C:\Users\Path..\AppData\Local\Android\sdk\extras\android\support\multidex\library\libs\android-support-multidex.jar' as it does not exist.
Can any one pleas help am fed up of this issue no proper solution below is my code
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.9'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.netbeansdemo.NetbeansDemo'
dependencies {
compile 'com.gluonhq:charm:3.0.0'
androidRuntime 'com.gluonhq:charm-android:3.0.0'
iosRuntime 'com.gluonhq:charm-ios:3.0.0'
desktopRuntime 'com.gluonhq:charm-desktop:3.0.0'
}
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
androidSdk = 'C:/Users/ee209275/AppData/Local/Android/Sdk'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'io.datafx.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
You need to update the Gluon plugin for your IDE, so you can generate a project with updated dependencies. Current versions of the plugin are 2.5.0 for NetBeans and IntelliJ, 2.4.0 for Eclipse.
For a single view project, this will be the build.gradle file you will get:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.6'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.gluonhq.testplugin.GluonTestPlugin'
dependencies {
compile 'com.gluonhq:charm:4.3.5'
}
jfxmobile {
downConfig {
version = '3.3.0'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
You have an issue with the Android SDK path. This question shows how to solve it.
Basically:
Open the Android SDK Manager and make sure you have installed Extras/Google Repository and Extras/Android Support Repository.
Remove the androidSdk line from the android block on your build.gradle file and move it to a properties file. For that, just create a properties file under C:\Users\<user>\.gradle\gradle.properties, and add the ANDROID_HOME variable: ANDROID_HOME=C:/<path.to.Android>/sdk.
Then reload your project, see that it works on desktop, and then deploy to mobile.

SingleViewProject crash on Android

I use a Samsung Galaxy S7 for my tests.
I don't understand why I compile and launch my gluon Applications on my phone, it crash. I tried with the SingleViewProject and I have the same problem.
The last week, I didn't have this problem.
my grade file
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.8'
}
}
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:2.1.1'
androidRuntime 'com.gluonhq:charm-android:2.1.1'
iosRuntime 'com.gluonhq:charm-ios:2.1.1'
desktopRuntime 'com.gluonhq:charm-desktop:2.1.1'
}
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
androidSdk = "/Users/Alexandre/Library/Android/sdk"
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'io.datafx.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
The stacktrace
Process: com.gluonapplication, PID: 20944
java.lang.RuntimeException: Did not create correct launcher.
...
Caused by: java.lang.RuntimeException: Could not find /javafx.platform.properties on classpath.
Have you an idea to help me ?

Gradle Geb saucelabs plugin

I'm following the example from http://www.gebish.org/manual/0.9.2/sauce-labs.html#gradle_geb_saucelabs_plugin but am unable to get it working. My build.gradle script is as follows:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.0.0"
classpath 'org.gebish:geb-gradle:0.9.2'
}
}
version "0.1"
group "example"
apply plugin: "grails"
apply plugin: "geb-saucelabs"
repositories {
grails.central() //creates a maven repo for the Grails Central repository (Core libraries and plugins)
maven { url "http://repository-saucelabs.forge.cloudbees.com/release" }
}
grails {
grailsVersion = '2.3.5'
groovyVersion = '2.1.9'
springLoadedVersion '1.1.3'
}
dependencies {
bootstrap "org.grails.plugins:tomcat:7.0.50" // No container is deployed by default, so add this
compile 'org.grails.plugins:resources:1.2' // Just an example of adding a Grails plugin
sauceConnect "com.saucelabs:sauce-connect:3.0.28"
}
sauceLabs {
browsers { //5
firefox_linux_19 //Could not find property 'reporting' on root project 'gradleGrailsError'.
chrome_mac
internetExplorer_vista_9
}
task { //6
testClassesDir = test.testClassesDir
testSrcDirs = test.testSrcDirs
classpath = test.classpath
}
account { //7
username = System.getenv("SAUCE_ONDEMAND_USERNAME")
accessKey = System.getenv("SAUCE_ONDEMAND_ACCESS_KEY")
}
}
When I run $gradle test, I get the following error: Could not find property 'reporting' on root project... This error occurs on the line which specifies firefox_linux_19 as the browser. Can someone please advise how I can get the geb-saucelabs plugin working correctly? Thanks.
After a lot of trial and error, I got the following to work:
sauceLabs {
tasks.withType(Test) {
reports.junitXml.destination = reporting.file("test-results/$name")
reports.html.destination = reporting.file("test-reports/$name")
}
browsers { //5
firefox_linux_19
chrome_mac
internetExplorer_vista_9
}
account { //7
username = System.getenv("SAUCE_ONDEMAND_USERNAME")
accessKey = System.getenv("SAUCE_ONDEMAND_ACCESS_KEY")
}
}
The addition of the tasks.withType(Test) was the key, and I also removed the task closure which was listed in the sample code.

Resources