The problem is that this line of code is producing an error: And the error says: Type mismatch.Required:ActivityMainBindingFound:ViewDataBinding! The solution is to add a <layout> tag in the layout file that you are inflating!
Android
Error inflating class androidx.fragment.app.FragmentContainerView // Android Kotlin Dev Diary
The cause of error in Logcat: The fix was to add a startDestination to <navigation> tag in the nav_graph.xml.
Expand ScrollView vertically if height is smaller than screen // Android Dev Diary
I have the following XML layout code in an Android app that I’ve been tinkering with: I wrapped my GridLayout in a ScrollView because on the landscape orientation of the Android app’s screen, my grid contents are cut from the view because they’re too tall, and there’s no way to see them without a scrollbar, […]
DataBinderMapperImpl Error: cannot find symbol (DataBinding) //Android Kotlin Dev Diary
Today I encountered the following error as I was building an Android app: Turns out, there’s an error in the related XML file, activity_main.xml! 😂 For other possible solutions, this StackOverflower answer may help: android: data binding error: cannot find symbol class
Cannot access ‘‘: it is private in ‘MoshiConverterFactory’ //Android Kotlin Dev Diary
I’m starting a new category on my blog — Dev Diary, to document some of the errors that I encounter and what I did to fix them. I’m doing this in hopes of helping developers (including my future self!) as they work with code (and to get more blog visits! LOL). It’s nice to save […]
Android app dev: Intent extras set in onBackPressed() misssing when back to onActivityResult()
It’s funny how we spent about an hour trying to figure out why the Intent extras that we’re setting are not being sent back to onActivityResult(). If we only knew that the solution was as simple as moving one line of code. The call to super.onBackPressed() should be placed after setting Intent extras and after […]
Add “options menu” to an AppCompatActivity (Android App Development)
Adding an “options menu” to an Android app’s Activity is quite simple. This is an example of what an Android options menu looks like. Look at the icon that looks like 3 dots vertically stacked. My dev environment status as of writing this Android Studio version: v. 2.1 OS: Mac OS X El Capitan v. […]
Java: method to convert degrees into directions (16-wind compass rose)
I’m working on a weather app for Android. The data for wind direction that I get from the weather API is in form of degrees (0 to 360). I want to display wind direction in a user-friendly format such as N (North), NNE (North-northeast), NE (Northeast), ENE (East-Northeast), E (East), ESE (East-Southeast), SE (Southeast), SSE […]
Android Maps: Get current location coordinates with Google API Client Builder
To get your current location via Google Map in an Android app, this was how we do it:
1 2 3 4 |
@Override public void onMapReady(GoogleMap googleMap) { Location location = googleMap.getMyLocation(); } |
Stop. Don’t use that! The method GoogleMap.getMyLocation() is deprecated. Instead, we need to use FusedLocationApi and the callback onLocationChanged(). Here’s an example code that works for me ( consider copying the contents of onResume() into onStart() […]
Android Studio and the 64K methods limit (DEX error)
Hi! I’ll share a few tips with you on how to find out the number of methods that your Android app has. I’m gonna show you a few tools such as APK file methods counter, and an Android plugin that will show you the number of methods each imported class or dependency has. These will […]