7

I have a project in eclipse. I need include firebase library. If I was using Android Studio the steps would simply be:

enter image description here

And its all, all library include.

But I cant understand how include firebase cloud message to eclipse. I cant find how include it to eclipse.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
b1065579
  • 155
  • 1
  • 1
  • 9

5 Answers5

9

The new Firebase (9xx) libraries can be found in the Google Repository. You can install this with the Eclipse Android SDK Manager. Open the SDK manager and scroll down until you find Google Repository and install the package.

The package will be installed in /extras/google/m2repository and you will find the Firebase files further down at /com/google/android/firebase.

You can rename the .aar files to .zip and extract the jar file, rename these from classes.jar and copy them to the project libs folder displayed in Eclipse (or copy outside Eclipse and then follow the instructions to import a project into Eclipse.)

usajnf
  • 522
  • 3
  • 11
  • Extract every single .jar from the .aar files? – Eames Aug 21 '16 at 10:52
  • I have used in eclipse this but i am getting FirebaseMessagingService cannot be resolved to a type, please anyone guide me ? – Achin Oct 01 '16 at 06:52
  • 1
    Extracting the aar files just gives me a Manifest & R.txt file. Which is the one that gives the jar file? – Zen Oct 29 '16 at 22:56
  • @summers some of the .aars have only resources. But the ones you need for messaging have a classes.jar file in them containing the source code for the various methods of FCM. – usajnf Nov 06 '16 at 23:14
  • @Eames The firebase-iid and firebase-messaging are needed for the basic client implementation. – usajnf Nov 06 '16 at 23:15
  • I have followed all above instructions and My app is working with out error..But I am not getting push message...I am sending from firebase dashboard and it is showing completed there but not receiving any push message...onTokenRefresh method never called and onMessageReceived also never called...My manifest file is ok I have not given my services outside the application root...and also given android:enabled="true" android:exported="true"... – Manoj Behera Nov 22 '16 at 09:18
  • I included the libraries common, iid and messaging in my project, create the service classes which extend from FirebaseInstanceIdService and FirebaseMessagingService and added them in my manifest. I can create an Instance of my Services, which means the super classes of my Services should be available. But now I have the problem, that I get a ClassNotFoundException when I call this method: FirebaseInstanceId.getInstance().getToken() Does anyone know what the problem could be? – Roman Nov 24 '16 at 14:40
  • I m facing the same problem. I have added all 3 classes.jar files of iid, messaging and common firebase. It is not giving error. But when i run the code it is giving ClassNotFoundException. Someone please help me with this. – R.R.M Mar 11 '17 at 06:30
2

There is a move towards Android Studio with Gradle. The Eclipse solution to Firebase CM is not forthcoming. My feeling is we will all have to move to AS with Gradle soon. There are good books on it and very simple instructions on Google dev sites. We might as well start learning the new IDE and migrate.

usajnf
  • 522
  • 3
  • 11
  • 6
    The main problem is that on some machines Gradle takes too long to build even in offline mode, that's why personally i don't use android studio anymore, it's almost the same, but testing the app takes way too much longer in AS than in Eclipse, Eclipse still the fastest in my opinion – Homombi Jul 31 '16 at 20:44
  • Yep. Did you figure out how to import firebase on Eclipse? – Zen Oct 29 '16 at 22:21
  • Same instructions as in the answer above this one. The firebase-iid and firebase-messaging are needed for the basic client implementation. When you open the archive you will see classes.jar which will have to be renamed before importing to Eclipse or they will overwrite each other! – usajnf Nov 06 '16 at 23:08
  • I have followed all above instructions and My app is working with out error..But I am not getting push message...I am sending from firebase dashboard and it is showing completed there but not receiving any push message...onTokenRefresh method never called and onMessageReceived also never called...My manifest file is ok I have not given my services outside the application root...and also given android:enabled="true" android:exported="true" – Manoj Behera Nov 22 '16 at 09:18
2

You can add this on your Android Manifest

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 
<receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="YOUR PACKAGE NAME" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
            android:exported="false" />

And then you can get the token and try to send Message on.

Dont forget also to build FirebaseApps on your code (in my case on my MainActivity)

FirebaseOptions options = new FirebaseOptions.Builder()
    .setApiKey("YOUR FIREBASE API KEY")
    .setApplicationId("YOUR FIREBASE APP ID")
    .setGcmSenderId("YOUR FIREBASE SENDER ID")
    .build();

FirebaseApp myApp = FirebaseApp.initializeApp(getApplicationContext(), options);
        token = FirebaseInstanceId.getInstance(myApp).getToken();

Hope it will get what you looking for on Eclipse.

Yuw
  • 55
  • 1
  • 12
  • 1
    Thank you for this info. When I call the FirebaseOptions.Builder(), I get a NoClassDefFoundError with this Info: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzac" on path: DexPathList Do you know what this error could be? – Roman Nov 29 '16 at 15:04
  • @Roman, have you try to put all jar u need on libs and google play libs on your dependency? – Yuw Nov 30 '16 at 03:45
  • I've already included the firebase common, iid and messaging jars. But I don't know which google play libs I need. Tried base and iid now, but I still get the same error. – Roman Nov 30 '16 at 10:33
  • @Roman, can u show your android manifest and your package structure? – Yuw Dec 05 '16 at 08:27
1

Old code is working no need to change code in firebase only change is in server code you have to use Web API Key from firebase project and Sender ID as per old code style. and you have to replace gcm url in web script - https://fcm.googleapis.com/fcm/send

No Requirement of firebase library...

  • I believe this is correct at the moment. The GCM client classes will still work but they are deprecated so are not maintained. FCM client classes will eventually have to be swapped into your client code. – usajnf Nov 06 '16 at 23:10
1

Have a look at the resources below. In short, it's about including the Firebase libraries into your project (see the GitHub project and the two videos at the end) and manually performing the steps that the plugin does for you in Android Studio / Gradle.

Dan Dar3
  • 1,199
  • 13
  • 23