Firebase在胶子移动项目中找不到配置文件

时间:2018-01-01 22:49:32

标签: java android firebase gluon-mobile

我正在使用gluon Mobile(JavaFX)创建应用,我试图运行登录:

Imagem_Login

控制器:

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");
        //}

    }

}

使用该方法进行记录 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());

                                    }
                                }

                            }
                        });
        }

发生以下错误:

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

我想这是因为应用程序没有找到.json服务文件,但是当尝试使用gradle构建时,它无法插入。

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'

日志。

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.

并且在配置firebase的配置时,会发生以下情况:

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

0 个答案:

没有答案