Category: Programming

  • Android Studio automatically adds Contacts permission

    After updating my Fuel Log app to take advantage of Android 6.0 (Marshmallow) run-time permissions, I noticed that app’s permission page (Settings > Apps > [app name] > Permissions) contains Contacts permission that is not present AndroidManifest.xml (nor anywhere else within my app).

  • Uploading existing Android Studio project to SVN (Subversion)

    I develop few Android apps during my spare time and until now I have been syncing project folders between my Synology NAS and PCs/Laptops using excellent Beyond Compare. Finally, I decided to get a bit more sophisticated and started using Subversion (SVN) to sync and track my dev projects. It’s been quite some time since I…

  • Android WRITE_EXTERNAL_STORAGE permission requires app restart – EACCES (Permission denied)

    Currently working to implement new Android 6.0 (Marshmallow) run-time permission model for one my apps. During testing on the emulator I found quite annoying bug. When user grants WRITE_EXTERNAL_STORAGE on-demand permission, the app still cannot write (nor read) from external storage. For permission changes to take affect you have to kill and restart the app. Found a related bug…

  • Unable to find optional library – org.apache.http.legacy

    Android Studio suddenly (and for no apparent reason) started complaining that it could not find org.apache.http.legacy (which was added to build.gradle as a legacy library). Warning: Unable to find optional library: org.apache.http.legacy The issue was caused by a missing optional.json file that was supposed to be located in Android SDK folder …AndroidSDK\platforms\android-23\optional

  • org.apache.http stops working in Android SDK 23

    Issue A project no longer compiles in Android Studio after switching from Android SDK v22 to v23. The compiler complains that it can not resolve symbol HttpClient, or that package org.apache.http does not exist.

  • Google Play Services automatically add new permissions

    Issue After upgrading Google Play Services from 6.1.11 to 7.5.0, bunch of new permissions are automatically added to the application’s manifest. The app actually only uses Admob (Google Mobile Ads) libraries from Google Play Services and permissions such as “ACCESS_COARSE_LOCATION”, “ACCESS_ACCOUNTS”, “USE_CREDENTIALS” are completely unnecessary.

  • Android – Some UTF-8 characters get lost during HttpPost

    Issue Some non ASCII characters get lost when submitting HttpPost (or HttpPut) requests to a remote web service. All text after the problematic character also gets stripped out.There were no issues on the server side as other clients could submit any non standard characters without any issues.

  • PHP json_encode() fails with error “Invalid UTF-8 sequence in argument”

    Issue PHP / MySQL web service fails to return JSON encoded data when it contains some non standard ASCII characters. Text in MySQL looks correctly and database has “utf8_unicode_ci” collation.The issue occurs while running json_encode() function. The web service returns following error: Type : Error ExceptionMessage: json_encode(): Invalid UTF-8 sequence in argument

  • Android – getActionBar() returns null after upgrading to SDK 21

    I was working on a new app in Android Studio Beta with target SDK 20. It was all well and good, but after updating target SDK version to 21 (and appcompat-v7 to 21.0.0) the app started crashing on launch. Quick debugging revealed that the issue was cased by the line of code actionBar = getActionBar(); inside…

  • Android – hiding ActionBar icon and title during launch

    I was developing an app that had a tabbed interface (FragmentPagerAdapter) inside the main activity. Each tab was setting different ActionBar icon and title inside onTabSelected method. Something like this: @Overridepublic void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {   viewPager.setCurrentItem(tab.getPosition());   if (tab.getPosition() == 0){      actionBar.setTitle(“title1”);      actionBar.setIcon(R.drawable.icon1);   }   if (tab.getPosition() == 1) {     …