Tag: Mobile phone

Programming Stuff

Android Studio Bug Workaround – Project breaks when copied or moved

Since I write training courses about Android development, I frequently have to copy projects from one folder to another. I commonly create a project in a “before” folder, copy the project to an “after” folder, and then do the work being discussed in the course in the project in the “after” folder. When students view the course they can download “before” and “after” copies of the project.

Well one of the pains I’ve been dealing with in the preview release of Android Studio is the fact that when a project is copied from one folder to another, the project keeps pointers to the original folder. One ends up with a mess where some things in the new project point to the new folder and somethings point to the old. Deleting the original folder makes things even worse.

I’ve reported the issue as an Android Studio bug. It appears to have been accepted as an issue but as of this writing the version of Android Studio currently available still has the problem.

The version available as of this writing…

AndroidStudioAbout_AI-130.700763

I’m certain this is an issue that will be addressed so if you’re reading this post substantially beyond the posting date, verify that the problem still exists before doing the steps I list here.

OK so the workaround…

UPDATE: The day after I made this post, I figured out a simpler work around. Please see this post for the new workaround.

The solution I’ve found is to modify the path information contained in 4 of the project files in the destination folder.

Before doing anything, be sure Android Studio is completely closed.

Let’s make the following Assumptions in copying our project to a new folder.

  • The project name is:
    AndroidExample
  • Original project folder:
    C:\Demo\before\AndroidExampleProject
  • Destination project folder:
    C:\Demo\AFTER\AndroidExampleProject

Note: I’m including line numbers just as estimates. Your line numbers will almost definitely be different.

1. File: C:\Demo\AFTER\AndroidExampleProject\AndroidExampleProject.iml (approx. line 7)

Change:

<option name="PROJECT_ABSOLUTE_PATH" value="C:\Demo\before\AndroidExampleProject" />

To:

<option name="PROJECT_ABSOLUTE_PATH" value="C:\Demo\AFTER\AndroidExampleProject" />

2. File: C:\Demo\AFTER\AndroidExampleProject\.idea\gradle.xml (approx. line 6)

Change:

<option name="externalProjectPath" value="C:\Demo\before\AndroidExampleProject\build.gradle" />

To:

<option name="externalProjectPath" value="C:\Demo\AFTER\AndroidExampleProject\build.gradle" />

3. File: C:\Demo\AFTER\AndroidExampleProject\.idea\workspace.xml(approx. line 207)

Note: The “option” element you’re changing will be a child of the “ExternalProjectPojo” element

Change:

<option name="path" value="C:\Demo\before\AndroidExampleProject\build.gradle" />

To:

<option name="path" value="C:\Demo\AFTER\AndroidExampleProject\build.gradle" />

4. File: C:\Demo\After\AndroidExampleProject\AndroidExample\AndroidExample.iml(approx. line 15)

Change:

<option name="PROJECT_ABSOLUTE_PATH" value="C:\Demo\before\AndroidExampleProject" />

To:

<option name="PROJECT_ABSOLUTE_PATH" value="C:\Demo\AFTER\AndroidExampleProject" />

5.
Now open the project in Android Studio

You may be prompted with a dialog indicating that it’s removing a non-existent project. Let it do that. It’s just cleaning up some internal data, it doesn’t appear to have any impact on the original project.

Voila! We now have a copy of our project.

The best news of all … I’m pretty sure that the bug that’s causing us to have to go through all of these steps (rather than simply copying the project folder) is a bug that will soon be fixed.

For information on getting started developing Android applications or working with Android Studio, checkout Jim’s Android programming courses on Pluralsight including his latest course.

Android for .Net Developers Series - Getting Started

Programming Stuff

Android Studio Power Save Mode

Have you noticed a shortening of your laptop’s battery life when working with Android Studio?

Android Studio is a great tool and some of the great things it does require fairly substantial processing to occur in the background. Much of this processing is constantly firing  performing what are called Inspections.

To get a sense of the kind of background work that’s going on, choose Project Settings from the Android Studio menu and then highlight Inspections in the Project Settings pane.

Android Studio Inspection Settings

To save power we could go through and turn off some of these inspections so that less background processing occurs. These inspections are good stuff, though. I prefer to have these checks available. Fortunately, Android Studio doesn’t require us to make this choice.

Android Studio gives us the option of stopping the automatic checks and instead running them on demand. You can prevent these inspections from automatically running by selecting Project Power Save Mode in the Android Studio menu.

You can then run the checks manually by choosing Analyze \ Inspect Code… from the Android Studio menu.

With this, we get the benefit of Android Studio code inspection while still maximizing our laptop battery life.

For information on getting started developing Android applications or working with Android Studio, checkout Jim’s Android programming courses on Pluralsight including his latest course.

Android for .Net Developers Series - Getting Started

Programming Stuff

Android Studio 0.1.2 Is WAY more stable

The stability of the  initial preview release of Android Studio (version 0.1) was pretty impressive. Being built on a long-standing product like JetBrains Intellij IDEA gave it a great start.

That said, it did at times feel like a version 0 product … unexpected message boxes popping up, strange behavior in the feature that displays the string value where string resources are used (sometimes didn’t work .. sometimes showed the string value on a different line than where the resource appeared), those sort’a things.

