0

I'm creating an app using gluon Mobile (JavaFX), I'm trying to run a login:

Imagem_Login

Controller:

public class PrimaryPresenter {

    @FXML
    private View primary;

    @FXML
    private Label lblLogin;

    @FXML
    private TextField tfEmail;

    @FXML
    private PasswordField tfSenha;

    @FXML
    private Button btnLogin;

    @FXML
    private Button btnSignUp;

    @FXML
    private Label label1;

    public void initialize() {
        primary.showingProperty().addListener((obs, oldValue, newValue) -> {
            if (newValue) {
                AppBar appBar = MobileApplication.getInstance().getAppBar();
                appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> 
                MobileApplication.getInstance().showLayer(AplicacaoMain.MENU_LAYER)));
                appBar.setTitleText("Primary");
                appBar.getActionItems().add(MaterialDesignIcon.SEARCH.button(e -> 
                System.out.println("Search")));

            }
        });
    }

    @FXML
    void login(ActionEvent event) {
        try {
            Usuario usuario = new Usuario(tfEmail.getText(), tfSenha.getText());        
            UserDAO userDAO = new UserDAO();
            userDAO.signIn(usuario);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @FXML
    void signUp(ActionEvent event) {

 //     if(tfEmail.getText().isEmpty() && tfSenha.getText().isEmpty() == false ) {
            new SecondaryView("Secondary View").getView();
   //   } else {
    //      lblLogin.setText("Error");
        //}

    }

}

Using the method to log UserDAO:

private FirebaseAuth autenticacao;

    private FirebaseAuth.AuthStateListener autenticacaoListener;

    private FirebaseUser usuarioFirebase;    

public void signIn(Usuario usuario) {
            autenticacao.signInWithEmailAndPassword(usuario.getEmail(), usuario.getPswd())
                        .addOnCompleteListener(new OnCompleteListener<AuthResult>() {

                            @Override
                            public void onComplete(Task<AuthResult> task) {

                                if(!task.isSuccessful()) {
                                    System.out.println("Passed");

                                    usuarioFirebase = FirebaseAuth.getInstance().getCurrentUser();
                                    if(usuarioFirebase != null) {

                                        //dados importantes do usuario
                                        System.out.println(usuarioFirebase.toString());

                                    }
                                }

                            }
                        });
        }

The following error occurs:

GRAVE: javafx.platform is not defined. Desktop will be assumed by default.
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
    at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Node.fireEvent(Node.java:8413)
    at javafx.scene.control.Button.fire(Button.java:185)
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:417)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    at com.sun.glass.ui.View.notifyMouse(View.java:937)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$48(GtkApplication.java:139)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
    at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
    ... 52 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
    at com.joaodjunior.applicacao.views.PrimaryPresenter.login(PrimaryPresenter.java:62)
    ... 62 more
Caused by: java.lang.NullPointerException
    at com.joaodjunior.model.users.UserDAO.signIn(UserDAO.java:72)
    at com.joaodjunior.applicacao.views.PrimaryPresenter.login(PrimaryPresenter.java:60)
    ... 62 more

I imagine it is due to the app not having found the .json service file, but when trying to build with the gradle, it can not insert.

Gradle_Home:

apply plugin: 'base'

