Today, when I was uploading new version of EasyFlipView library on jCenter, then I found this strange error which was not rebuilding my whole library module. The error was Execution failed for task ':app:compileDebugJavaWithJavac'. Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_121 contains a valid JDK installation. I tried googling around and found answers on StackOverflow like this and this. I tried different solutions. Here’s the one which was very simple and worked for me in an instant.

Continue reading

Today, I opened a very old project for a quick update. After upgrading the support libraries, gradle plugins and other tools, I saw this strange issue for the first time. The app was building and running successfully, but when I opened any code file, I was getting huge list of compile errors mostly about Unresolved Reference etc. Initially, I cleaned project, rebuild it, restarted Android studio few times, but couldn’t fix it.

Continue reading

Sometimes, we need our TextView change its text size according to the content put in it. But, Android didn’t have much support of it until Android O. And then Android Support library got this feature. Let’s see how it all works. First, you have to add the support library v26 or more in your build.gradle file. implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support:support-v4:26.1.0' Although, it has been introduced in Android Oreo, but through using support library, this feature is backward compatible upto the Android 4.

Continue reading

When debugging apps, we sometimes start putting logging statements all over the code to figure out what’s going on. class MainActivity : AppCompatActivity() { lateinit var retrofit: Retrofit override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) setupToolbar() Log.d("MyApp", "Toolbar Set") initRetrofit() Log.d("MyApp", "Retrofit Initialized") var myButton = findViewById<Button>(R.id.search_close_btn) myButton.setOnClickListener { Log.d("MyApp", "My Button Clicked") } Log.d("MyApp", "Activity Creation Done!") } } That works, but it happens that we forget to remove the logs before committing, and they either get flagged in the code review, or they’re still there when we release.

Continue reading

Although RecyclerView has a very good and smooth scrolling built-in, but when you put into any ScrollView, then your RecyclerView’s scrolling will not work. For example, <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <android.support.v7.widget.RecyclerView android:id="@+id/listRecyclerView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="@dimen/_10sdp" tools:listitem="@layout/activity_type_item_layout"/> </LinearLayout> </ScrollView> Now, the RecyclerView will not scroll. To fix that, you will have to use NestedScrollView instead of ScrollView like this: <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <android.support.v7.widget.RecyclerView android:id="@+id/listRecyclerView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="@dimen/_10sdp" tools:listitem="@layout/activity_type_item_layout"/> </LinearLayout> </android.

Continue reading

A very common task in any android app is to hit any web service call and fetch some data from server. Google have always recommended to perform such heavy or time consuming calls in background thread, as if performed in main thread, these can block the UI and make the app irresponsive Traditionaly, developers use AsyncTask for these sorts of computations. But working with AsyncTask is not only complex and lengthy, but also very frustrating.

Continue reading

When developers need to integrate push notifications in their Android apps, the first thing comes in mind is Firebase Notifications or Firebase Messaging. But when they integrate, there are few common issues which they stuck into. One of those common issues is that the applications doesn’t get push notifications. There are multiple reasons such as Unregistered device token or app is killed or Android Oreo’s doze mode is on etc.

Continue reading

Author's picture

Wajahat Karim

Android Developer. UI/UX Designer. Blogger. Writer. Wantrepreneur. GitHub Geek. Tea Lover

Senior Android Developer

Karachi, Pakistan