java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions

Published on

Getting Exception java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions after updating to the new firebase If you haven’t already, update your ‘Google Play Services’ to Revision 30 from Android SDK Manager > Extras. And then add the line compile ‘com.android.support:multidex:1.0.1’ to your dependancies (or simply remove multiDexEnabled true if not required) Add this attribute to the application tag in manifest: … Continue reading java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions

HashMap vs Hashtable in java?

Published on

Differences between HashMap and Hashtable in Java: Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones. Hashtable does not allow null keys or values. HashMap allows one null key and any number of null values. One of HashMap’s subclasses is LinkedHashMap, … Continue reading HashMap vs Hashtable in java?

How to access unique Android device ID using JAVA?

Published on

How to get unique device hardware id in Android? Settings.Secure#ANDROID_ID returns the Android ID as an unique 64-bit hex string. import android.provider.Settings.Secure; private String android_id = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID); —————————————————-/OR/————————————————– Get Unique ID of Android Device? There are many answers to this question, most of which will only work “some” of the time, and unfortunately that’s … Continue reading How to access unique Android device ID using JAVA?

How to use retrofit without model class?

Published on

Yes, you can. @POST(“url”) Call<JsonObject> register(@Query(“name”) String name, @Query(“password”) String password); Just write JsonArray or JsonObject according to your response instead of Model class. Then, get data from JsonObject or JsonArray which you get in response as below Call<JsonObject> call = application.getServiceLink().register(); call.enqueue(new Callback<JsonObject>() { @Override public void onResponse(Call<JsonObject> call, Response<JsonObject> response) { JsonObject object … Continue reading How to use retrofit without model class?

How to wrap checked exceptions but keep the original runtime exceptions in Java

Published on

I use a “blind” rethrow to pass up checked exceptions. I have used this for passing through the Streams API where I can’t use lambdas which throw checked exceptions. e.g We have ThrowingXxxxx functional interfaces so the checked exception can be passed through. This allows me to catch the checked exception in a caller naturally … Continue reading How to wrap checked exceptions but keep the original runtime exceptions in Java