Devsig Podcast

Android App Optimisation: Tips and Tools for Better Performance


Listen Later

The article provides tips and tools for optimising Android apps, focusing on performance issues that impact user experience. It highlights the importance of optimisation, noting that 86% of users uninstall apps after a single use due to poor performance. It also notes that users expect apps to load quickly, with 40 out of the top 100 apps starting in under 2 seconds. The article provides a list of performance tips and debugging tools to help improve app performance.Performance Tips:
  • String vs StringBuilder: Using StringBuilder for multiple string appends is more efficient than direct string concatenation due to the immutability of strings.
  • Correct Data Type: Choosing the right data structure (e.g., ArrayList vs. Vector, Set for unique objects) based on the use case can improve performance.
  • Location Updates: Use Google Location Services API, request only the necessary location precision and update frequency, and stop updates when not needed.
  • Network Requests: Batch network requests to minimise battery consumption and mobile data usage. Consider using GCM Network Manager for scheduling tasks.
  • Reflection: Cache responses when using reflection for backward compatibility, as reflection can be slow.
  • Autoboxing: Avoid autoboxing (converting primitive types to Object types) by using primitive types directly or specialised collections like SparseIntArray.
  • OnDraw: Optimise the onDraw() function by avoiding object allocation and minimising drawing operations.
  • ViewHolders: Use the ViewHolder design pattern to smooth scrolling lists by caching view lookups.
  • Resizing Images: Resize images before displaying them to avoid memory issues, and consider using third-party libraries like Picasso, Universal Image Loader, Fresco, or Glide.
  • Strict Mode: Use Strict Mode during development to detect network requests or disk accesses on the main thread, but disable it in production builds.
Debugging Tools:
  • Android Monitor: Built-in tool in Android Studio that provides graphs for Network, CPU, GPU, and Memory usage.
  • GPU Overdraw: Tool in Developer Options that shows overdraw areas with different colours, indicating how many times an area was overdrawn.
  • GPU Rendering: Tool in Developer options that displays coloured bars on the screen, representing the time spent on different rendering phases.
  • Hierarchy Viewer: Tool for getting an overview of view hierarchies and identifying useless views or performance bottlenecks.
The article emphasises that optimising Android apps is complex and requires understanding the trade-offs of different approaches. It recommends staying updated with the latest tools and learning from top developers and companies.
...more
View all episodesView all episodes
Download on the App Store

Devsig PodcastBy Bholendra Singh