buildscript {

    repositories {
        jcenter()
        mavenLocal()
        maven { url 'https://maven.google.com'  }
    }
    dependencies {
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

Gradle_APP

apply plugin: 'com.android.application'

configurations {
    download
    testDownload
}

task cleanDownloadedDependencies(type: Delete) {
     delete fileTree('libs/compile/downloaded') 
} 

task cleanDownloadedTestDependencies(type: Delete) {
    delete fileTree('libs/testCompile/downloaded')
} 

task downloadDependencies(type: Copy) {
    from configurations.download into "libs/compile/downloaded/"
} 

task downloadTestDependencies(type: Copy) {
    from configurations.testDownload into "libs/testCompile/downloaded/"
} 

task updateDependencies {
    dependsOn cleanDownloadedDependencies, cleanDownloadedTestDependencies, downloadDependencies, downloadTestDependencies
}

buildscript {

    repositories {
        jcenter()
//        mavenLocal()
//        maven { url 'https://maven.google.com'  }
    }
    dependencies {
        classpath 'com.google.gms:google-services:3.1.0'
        classpath 'org.javafxports:jfxmobile-plugin:1.3.10'
    }
}
apply plugin: 'org.javafxports.jfxmobile'

repositories {
    flatDir {
        dirs 'libs'
    }
    jcenter()
    maven { url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'}
    maven { url 'https://maven.google.com'  }
    maven { url 'https://maven.fabric.io/public' }
}

mainClassName = 'com.joaodjunior.applicacao.AplicacaoMain'

apply  plugin   :   'java'
apply  plugin   :   'eclipse' 

allprojects {
    repositories {
        jcenter()
        mavenLocal()
        maven { url 'https://maven.google.com'  }
        maven { url 'https://maven.fabric.io/public' }
    }
}

dependencies {

//  implementation fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.gluonhq:charm:4.4.1'
    compile 'com.google.firebase:firebase-core:11.0.4'
    compile 'com.google.firebase:firebase-auth:11.8.0'
    compile 'com.google.firebase:firebase-auth:10.0.1'
    //compile 'com.firebaseui:firebase-ui-auth:3.1.2'

    compile 'com.firebase:firebase-client-android:2.4.0'
    compile 'com.google.android.gms:play-services-auth:11.8.0'

    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.google.android.gms:play-services:10.0.1'
    compile "com.google.android.gms:play-services-base:9.8.0"

    compile group: 'com.google.android', name: 'android', version: '4.1.1.4'

    compile group: 'org.scream3r', name: 'jssc', version: '2.8.0'
    compile group: 'org.olap4j', name: 'olap4j', version: '1.2.0'
    compile group:'com.google.firebase', name: 'firebase-database', version: '11.8.0'
    download('com.firebaseui:firebase-ui-database:3.0.0')
    compile fileTree(dir: 'libs/compile', include: '**/*.jar')
    testCompile fileTree(dir: 'libs/testCompile', include: '**/*.jar')
}

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 {
        minSdkVersion '19'
        compileSdkVersion '27'
        targetSdkVersion '27'
        manifest = 'src/android/AndroidManifest.xml'

        defaultConfig {
            applicationId "com.joaodjunior.application"
            minSdkVersion 14
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"

        }
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonapplication.**.*',
                'com.gluonhq.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}

project.afterEvaluate {
    explodeAarDependencies(project.configurations.compile)
}

apply plugin: 'com.google.gms.google-services'

Log.

Working Directory: /home/joaojunior/eclipse-workspace/FirePlantMobile/FirePlantMobileApp
Gradle User Home: /home/joaojunior/.gradle
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 2.14.1
Java Home: /usr/lib/jdk-oracle
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
Gradle Tasks: run

please apply google-services plugin at the bottom of the build file.
:FirePlantMobileApp:compileJava UP-TO-DATE
:FirePlantMobileApp:processResources UP-TO-DATE
:FirePlantMobileApp:classes UP-TO-DATE
:FirePlantMobileApp:compileDesktopJava UP-TO-DATE
:FirePlantMobileApp:processDesktopResources UP-TO-DATE
:FirePlantMobileApp:desktopClasses UP-TO-DATE
:FirePlantMobileApp:runjan 01, 2018 7:47:44 PM com.gluonhq.charm.down.Platform <clinit>
GRAVE: javafx.platform is not defined. Desktop will be assumed by default.

and when configuring following the configuration of the firebase, the following happens:

Working Directory: /home/joaojunior/eclipse-workspace/FirePlantMobile/FirePlantMobileApp
Gradle User Home: /home/joaojunior/.gradle
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 2.14.1
Java Home: /usr/lib/jdk-oracle
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
Gradle Tasks: run


FAILURE: Build failed with an exception.

* Where:
Build file '/home/joaojunior/eclipse-workspace/FirePlantMobile/FirePlantMobileApp/build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':FirePlantMobileApp'.
> Failed to apply plugin [id 'com.android.application']
   > Gradle version 2.2 is required. Current version is 2.14.1. If using the gradle wrapper, try editing the distributionUrl in /home/joaojunior/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 8.57 secs
  • This is not a common NPE, in fact I can not configure the project to use the firebase. – João Junior Jan 02 '18 at 00:41
  • Is the problem that the properties file is not in the project? Is it that it is not included in the APK? Have you tried to fix the gradle problem ... by upgrading as it suggests? – Stephen C Jan 02 '18 at 01:22
  • I tried to change in the properties, however it error: Missing androidSDK And the file is in the root of the app and even then, it does not even apply the services plugin. =( – João Junior Jan 02 '18 at 14:42

0 Answers0