Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Friday, 15 November 2013

Popular Android Development Websites and Blogs


Hello Everyone,

Here is the some of the Android Development Blogs which definitely helps you while developing android application.

Hope this list will helpful to you..!

Android Developers Blog
Developer Android
Romain Guy
Styling Android
Cyril Mottier
Android Weekly.
The CommansBlog
InterFuser
Truiton.com
Android Views
Apps Rox
 Mobile Tus 
Androidhive
Code Of A Ninja
Vogella
Java Papers
Android-er
Mkyong
Java2s
Dan Clarke
My Sample Code
Android Design Patterns
Wagied Davids
MyDoople
Viralpatel
Scaloid
Android UI
Android Begin
Programmer Guru
Marakana
Grokking Android
Android Patterns
Android Education
Android App Market
Java Code Geeks
New Think Tank
Android Aspect
Android Hub 4 You
Surviving With Android
Knowledge of Experience
Clean Code
Think Android
Mr Bool
Android Guide Tips
Android Tuts



Happy Development. Happy Reading.

Monday, 11 November 2013

Reverse Engineering of Android applications



I happy share my answer from Stack Overflow regarding to reverse engineered the android application (.apk). 

Procedure for decoding .apk files, step-by-step method:
Step 1:
Make a new folder and put .apk file in it (which you want to decode). Now rename the extension of this .apk file to .zip (eg.: rename from filename.apk to filename.apk.zip) and save it.
If problems in the converting into .zip please refers below link
After getting .zip now you get classes.dex files, etc. At this stage you are able to see 
drawable but not xml and java files, so continue.
If you don’t see the extensions go through check the configuration 
Step 2:
Now extract this zip apk file in the same folder. Now download dex2jar from this link http://code.google.com/p/dex2jar/ and extract it to the same folder. Now open command prompt and change directory to that folder.

Then write dex2jar classes.dex and press enter. Now you get classes.dex.dex2jar file in the same folder.

Then download java de-compiler from http://java.decompiler.free.fr/?q=jdgui and now double click on jd-gui and click on open file. Then open classes.dex.dex2jar file from that folder. Now you get class files and save all these class files (click on file then click "save all sources" in jd-gui) by src name. Extract that zip file (classes_dex2jar.src.zip) and you will get all java files of the application.

At this stage you get java source but the xml files are still unreadable, so continue.

Step 3:
Now open another new folder and put these files
1.    put .apk file which you want to decode
2.    download
install window using google and put in the same folder
3.    download framework-res.apk file using google and put in the same folder (Not all apk file need framework-res.apk file)
4.    Open a command window
5.    Navigate to the root directory of APKtool and type the following command: 
apktool if framework-res.apk.
Above command should result in "Framework installed ...".

6.    apktool d "appName".apk ("appName" denotes application which you want to decode) now you get a file folder in that folder and now you can easily read xml files also.

Step 4:
Finally we got the res/ as well as java code of project which is our target at starting. Enjoys the coding

Src –

  1.     http://comptech-blogger.blogspot.in/2012/09/how-to-get-source-code-from-apk-file.html
  2.     http://stackoverflow.com/questions/3593420/android-getting-source-code-from-an-apk-file

Creating a Google Map application using map v2 with Release Key

Steps:-


  •      Open Eclipse and create a new Android project.
    The first thing that we will handle is the import of Google Map classes. To get the Google Maps files we need to download the last version of Google Play Services via the Android SDK Manager.
  • After you downloaded the Google Play Services, restart Eclipse and
    in the Package Explorer Right-Click –> Import….
    In the opened windows choose “Existing Android Code into Workspace” and click “Next”.
    Click the “Browse…” Button and head to the location of your SDK folder. In it find the following folder: \extras\google\google_play_services\libproject\google-play-services_lib and press “OK”, check the V next to it in the window and press the “Finish” button.
  •      Now you added Google Play Services to your work space, we have to create a reference
    from our project to this library. Right-Click your project and choose “Properties” go
    to the Android section, in the lower part press the “Add…” button and add a reference
    to that library. Your result should be as in the screen shot bellow:



         
      Note: 
If you try to reference google-play-service library and you receive a red X next to this reference, what you should do is to move the .jar file to a location where it’s path will be shorter and then reference it again.

  •      Another import we have to make in order to make our application work on Operation system prior to API11 is to import the support library this can be done very easily using Eclipse: Right-Click you project and choose “Android Tools” and then choose “Add Support Library…”:




When you finish those imports you should have the following libraries (Red) in the Android Dependencies folder (Green) of your project:


  • We are now ready for some coding: First of all open the Android Manifest file: add the following permissions:

<permission android:name="your.application.package.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="your.application.package.permission.MAPS_RECEIVE"/>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

      Important: 
      Replace your application package instead of the current “your.application.package” string.
  •      Next, Google Maps uses OpenGL so we have to add OpenGL support to our application
    by adding this to the Manifest file:

<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
  •      Finally add your key to you application right before you close your “application” node
    in the Manifest file:

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Your Google Maps API V2 Key" />

  •       Now create an Activity that extends from “FragmentActivity”:

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class MapActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map_layout);
    }
}

  •      Finally for map_layout, XML layout file that was set as a content view of the map activity write the following:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    


