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

Saturday, April 28, 2012

facebook-android-sdk\facebook\build.xml:46: sdk.dir is missing


Why:
Missing local.properties in the facebook library project folder. (need to provide the sdk.dir env variable, this solution describes how to make the local.properties)

Dependencies:
Path to tools batch files:
C:\<path_to_location_of_your_android_sdk>\android-sdks\tools

Fix:
Open CMD to the directory of downloaded facebook library:
(Windows) $ android.bat update lib-project -p .
(Linux) $ android update lib-project -p .

This will generate local.properties to keep you going.

local.properties:
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.

# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=C:\\
<path_to_location_of_your_android_sdk>\\android-sdks

You can also write this file to that project directory and be done.

Sunday, September 25, 2011

Remove app from device (fast)

This guide is a fast way to remove an apk you have been developing from the device:


  1. For easy access to the adb binary, create a folder in your home directory bin and place a symbolic link to your original adb binary.
    cd ~
      • mkdir bin
      • cd bin
ln -s ../Software/android-sdk-linux_86/platform-tools/adb adb
(if your original adb binary lives in /home/your_user_name/Software/android-sdk-linux_86)
  1. Re-login to your Ubuntu workstation and you are done.
Next time to quickly remove your app, open a terminal prompt (Ctrl+Alt+T) and type adb uninstall your.app.package.name.

Sunday, August 28, 2011

Android Logging Best Practices

You are implementing some small piece of logic, deep inside of your code's activities and a crash occurs, problem is, you have been scrolling LogCat window and you can't find your exception. Here are some best ways to stop wasting time, filtering out the useless:
  • Create a TAG with which you will be logging all the time. Saves memory and time. i.e. 
public static final String TAG = "MyApplicationTag";
or
public static final String TAG = MyActivityClass.class.getSimpleName();

...

Then in your code:
...

Log.d(TAG, "log this");


One for an entire application, one per activity. As long as it makes sense to you and you can quickly find it.

Additional tips:
  • Setup additional tabs inside of LogCat. These are very useful:
    • AndroidRuntime
    • System.err
    • MediaProvider
  • Create a utility class
public static class SuperAppLog {

public final static String TAG = SuperAppLog.class.getSimpleName();

public void error(String message) {
// .. do some app wide logging
// .. redirect to a file
// .. fire off a analytics logging request
// .. etc
}

}



That's it. If you want to get more fancy or mess around with Log levels, check out this answer or this guide.

Happy Coding!