About a week or so after the initial release Android Studio automatically updated to Android Studio 0.1.1 and there was some improvement but not a huge amount.

Well then yesterday, I received another update, Android Studio 0.1.2 (Build #AI-130.692269) … I’ve only been using it for less than 24 hours but so far this build feels MUCH MUCH better. It’s feeling much more stable.

AndroidStudioAbout_0.1.2

If you haven’t already done so, I encourage you to download Android Studio and start checking it out. I’m sure there will still be some issues but it’s improving quickly and IMHO is already so much better than using Eclipse that any minor annoyances are a small price to pay to have such a superior dev tool.

For information on getting started developing Android applications or working with Android Studio, checkout Jim’s Android programming courses on Pluralsight including his latest course

AndroidDotNetSeries_GettingStarted_Logo

Programming Stuff

Android Studio Dark Theme (Darcula)

After seeing those cool demos of Android Studio showing the neat-looking dark theme, the default theme that Android Studio downloads with can be a little disappointing.

If you haven’t seen it, here’s Android Studio set to the Darcula theme.

Android Studio Darcula Theme

To get the Darcula theme, first open the Android Studio Settings dialog

  1. Select File on the Android Studio menu
  2. Then select Settings

Once on the Settings screen just…

  1. Highlight Appearence
  2. Click on the Theme dropdown and select Darcula
  3. Click OK

Setting Darcula Theme

You’ll be prompted to restart Android Studio. Allow the restart and there you have it. The great look of Android Studio in Darcula.

Adapted from Jim’s Pluralsight course Android for .NET Developers: Getting Started

AndroidDotNetSeries_GettingStarted_Logo

Programming Stuff

Android for .NET Developer Series: Getting Started

There’s no question that smartphones and tablets have become the computers of choice for most users. Android has been the leading smartphone for some time and now Android leads in tablets as well.

According to Google, nearly 900 million Android devices have been activated. This presents an incredible opportunity for both individual developers and organizations to create software with a reach and impact beyond anything previously possible.

Android development is, of course, very different from the web-based and/or desktop app development most of us have been doing for years. But this difference doesn’t mean we can’t take part in such a great opportunity.

People will often point to Android’s use of Java rather than .NET being the biggest challenge in becoming an Android developer. I disagree. If that were the case, environments like Mono that enable the use of C# and .NET libraries on Android would enable us all to immediately become Android developers. But in my experience, developers with a .NET background who use Mono don’t become effective Android developers any faster than those who take the plunge and use Java. Why is that?

The challenge in creating Android apps is not the programming language, class libraries, or runtime. The challenge in creating Android apps is that it’s an entirely different way of thinking and an entirely different approach to application development.

To be successful on such a different platform, developers need to adopt and ultimately embrace the way-of-thinking of the Android platform.

The new series from Pluralsight, Android for .NET Developers, strives to do exactly that. We focus on guiding developers to fully embrace the tools, language, libraries and, most importantly, mindset of Android development by building on your skills as a .NET developer. Although this series assumes a .NET background, the series is appropriate for anyone with existing programming experience who wants to start working with Android.

In the first course in the series, Android for .NET Developers: Getting Started, we walk through the process of setting up your environment, using the Android development tools, and deploying apps to both real devices and emulators. We talk briefly about the long-standing development environment, Eclipse, but focus throughout the series on the new development environment, Android Studio, announced by Google just a few days ago.

The first course in the series is now available with a new course from the series being released every few weeks. The series is made up of the following courses.

Android for .NET Developers: Getting Started

Android for .NET Developers: Building an Android App

Android for .NET Developers: Android data management

Android for .NET Developers: Adopting the Android mindset

Android for .NET Developers: Embracing the Android platform

I hope you’ll join me in this experience of leveraging your existing skills to empower you to take part in the opportunity offered by the success of Android. At the end of this series, I’m confident that you will have adopted the Android mindset and will be embracing the Android platform.

Android for ,NET Developer Series: Getting Started

Programming Stuff

Android Meetup May 2013 – Android Camera Integration

Thank you to everyone who attended the Central Florida Android Developers Group last night. Special thanks to Echo for hosting the event.

I had the opportunity to talk about how to easily integrate photo capture capability into one’s app by leveraging the built-in Android camera app and Intents.

Last night’s presentation was an excerpt from the first module of my Android Photo and Video Programming course.

You can download the code from last nights discussion. The download includes the Photo capabilities we discussed and also includes Video capability, which we didn’t have time to discuss. Please feel free to post any questions you might have.

For more information on this and other Android-related topics, checkout Jim’s Android courses at Pluralsight.

PSAndroid_216x155

Programming Stuff

Android tops 56% of the Tablet market

What was once thought impossible just happened: Android has displaced iPad as the dominant tablet platform.

As reported by IDC, Android took the tablet market by storm in Q1 with over 56% of the market. During that same period iPad dropped below 40% market share.

Given Androids already overwhelming lead over iOS on Smartphones, it appears that Android is now the undisputed leader in all-things-mobile.

Checkout Jim’s Android developer courses for Pluralsight.

PSAndroid_216x155