Thursday, December 26, 2013

AndroidManifest.xml file in android / AndroidMenifest file

Every app must have AndroidManifest.xml file in its root directory.
It has information about the application which is accessed by OS before running the app.
It has following things:-
1.package name, Its unique per application.
2.Describe the components of the application.(4 main components of apps:- activity, services, broadcast receiver , content provider) It names the classes that implement each of the components and publishes their capabilities.
3.declaration of permission.
4.Minimum level of Android app.
5.List of libraries that must be linked

Template of AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest> //it must be there and only once

    <uses-permission />
    <permission />
    <permission-tree />
    <permission-group />
    <instrumentation />
    <uses-sdk />
    <uses-configuration /> 
    <uses-feature /> 
    <supports-screens /> 
    <compatible-screens /> 
    <supports-gl-texture /> 

    <application> //it must be there and only once

        <activity>
            <intent-filter>
                <action />
                <category />
                <data />
            </intent-filter>
            <meta-data />
        </activity>

        <activity-alias>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </activity-alias>

        <service>
            <intent-filter> . . . </intent-filter>
            <meta-data/>
        </service>

        <receiver>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </receiver>

        <provider>
            <grant-uri-permission />
            <meta-data />
            <path-permission />
        </provider>

        <uses-library />

    </application>

</manifest>

Example
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.shriram.timetone"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />
        <uses-permission android:name="android.permission.INTERNET" />
   

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.shriram.timetone.MainActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Black.NoTitleBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>







Progaurd in android / What is Proguard in Android / what is use of Proguard in Android

Proguard is mainly to avoid decompiling ( reverse engineering ) of .apk or .dex file.
Proguard is tool for shrinking , optimizing  and obfuscating the code by removing unused code and renaming classes , fields , methods with semantically obscure names.
Its integrated into the android build system.

You can add proguard.cfg file at root directory of the project. You can add rules how to optimize and obfuscates your code.

To enable ProGuard so that it runs as part of an Ant or Eclipse build, set the proguard.config property in the <project_root>/project.properties file.

You need to add cfg file in project.properties with its path.( As we added in root not need path . but if other location you need to add path)
proguard.config  =/path/to/proguard.cfg



ProGuard outputs files after it runs :
dump.txt
           describe internal structure of the class files in the .apk  file
mapping.txt
Its useful when receive bug report. Used to decode and gets stack .
Its mapping between the original and obfuscated class, method, and field names. 
seeds.txt
Lists the classes and members that are not obfuscated
usage.txt
Lists the code that was stripped from the .apk

Above all files are located at below path
  • <project_root>/bin/proguard if you are using Ant.
  • <project_root>/proguard if you are using Eclipse.