36

When I open layout editor, eclipse is giving this error:

parseSdkContent failed
Could not initialize class android.graphics.Typeface

And when I try to run project, it is giving this error :

An internal error occurred during: "Launching myapp".
java.lang.NullPointerException

Every time I'm getting this error and I have to restart eclipse. Is there any solution? This problem started suddenly today.


XML file:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#66000000"
     >

    <RelativeLayout
        android:id="@+id/refresh_match_layout"
        android:layout_width="fill_parent"
        android:layout_height="150dp"
        android:layout_centerInParent="true"
        android:layout_margin="15dp"
        android:background="@drawable/app_detay_lay_bg"
        android:orientation="vertical"
        android:padding="10dp"
        android:visibility="visible" >

        <ImageView
            android:id="@+id/app_icon"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:padding="10dp"
            android:textColor="#ffffff"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/app_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:textColor="#000000"
            android:layout_toRightOf="@+id/app_icon"
            android:layout_marginTop="2dp"
            android:textSize="20sp" />

        <ImageButton
            android:id="@+id/app_detail_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="2dp"
            android:background="@null"
            android:src="@drawable/settings_detail"/>

        <ImageButton
            android:id="@+id/app_remove_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/app_icon"
            android:layout_alignTop="@+id/app_detail_button"
            android:background="@null"
            android:src="@drawable/settings_remove" />

    </RelativeLayout>

</RelativeLayout>

Error picture: enter image description here

Nawaz
  • 353,942
  • 115
  • 666
  • 851
Lazy
  • 1,807
  • 4
  • 29
  • 49

4 Answers4

88

I deleted the home/.android folder and everything is normal now.

In Windows you can find this folder in C:/Users/User/

Source: https://stackoverflow.com/a/5883841/3681056

Note: it happens when you have 2 versions of SDK and eclipse, both in the same computer (and using the same .android file), if you open on version the other will get this error.

Community
  • 1
  • 1
Lazy
  • 1,807
  • 4
  • 29
  • 49
  • and don't forget to restart the eclipse :) – Safvan 7 Sep 19 '14 at 09:41
  • If you have an application that uses the maps, that will get broken on deleting the .android folder. The map window will display just a blank screen with the zoom icons. – user2260040 Sep 23 '14 at 23:05
  • 8
    Be careful, though - your .android folder contains your AVDs, debug keystore, and more. You might want to move it somewhere else, instead. – Tad Oct 23 '14 at 13:56
  • 1
    On Mac, the folder can be found at `~/.android` – Mike Ortiz Nov 14 '14 at 23:46
  • Just remove ~/.android/avd instead of removing complete folder. It worked for me. You need to delete the .ini file of the AVD. Then restart eclipse will resolve your problem. – chaitanya Oct 27 '15 at 19:26
4

Deleting ".android" is temporarily fixing the problem with me as after sometime it begins to come again ..

Here is another cause and fix that might help .. This is happening because of existence of 2 versions of SDK in the same machine but in case you have only one version (probably it is 21) just download the SDK platform for API 20 (4.4W) as there is a problem in 21's "layoutlib.jar"). start applying the following:

  • Close Eclipse

  • Navigate to your sdk folder (something like C:\adt-bundle-windows-x86_64-20140321\sdk)

  • Go to platforms folder -> android-21 folder -> data folder and rename layoutlib.jar (for backup only)

  • Copy the same file (layoutlib.jar) from your android-20 folder to this folder "android-21"

  • Start Eclipse

Muhammad Soliman
  • 21,644
  • 6
  • 109
  • 75
2

deleting home/.android is useless, i delete ~/.android/avd it worked for me :)

Pythonoid
  • 65
  • 10
1

I was getting this error too

parseSdkContent failed Could not initialize class android.graphics.Typeface

But I could only resolve it after changing my Eclipse ADT from 64 bit to 32 bit on Windows 7 64 bit OS.

muasif80
  • 5,586
  • 4
  • 32
  • 45
  • I guess it is related to 5.0 SDK http://stackoverflow.com/questions/26829679/parsesdkcontent-failed-could-not-initialize-class-android-graphics-typeface-in – Paul Verest Nov 24 '14 at 10:13