<fragment
        android:name="com.google.android.gms.maps.SupportMapFragment"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>



Steps to getting the Map API Key from the Google Map:  
  •        Create a new project




  •      Select services for the project. Here we need a Google Maps Android API v2 service. Search this service in list and ON this service.



  •        Get SHA1 Fingerprint form this command
C:\Users\pavan.p>keytool -list -alias androiddebugkey -keystore default-keystore-file
-storepass android -keypass android
androiddebugkey, Jun 25, 2012, PrivateKeyEntry,
Certificate fingerprint (SHA1): 67:3C:9D:----Gen SHA1 Key----:E8
In my case:-
default-keystore-file : C:\Users\pavan.p\.android\debug.keystore
Or find it in the Eclipse Window -> Preferences -> Android -> Build -> here you will found the both SHA1 and MD5 fingerprint.

  • Go to API Access tab from the console. Here we show the one key Key for browser apps (with referrers). We want to get API Key for android then click on create New Android Key button. The opened dialog asks for SHA1 fingerprint and package name followed by semicolon.

Enter your SHA1 fingerprint and package name,
In my case input is  67:3C:9D:3B:AB:00:D0:ED:6D:94:28:B9:63:EF:E0:33:32:E7:6D:E8;sample.sample




  •        Use this key in the Manifest file:

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Your Google Maps API V2 Key" />

  • One important thing about the Android Google map v2 is , When your application is in debugging mode the map works fine but when we create .apk of the application the Google map needs the Release Key for that.  With version 2 API's you can use the same key for release and debug. In your google api's console edit your allowed android apps and on each line put your debug/release key, and then your app name. You can use multiple lines, then it will work with both keys.

  •      To export the apk, see the bottom of the manifest file with link as “Use the Export Wizard”




Follow all the instructions:-













  • When apk is generated at the same time MD5 fingerprint and SHA1 generated in the console as follow

  •      Copy the SHA1 key, go to Google API Console and Click on Edit allowed Android apps... link, add the SHA1 key in the dialog box with package name. Make sure that generated the API key and Manifest key is same.
Hope all the steps helpful to you.

Happy Reading and Happy coding.. :-)

Wednesday, 23 October 2013

Map Fragment / MapView v2 Quick Start

The Maps APIs for Android have been updated in the latest release of the Google Play Services library and have been rolled out to Android devices with the Play Store. To test it out:
1. Create a new project
  • File -> New -> Android Application Project
  • You can leave all the options with their default values
  • Choose BlankActivity in the Create Activity screen


2. Ensure you have the latest version (v2) of the Google Play Services installed.
  • Select Window > Android SDK Manager or run android at the command line.
  • Scroll to the bottom of the package list and select Extras > Google Play services. 
  • The Google Play services SDK is downloaded to your computer and installed in your Android SDK environment at  <android-sdk-folder>/extras/google/google_play_services/


3. Add the Google Play Services project into your Eclipse workspace.

  1. Click File -> Import..., select Android -> Existing Android Code into Workspace
  2. Browse to and select <android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib

4. To add the dependency to Google Play Services into your project

  1. Project -> Properties -> Android -> Library, Add -> google-play-services_lib

5. Update MainActivity.java  to extend FragmentActivity instead of Activity
  1. Check that Google Play Services is available on the device at runtime to protect against error cases

GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
  1. Update res/layout/activity_main.xml and replace the entire contents with




  1. The map is controlled through the GoogleMap object, use findFragmentById to keep a reference to the GoogleMap from the layout.
GoogleMap map = ((SupportMapFragment)  getSupportFragmentManager().findFragmentById(R.id.map))
               .getMap();


To use Google Maps API you need an API Key:
  1. Go to the Google APIs Console
  2. In Services enable ‘Google Maps Android API v2’ and agree to the terms
  3. In the left navigation bar, click API Access.
  4. Click Create New Android Key....
  5. In the resulting dialog, enter the SHA-1 fingerprint, then a semicolon, then your application's package name. For example:
  1. BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.example.android.mapexample
  1. If you have debug and production keys then add both in.
  1. To obtain the SHA1 of your debug certificate use keytool:
keytool -list -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android -keypass android -v
  1. For Windows computers the .android directory is in your user directory
  2. Your new API key will be a 40 character string like AIzbSyBaEqeUpYvlsbUe0OqTPn1-ABVMHVbdNxo
  1. Add the following tag into your AndroidManifest.xml just before the closing </application> tag









  1. Your application now also needs the following permissions in the AndroidManifest.xml

  1. Optionally you can include one or both of these permissions to enable auto-location


  1. Maps v2 uses OpenGl so the following uses-feature is also required

  1. Test your application, checking the logcat output for any errors.
  2. If it is working try out some of the other GoogleMap options:
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
mMap.setMyLocationEnabled(true);


  1. more details at
https://developers.google.com/maps/documentation/android/views
Attribution Requirements. If you use the Google Maps Android API in your application, you must include the Google Play Services attribution text as part of a "Legal Notices" section in your application. Including legal notices as an independent menu item, or as part of an "About" menu item, is recommended. The attribution text is available by making a call to GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo.

For more information regarding to Android Google map kindly visit to https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw