-1

This is my main.xml

<com.example.parallax_sample xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res/com.example.parallax_sample"
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:overScrollMode="never">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="1000dp"
        tools:context=".MainActivity" >

        <RelativeLayout
            android:id="@+id/relativeLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            tools:context=".MainActivity" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:src="@drawable/teste" />

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:text="Bottom"
                android:textColor="#ffffff"
                android:textSize="18sp" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:text="Top"
                android:textColor="#ffffff"
                android:textSize="18sp" />
        </RelativeLayout>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/relativeLayout1"
            android:text="@string/hello_world" />
    </RelativeLayout>

</com.example.parallax_sample>

when I switch to graphical layout I see nothing (grey screen) ,with the exception stating.

Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup.

I may be wrong but it must be a problem of main.xml only . How can i resolve it.

Here is the StackTrace

 E/AndroidRuntime(15768): FATAL EXCEPTION: main
 E/AndroidRuntime(15768): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.parallax_sample/com.appkraft.parallax_sample.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class com.example.parallax_sample
 E/AndroidRuntime(15768):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343)
 E/AndroidRuntime(15768):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
 E/AndroidRuntime(15768):   at android.app.ActivityThread.access$600(ActivityThread.java:162)
 E/AndroidRuntime(15768):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
 E/AndroidRuntime(15768):   at android.os.Handler.dispatchMessage(Handler.java:107)
 E/AndroidRuntime(15768):   at android.os.Looper.loop(Looper.java:194)
 E/AndroidRuntime(15768):   at android.app.ActivityThread.main(ActivityThread.java:5371)
 E/AndroidRuntime(15768):   at java.lang.reflect.Method.invokeNative(Native Method)
 E/AndroidRuntime(15768):   at java.lang.reflect.Method.invoke(Method.java:525)
 E/AndroidRuntime(15768):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
 E/AndroidRuntime(15768):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
 E/AndroidRuntime(15768):   at dalvik.system.NativeStart.main(Native Method)
 E/AndroidRuntime(15768): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class com.example.parallax_sample
 E/AndroidRuntime(15768):   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
 E/AndroidRuntime(15768):   at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
 E/AndroidRuntime(15768):   at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
 E/AndroidRuntime(15768):   at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
 E/AndroidRuntime(15768):   at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:281)
 E/AndroidRuntime(15768):   at android.app.Activity.setContentView(Activity.java:1881)
 E/AndroidRuntime(15768):   at com.appkraft.parallax_sample.MainActivity.onCreate(MainActivity.java:18)
 E/AndroidRuntime(15768):   at android.app.Activity.performCreate(Activity.java:5122)
 E/AndroidRuntime(15768):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
 E/AndroidRuntime(15768):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
 E/AndroidRuntime(15768): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.parallax_sample" on path: DexPathList[[zip file "/data/app/com.example.parallax_sample-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.parallax_sample-1, /vendor/lib, /system/lib]]
 E/AndroidRuntime(15768):   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
 E/AndroidRuntime(15768):   at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
 E/AndroidRuntime(15768):   at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
 E/AndroidRuntime(15768):   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
Nihar
  • 553
  • 1
  • 10
  • 29

2 Answers2

2

Your root element on the xml is a custom element. If the graphical layout cannot render that first element, it won't be able to render the rest of them either.

M Rajoy
  • 4,028
  • 14
  • 54
  • 111
  • so how can i fix my problem in this scenario ?? – Nihar Dec 09 '13 at 11:46
  • add the library to your workspace and add the project as a library :)\ – Jeffy Lazar Dec 09 '13 at 11:54
  • @ Jlazar which library u r mentioning to add in the workspace – Nihar Dec 09 '13 at 12:21
  • If this is an external library there probably is little you can do to make it render in the Graphical Editor. Check this question: http://stackoverflow.com/questions/15423149/how-to-use-isineditmode-to-see-layout-with-custom-view-in-the-editor – M Rajoy Dec 09 '13 at 12:25
  • kelmer ,I dont have that scenario , I dont have any null pointer exception,it is something just I am doing silly a newcomer hence can not locate that my log says that android.view.InflateException: Binary XML file line #1: Error inflating class com.appkraft.parallax_sample and java.lang.ClassNotFoundException: Didn't find class "com.appkraft.parallax_sample" on path: DexPathList[[zip file "/data/app/com.appkraft.parallax_sample-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.appkraft.parallax_sample-1, /vendor/lib, /system/lib]] any help on that – Nihar Dec 09 '13 at 12:38
  • If your package declaration (as stated in the other answer) is `com.appkraft.parallax_sample`, then why are you using `com.example.parallax_sample`on your xml layout file? – M Rajoy Dec 09 '13 at 12:40
1

"com.example.parallax_sample" is the problem, previews for custom view can't be created, though possibly it will work fine when you run it.

Abhishek Shukla
  • 1,242
  • 8
  • 11
  • but it not working ,crashes at this point setContentView(R.layout.activity_main); from eclipse debug any solution how to overcome that – Nihar Dec 09 '13 at 11:46
  • have a look at the stack trace – Nihar Dec 09 '13 at 11:53
  • Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.parallax_sample" .. This is the problem, it cannot find the class. please make it sure that the class exists and it's accessible – Abhishek Shukla Dec 09 '13 at 11:55
  • I have noticed that but the package declaration is com.appkraft.parallax_sample dont understand how come "example is coming" – Nihar Dec 09 '13 at 11:59
  • yeah got it forgot to change in few files. – Nihar Dec 09 '13 at 12:09