0

When I run my own app on desktop Gluon, it is working fine, but when I use the debugger to my phone Sony experia the login UI is showing, but when I wrote username and password I can't access the main screen. What do I need to write in my db connect and in build.gradle?

I tried to change mysql version in my build.gradle to compile mysql:mysql-connector-java:8.0.13 and to compile mysql:mysql-connector-java:5.1.46

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'org.javafxports:jfxmobile-plugin:1.3.16'
}
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
jcenter()
maven {
    url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}

 mainClassName = 'com.crm.CRM'

dependencies {
compile 'com.gluonhq:charm:5.0.2'
compile 'mysql:mysql-connector-java:8.0.13'
compile 'com.jcraft:jsch:0.1.54'
}

jfxmobile {
downConfig {
    version = '3.8.6'
    // Do not edit the line below. Use Gluon Mobile Settings in your 
  project context menu instead
    plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
    javafxportsVersion = '8.60.11'
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'  
        exclude 'META-INF/rxjava.properties'
        exclude 'META-INF/spring.schemas'
        exclude 'META-INF/INDEX.LIST'
    }   
    //        compileSdkVersio=28
    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.**.*'
    ]
}
}

and this is the code for connect db :

 public static Connection getConnection() {
 try {
  //Your Database usrl using String,ensure it is correct             
 Class.forName("com.mysql.jdbc.Driver");
 Connection con = 
 DriverManager.getConnection("jdbc:mysql://192.168.43.13:3306/crmywa? 
 useUnicode=yes&characterEncoding=UTF-8", "root", "");
        return con;
 } catch (Exception ex) {
         
 Logger.getLogger(dbmobo.class.getName()).log(Level.SEVERE, null, ex);
 }
    return null;
}

enter image description here

EDIT

after i check the result adb logcat i got this result :

01-31 18:51:01.399 17374 17407 W System.err: Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. 
01-31 18:51:01.403 17374 17407 W System.err: Exception in Application start method 
01-31 18:51:01.405 17374 17407 I System.out:QuantumRenderer: shutdown 
01-31 18:51:01.406 17374 17402 W System.err: java.lang.reflect.InvocationTargetException 
01-31 18:51:01.406 17374 17402 W System.err:    at java.lang.reflect.Method.invoke(Native Method) 
01-31 18:51:01.406 17374 17402 W System.err:    at javafxports.android.DalvikLauncher$1.run(DalvikLauncher.java:188)
01-31 18:51:01.406 17374 17402 W System.err:    at java.lang.Thread.run(Thread.java:761) 
01-31 18:51:01.406   364  3793 I BufferQueueProducer: [SurfaceView -com.crm/javafxports.android.FXActivity](this:0x7549311800,id:2793,api:1,p:17374,c:364) new GraphicBuffer needed 
01-31 18:51:01.406 17374 17402 W System.err: Caused by: java.lang.RuntimeException: Exception in Application start method 
01-31 18:51:01.406 17374 17402 W System.err:    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
01-31 18:51:01.406 17374 17402 W System.err:    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$138(LauncherImpl.java:182)
01-31 18:51:01.406 17374 17402 W System.err:    at com.sun.javafx.application.LauncherImpl.access$lambda$1(LauncherImpl.java)
01-31 18:51:01.407 17374 17402 W System.err:    at com.sun.javafx.application.LauncherImpl$$Lambda$2.run(Unknown Source)
01-31 18:51:01.407 17374 17402 W System.err:    ... 1 more 
01-31 18:51:01.407 17374 17402 W System.err: Caused by: javafx.fxml.LoadException: 
01-31 18:51:01.407 17374 17402 W System.err: file:/data/app/com.crm-1/base.apk!/fxml/login.fxml:21
01-31 18:51:01.407 17374 17402 W System.err:    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
01-31 18:51:01.407 17374 17402 W System.err:    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579) 
01-31 18:51:01.407 17374 17402 W System.err:    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441) 
01-31 18:51:01.407 17374 17402 W System.err:    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214) 
01-31 18:51:01.407 17374 17402 W System.err:    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175) 
01-31 18:51:01.407 17374 17402 W System.err:    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148) 
01-31 18:51:01.407 17374 17402 W System.err:    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124) 
01-31 18:51:01.407 17374 17402 W System.err:    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104) 
01-31 18:51:01.407 17374 17402 W System.err:    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097) 
01-31 18:51:01.407 17374 17402 W System.err:    at com.crm.CRM.start(CRM.java:15) 
01-31 18:51:01.407 17374 17402 W System.err:    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$145(LauncherImpl.java:863)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.javafx.application.LauncherImpl.access$lambda$8(LauncherImpl.java)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.javafx.application.LauncherImpl$$Lambda$9.run(Unknown Source)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$158(PlatformImpl.java:326)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.javafx.application.PlatformImpl.access$lambda$6(PlatformImpl.java)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.javafx.application.PlatformImpl$$Lambda$7.run(Unknown Source)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.javafx.application.PlatformImpl.lambda$null$156(PlatformImpl.java:295)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.javafx.application.PlatformImpl.access$lambda$18(PlatformImpl.java)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.javafx.application.PlatformImpl$$Lambda$19.run(Unknown Source)
01-31 18:51:01.408 17374 17402 W System.err:    at java.security.AccessController.doPrivileged(AccessController.java:57)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.javafx.application.PlatformImpl.lambda$runLater$157(PlatformImpl.java:294)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.javafx.application.PlatformImpl.access$lambda$5(PlatformImpl.java)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.javafx.application.PlatformImpl$$Lambda$6.run(Unknown Source)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:93)
01-31 18:51:01.408 17374 17402 W System.err:    at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:52)
01-31 18:51:01.408 17374 17402 W System.err:    ... 1 more 
01-31 18:51:01.409 17374 17402 W System.err: Caused by:java.lang.UnsupportedOperationException 
01-31 18:51:01.409 17374 17402 W System.err:    at java.util.regex.Matcher.group(Matcher.java:383)
01-31 18:51:01.409 17374 17402 W System.err:    at com.mysql.cj.conf.ConnectionUrlParser.isConnectionStringSupported(ConnectionUrlParser.java:152)
01-31 18:51:01.409 17374 17402 W System.err:    at com.mysql.cj.conf.ConnectionUrl.acceptsUrl(ConnectionUrl.java:258)
01-31 18:51:01.409 17374 17402 W System.err:    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:195)
01-31 18:51:01.409 17374 17402 W System.err:    at java.sql.DriverManager.getConnection(DriverManager.java:569) 
01-31 18:51:01.409 17374 17402 W System.err:    at java.sql.DriverManager.getConnection(DriverManager.java:219) 
01-31 18:51:01.409 17374 17402 W System.err:    at com.crm.dbmobo.getConnection(dbmobo.java:17) 
01-31 18:51:01.409 17374 17402 W System.err:    at com.crm.LoginController.<init>(LoginController.java:78) 
01-31 18:51:01.409 17374 17402 W System.err:    at java.lang.Class.newInstance(Native Method) 
01-31 18:51:01.409 17374 17402 W System.err:    at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:45) 
01-31 18:51:01.409 17374 17402 W System.err:    at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:927)
01-31 18:51:01.409 17374 17402 W System.err:    at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
01-31 18:51:01.409 17374 17402 W System.err:    at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
01-31 18:51:01.409 17374 17402 W System.err:    at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
01-31 18:51:01.409 17374 17402 W System.err:    at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707) 
01-31 18:51:01.409 17374 17402 W System.err:    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527) 
01-31 18:51:01.409 17374 17402 W System.err:    ... 24 more 
01-31 18:51:01.411   364  3793 I BufferQueueProducer: [SurfaceView -com.crm/javafxports.android.FXActivity](this:0x7549311800,id:2793,api:1,p:17374,c:364) new GraphicBuffer needed

