Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Tuesday, November 11, 2014

[Android Studio] Error : Failed to find: com.android.support

It's nice that Google is trying to make a full-fledged Android Authoring Software, complete with what is expected from an authoring tool.  But as of now, the tool itself is in Beta which has a few hiccups hidden somewhere, and one of this is not being able to compile an Android Project. o_o

Like, really?

So if you, like me, had encountered this problem saying:
Error : Failed to find: com.android.support
Relax and open SDK Manager then install the Android Support Repository and/or Android Support Library.  Better yet, install those two. :)

Upon restart of Android Studio, that problem should go away.

Happy hacking!

~creek23

Friday, June 22, 2012

Screencasting with Android

Well, if you are already using the Screencast Video Recorder, there's no use of reading this -- but I'm betting you're not because you stumbled onto this tutorial.

First of all, I am not related to the said screencasting app and I am in no way endorsing it.  I haven't even tried that app yet because 1.) it's not supported on my low-end Android device and 2.) it's a paid app -- yes, I'm cheap, sue me. :P

So this tutorial is about creating a screencast of your Android device using a free and open source tools called Android Screen Capture (or AShot) and FFmpeg.  I should warn you that this tutorial is not for the fainthearted -- it's gonna be messy through setting these tools up, and through creating of the screencast video itself.

I'm going to assume you know what we mean by screencast.  And I'm going to assume you are using Windows on your PC.

To start, download the tools:
AShot - http://sourceforge.net/projects/ashot/files/latest/download
FFmpeg - http://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-20120620-git-5a90e55-win32-shared.7z

Here's a very detailed tutorial of setting-up AShot, which I'm very glad not to write over again.  It talks about downloading Android SDK, which AShot uses to capture images from your Android device.  One quick note, however, is the copying of the three files, namely:
  • adb.exe
  • AdbWinApi.dll
  • AdbWinUsbApi.dll
from this directory: C:\Program Files\Android\android-sdk\platform-tools

to this directory: C:\Program Files\Android\android-sdk\tools

Again, simply COPY the three files and not MOVE from one to the other.

Lots of troubleshooting is also discussed on that page, so go thoroughly through that page if AShot won't seem to work.



At this stage, I'm assuming you already got AShot working and you're seeing the same image in your PC as what's on your Android device as shown in the photo above.  You might have also tried screencapturing, and saw a tiny little problem -- (aside from the low FPS which is already answered many times on that page mentioned) instead of a video output, AShot outputs a series of PNGs.  Here's where FFmpeg comes in.

The FFmpeg binary download is just a zip file that can easily be extracted by 7zip or WinRAR -- though, I prefer 7zip.

I'm going to assume you extracted it on the root of your computer in such a way that ffmpeg.exe will be in this path: C:\ffmpeg\bin

And I'm also going to assume that you set AShot to output screenshots on this path: C:\ashot\

Now, all you have to do is open a Command Prompt and type this:
cd c:\ashot\
c:\ffmpeg\bin\ffmpeg -f image2 -i screenshot_%05d.png screencast.avi


Then using any movie player -- I use VLC media player by the way -- you can now view your screencast.avi.

Lastly, if you want to adjust the FPS of your AVI, try adding -framerate X when executing ffmpeg, where X is your desired FPS.

Happy screencasting!

~creek23

Monday, April 23, 2012

Android Development: Override the Device's Back button

When browsing a game's Options Menu and decided to not modify the current settings, you simply want to use your phone's Back button as, well, for going back to Main Menu.

But sadly, this is not the default behavior of that Back button. When you try to create your game, pressing that button will quit (umm... hide, rather) your app.

But don't lose hope. There's actually a way of changing that default behavior.

On your app's Activity class, add the following snippet.

@override
public void onBackPressed() {
  if (state == STATE_MAINMENU) {
     super.onBackPressed();
  } else {

     //do something else
  }
}


Of course, both state and STATE_MAINMENU has to be defined for the snippet to be usable. Also, whatever new behavior you want the Back button will have to do will be coded on the else part of the snippet, as indicated by do something else.

Saturday, April 21, 2012

Android Development: Disable Screen Rotation

By default, your app will run in Portrait mode.  And you might opt to keep it that way, but would also rotate to Landscape mode if the phone it handled sideways.

To keep it in Portrait mode, open your AndroidManifest.xml then add the highlighted text below.

<activity
   android:label="@string/app_name"
   android:name="HelloWorld"
   android:screenOrientation="portrait" >
   ...
< /activity>

But if you are creating an Android game, chances are you wanted to default it in Landscape and stay that way. If so, just change portrait to landscape.

Tuesday, May 4, 2010

Android on iPhone

I've heard about the fake iPhones from one of my officemates and I was deeply interested to buy one for some experiment. So I went to Divisoria (Philippine version of black market) and did see one which is worh PhP2,800

I tested the unit and was quite fascinated and impressed with the technology.

My supposed plan was to experiment with any opensource mobile operating system that would possibly work on the said phone. Specifically, I am interested in running Android on that fake iPhone. But a little googling showed that there is already an existing iPhone clone that uses Android. Cool, huh?


I'm still going to buy and try to do this hack for myself.

Saturday, January 30, 2010

Setting-up Android Development Enviroment on Windows

Downloading the Tools.
  1. Download Android SDK r4.
  2. Download Eclipse Classic 3.5.1.
  3. Download Android Development Tools 0.9.5.
Installing the Tools.
  1. Extract the SDK at your root directory (ex: C:\)
  2. Extract Eclipse and run eclipse.exe
  3. On Eclipse, click Help -> Install New Software.
  4. Click Add... button, Add Site dialog will pop-up.
  5. Click Archive... button and browse for ADT-0.9.5.zip then click OK.
  6. Specify ADT as Name then click OK.
  7. Toggle-on Developer Tools then click Next to install.
  8. Now set the path of the SDK. Click Window -> Preference. Select Android, and set the SDK Location to: C:\android-sdk-windows, then click OK.
Installing the Android API.
  1. With the SDK path set, click Window -> Android SDK and AVD Manager.
  2. Select Available Packages. Then toggle-on the following:
    • Documentation for Android 2.1, API 7, revision 1
    • SDK Platform Android 2.1, API 7, revision 1
  3. And optionally, toggle-on:
    • Google APIs by Google Inc., Adroid API 7, revision 1
    • Usb Driver package, revision 3
  4. Click Install Selected then accept the license and click Install Accepted.
Creating Android Virtual Device (AVD or what we call Emulator).
  1. Again, click Window -> Android SDK and AVD Manager.
  2. Specify the Name (ex: MyAndroidEmulator)
  3. Choose Android 2.1 - API Level 7 as the Target.
  4. On Hardware, click New and OK repeatedly until all Properties has been added.
  5. Click Create AVD.
Now you can start writing Android Apps!