Twitter Login working fine, but keeps asking API key [Android]


#1

Hello,

I have managed to implement twitter login in my Android application. Everything works fine so I’m just trying to keep it clean.

For now I only need to use the Login with Twitter feature, so I followed the instructions indicated here: https://dev.twitter.com/twitter-kit/android/twittercore

As I said, everything is working fine, but everytime my application starts I ge the following error:

E/Fabric  ( 8859): Error dealing with settings
E/Fabric  ( 8859): java.lang.IllegalArgumentException: Fabric could not be initialized, API key missing from AndroidManifest.xml. Add the following tag to your Application element 
E/Fabric  ( 8859):     <meta-data android:name="io.fabric.ApiKey" android:value="YOUR_API_KEY"/>
E/Fabric  ( 8859):     at io.fabric.sdk.android.services.common.ApiKey.logErrorOrThrowException(ApiKey.java:93)
E/Fabric  ( 8859):     at io.fabric.sdk.android.services.common.ApiKey.getValue(ApiKey.java:44)
E/Fabric  ( 8859):     at io.fabric.sdk.android.services.settings.Settings.initialize(Settings.java:68)
E/Fabric  ( 8859):     at io.fabric.sdk.android.Onboarding.doInBackground(Onboarding.java:80)
E/Fabric  ( 8859):     at io.fabric.sdk.android.Onboarding.doInBackground(Onboarding.java:26)
E/Fabric  ( 8859):     at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:46)
E/Fabric  ( 8859):     at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:11)
E/Fabric  ( 8859):     at io.fabric.sdk.android.services.concurrency.AsyncTask$2.call(AsyncTask.java:294)
E/Fabric  ( 8859):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/Fabric  ( 8859):     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
E/Fabric  ( 8859):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/Fabric  ( 8859):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/Fabric  ( 8859):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/Fabric  ( 8859):     at java.lang.Thread.run(Thread.java:818)

I tried adding that in my manifest file, using my consumer key as the value, and I get the following error instead:

03-24 13:34:38.451  10250-10268/... E/Fabric﹕ Unknown error while loading Crashlytics settings. Crashes will be cached until settings can be retrieved.
    org.json.JSONException: No value for app
            at org.json.JSONObject.get(JSONObject.java:389)
            at org.json.JSONObject.getJSONObject(JSONObject.java:609)
            at io.fabric.sdk.android.services.settings.DefaultSettingsJsonTransform.buildFromJson(DefaultSettingsJsonTransform.java:24)
            at io.fabric.sdk.android.services.settings.DefaultSettingsController.loadSettingsData(DefaultSettingsController.java:66)
            at io.fabric.sdk.android.services.settings.DefaultSettingsController.loadSettingsData(DefaultSettingsController.java:47)
            at io.fabric.sdk.android.services.settings.Settings.loadSettingsData(Settings.java:139)
            at io.fabric.sdk.android.Onboarding.doInBackground(Onboarding.java:80)
            at io.fabric.sdk.android.Onboarding.doInBackground(Onboarding.java:26)
            at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:46)
            at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:11)
            at io.fabric.sdk.android.services.concurrency.AsyncTask$2.call(AsyncTask.java:294)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)

I don’t understand why I get this error if everything is working fine.


#2

Hi NoelDeMartin,

This error is referring to the Fabric apiKey, which is different from the Twitter consumer key and secret. To get your Fabric apiKey:

Refer to your organization settings <https://fabric.io/settings/organizations>_ to obtain your API key and build secret.

Next, copy this value into your AndroidManifest.xml file.

If you’re still having problems, you can email support@fabric.io.

Lien


#3

Hi @lientm thanks for the reply :).

Yes I kind of guessed it had something to do with that. But my question is different, I was wondering why is it throwing that error on the first place, if my login is working correctly. Which operation is it trying to perform that needs the Api key? I would prefer to disable whatever it is trying to do in order to remove any overhead. Or at least I would like to know what is it doing.


#4

Hi @NoelDeMartin,

Twitter kit is built on top of the Fabric platform, so it needs the Fabric Api key to talk to fabric for its settings.

Lien


#5

Agree with NoelDeMartin, that’s really weird to have an extra key just to get TwitterCore to work. Is there any information available on why it’s needed and how it’s used?


#6

My app have same problem.
I use gradle dependencies to import Twitter SDK to my project. It works well but have exception at logcat.

    java.lang.IllegalArgumentException: Fabric could not be initialized, API key missing from AndroidManifest.xml. Add the following tag to your Application element
    <meta-data android:name="io.fabric.ApiKey" android:value="YOUR_API_KEY"/>

Just want to know why we have to add Fabric key to use Twitter SDK.


#7