3

I'm running Android Studio 0.8.6 and imported two Firebase libraries, to use in my project.

I manage to create objects of Firebase Simple Login classes, and also default Firebase objects. However. When I try to access any method of these object, Android Studio stubbornly says "Cannot resolve symbol ".

This is my code (it's basically Firebase quick start sample code):

Firebase myRef = new Firebase("https://xxxxxxxx.firebaseIO.com/");
SimpleLogin authClient = new SimpleLogin(myRef, this);


authClient.checkAuthStatus(new SimpleLoginAuthenticatedHandler() {
    @Override
    public void authenticated(FirebaseSimpleLoginError error, FirebaseSimpleLoginUser user) {
        if (error != null) {
            // Oh no! There was an error performing the check
        } else if (user == null) {
            // No user is logged in
        } else {
            // There is a logged in user
        }
    }
});

authClient.createUser("email@example.com", "very secret", new SimpleLoginAuthenticatedHandler() {
    public void authenticated(FirebaseSimpleLoginError error, FirebaseSimpleLoginUser user) {
        if(error != null) {
            // There was an error creating this account
        }
        else {
            // We created a new user account
        }
    }
});

It is the methods '.checkOutStatus' and '.createUser' which cannot be resolved.

I've been trying every way descibed here on SO to fix it, but nothing worked out. I also attach my build.gradle file beneath:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 19
    }
}

dependencies {
    // Support Libraries
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile files('libs/firebase-simple-login-1.4.1.jar')
    compile files('libs/firebase-client-jvm-1.0.16.jar')
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

Thanks in advance! :)

user3537089
  • 103
  • 1
  • 2
  • 4
  • Try synchronizing project. – Vasudev Aug 17 '14 at 13:38
  • You don't need .jar files, you can simply add `compile 'com.firebase:firebase-simple-login:1.4.1'` and then Gradle sync - it will automatically download and include lib to your project. – asylume Aug 17 '14 at 13:39
  • @asylume I followed your advice, but gradle sync fails and says: Failed to find: com.firebase:firebase-simple-login:1.4.1 . Any thought why? – user3537089 Aug 17 '14 at 13:55
  • @user3537089 Sorry, just checked maven rep and there is version 1.4.2, so use: `compile 'com.firebase:firebase-simple-login:1.4.2'` – asylume Aug 17 '14 at 13:58
  • @asylume That solved the gradle issue, alright :) but I still cannot access those methods of my firebase objects :( – user3537089 Aug 17 '14 at 14:07
  • I see you switched back to Eclipse ADT, but if you decide to give it another try, could you share the output you see when you attempt to gradle sync? – mimming Aug 20 '14 at 15:54
  • Hi @jenny tong. Gradle sync worked out fine. Android Studio just didn't want to recognize methods from objects made out of classes from my imported libraries. – user3537089 Aug 20 '14 at 16:00
  • Well that is a head scratcher then! Usually Gradle sync is to blame. My next step after that would be to delete the .idea directory and re-create the project (which is a lot less crazy in IntelliJ based IDEs than Eclipse) – mimming Aug 20 '14 at 16:03
  • @JennyTong hmm I think I tried that as well. But will give it one more try as soon as I have time. Thanks for trying :) – user3537089 Aug 20 '14 at 16:08
  • The migration to Android Studio / Gradle can be a tricky one, but it's worth it once you're there and you have the hang of the new tools (and their unique quirks) – mimming Aug 20 '14 at 16:17

2 Answers2

2

For resolving symbol issues, consider if your project has a settings.gradle that is NOT in the root directory, a bug in Android Studio causes it not read submodules correctly.

Here is my answer for another question that sounds similar to yours: https://stackoverflow.com/a/25224773/936067

Community
  • 1
  • 1
jonalmeida
  • 1,206
  • 1
  • 9
  • 24
  • 1
    Thx, but it didn't really work out, so I switched back to Eclipse. Don't have enough time to solve this issue completely, so I'll have to do it later. Anyway, many many thanks for trying to help :) – user3537089 Aug 19 '14 at 17:57
0

To use the Firebase Messaging service you need to add the following dependencies to your app's build.gradle file:

            compile 'com.google.firebase:firebase-messaging:9.4.0'

All other firebase dependency files are :

dependencies {
    apply plugin: 'com.google.gms.google-services'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.firebase:firebase-client-android:2.5.0'
    compile 'com.google.firebase:firebase-messaging:9.4.0'
}

I had the same problem but thanks to this answer:

https://stackoverflow.com/a/39353961/4836759

Community
  • 1
  • 1
Ashu
  • 2,970
  • 1
  • 19
  • 31