Friday, March 23, 2012

Android: Conversion to Dalvik format failed: Unable to execute dex: null


Android: Conversion to Dalvik format failed: Unable to execute dex: null

This error often comes when your android project size is large.
Try the following steps to remove the error
1. Clean the project
Project > Clean
2. Increase the memory allocated in eclipse.ini
Open the eclipse.ini file in the the Eclipse folder. Then edit
-Xms128m to -Xmx512m or something higher
Hope this help you

TextView with link in ANDROID…….


TextView with link in ANDROID…….

Hi all…….
All of you may be familiar with TextViews in ANDROID.
But how many of you know that we have have html as text in a textView. This post is a simple example to show this.
Create a fresh project and copy this code to the main java file.
?
Drag and copy the code
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
package com.coderzheaven;
 
import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;
 
public class TextViewLinkDemo extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
        TextView tv = (TextView) findViewById(R.id.tv);
        tv.setText( Html.fromHtml("<b>This is a textView with a link </b>  " +
                    " <br /> <a href="http://www.coderzheaven.com">Coderzheaven</a> " +
                    "created in the Java source code using HTML."));
         tv.setMovementMethod(LinkMovementMethod.getInstance());
    }
}
The main.xml
?
Drag and copy the code
01
02
03
04
05
06
07
08
09
10
11
12
13
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
    android:id="@+id/tv"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
</LinearLayout>
The AndroidManifest.xml file
?
Drag and copy the code
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
<?xml version="1.0" encoding="utf-8"?>
      package="com.coderzheaven"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".TextViewLinkDemo"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
Link in TextView Demo