enter image description here

Community
  • 1
  • 1
  • Can you deploy your app to mobile? If you do, what is `localhost`? Where is the database? – José Pereda Jan 31 '19 at 14:26
  • yes i can deploy into my mobile , the local host is mysql services in my laptop with the database name crmywa – wael abdelwahid Jan 31 '19 at 14:30
  • But your mobile, which may be in the same local network as your desktop, doesn't know about that, you will need to set a static IP, won't you? – José Pereda Jan 31 '19 at 14:32
  • no in the same local network the same thing when i put the static ip i change the ip now from localhost to *192.168.43.13* – wael abdelwahid Jan 31 '19 at 14:35
  • You have to set an IP either way, please update your question with it. Also add some System.out to print to console some of the steps, like the results of the connection. Then use `adb` to read them, and see if something is wrong. – José Pereda Jan 31 '19 at 14:40
  • ok sir i will send to you the result – wael abdelwahid Jan 31 '19 at 14:41
  • dear jose i update my question with adb logcat check pleas but after i put the static ip in my connection now the app on my mobile is showing black screen when i open it – wael abdelwahid Jan 31 '19 at 15:55
  • I guess the exception from the logcat is clear enough: there is an unsupported exception with the mySql driver. This is why I asked before if it was working on mobile. See this [answer](https://stackoverflow.com/questions/33485466/javafxports-mysqldb-driver-include-in-project-dex-error/33599574#33599574) for a possible fix. But anyway you shouldn't run mysql from your mobile. Instead you could use [SQLite](https://stackoverflow.com/questions/33655851/javafxports-and-sqlite-on-android-device/33656274#33656274) or use a REST service to access the backend. – José Pereda Jan 31 '19 at 16:36
  • Dear @jose pereda thank you for support my question but what is the rest service access? And if you have ready class for connection by SQLit I will appreciate you – wael abdelwahid Jan 31 '19 at 19:23
  • If you have a backend with your database, you can create a RESTful web service, and then consume it from your client app. You can check Gluon Connect for that. You can find samples for SQLite and for Connect [here](https://gluonhq.com/developers/samples/). – José Pereda Jan 31 '19 at 19:33
  • dear @JoséPereda my project now is working check my edit question but i have small issue look at to the second image i uploaded when i take the data by Arabic language – wael abdelwahid Feb 01 '19 at 11:32

1 Answers1

0

the problem for the app is not open on my phone i solve it by this syntax on mysql :

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;

then you most add the new user into your database

and is working very well

i took it from this link : HOST 192.168.--- not allowed to connect Mysql server

and my build.gradle :

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.3.16'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.crm.CRM'

dependencies {
    compile 'mysql:mysql-connector-java:3.1.12'
}

jfxmobile {
    downConfig {
        version = '3.8.6'
        // Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
        plugins 'display', 'lifecycle', 'statusbar', 'storage'
    }
    android {
        javafxportsVersion = '8.60.11'
        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/NOTICE.txt'  
            exclude 'META-INF/rxjava.properties'
            exclude 'META-INF/spring.schemas'
            exclude 'META-INF/INDEX.LIST'
        }   
        //        compileSdkVersio=28
        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.**.*'
        ]
    }
}