Question

When I click on my widget, which uses the gridlayout support library, I get this error:

10-12 17:15:14.373: E/dalvikvm(3957): Could not find class 'com.example.awesomefilebuilderwidget.Drag_and_Drop_App$MyDragListener', referenced from method com.example.awesomefilebuilderwidget.Drag_and_Drop_App.onCreate
10-12 17:15:14.433: E/AndroidRuntime(3957): FATAL EXCEPTION: main
10-12 17:15:14.433: E/AndroidRuntime(3957): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.awesomefilebuilderwidget/com.example.awesomefilebuilderwidget.Drag_and_Drop_App}: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.GridLayout
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1833)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1854)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.app.ActivityThread.access$1500(ActivityThread.java:135)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1041)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.os.Looper.loop(Looper.java:150)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.app.ActivityThread.main(ActivityThread.java:4333)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at java.lang.reflect.Method.invokeNative(Native Method)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at java.lang.reflect.Method.invoke(Method.java:507)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at dalvik.system.NativeStart.main(Native Method)
10-12 17:15:14.433: E/AndroidRuntime(3957): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.GridLayout
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:231)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.app.Activity.setContentView(Activity.java:1712)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at com.example.awesomefilebuilderwidget.Drag_and_Drop_App.onCreate(Drag_and_Drop_App.java:22)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1797)
10-12 17:15:14.433: E/AndroidRuntime(3957):     ... 11 more
10-12 17:15:14.433: E/AndroidRuntime(3957): Caused by: java.lang.reflect.InvocationTargetException
10-12 17:15:14.433: E/AndroidRuntime(3957):     at java.lang.reflect.Constructor.constructNative(Native Method)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)
10-12 17:15:14.433: E/AndroidRuntime(3957):     ... 20 more
10-12 17:15:14.433: E/AndroidRuntime(3957): Caused by: java.lang.NoClassDefFoundError: android.support.v7.gridlayout.R$dimen
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.support.v7.widget.GridLayout.<init>(GridLayout.java:255)
10-12 17:15:14.433: E/AndroidRuntime(3957):     at android.support.v7.widget.GridLayout.<init>(GridLayout.java:274)
10-12 17:15:14.433: E/AndroidRuntime(3957):     ... 23 more

I followed the official android developers guidelines to add the support library to my project but I am still getting the errors.

As I believe this is more or less my fault somewhere along the line heres the steps I took to add it:

1)Went to File->Import->Existing Android Code into Workspace->found the v7 gridlayout file and clicked finish

2)Went to the support gridlayout package and to the libs folder, right clicked on the .jar file, and added it to my build path (I did the same with the bin file)

3)Clicked on my own project->Properties->Library pane->Add JARs (as seen below)

enter image description here

Then I also have the order and export tab as marked below:

enter image description here

Then the two libs show up in my projects "Referenced Libraries" section. enter image description here

But no matter what I do, I still get that same error. Did I go about doing this correctly?

Was it helpful?

Solution

Your steps are incorrect. Instead of this:

3)Clicked on my own project->Properties->Library pane->Add JARs (as seen below)

Do this (from the Adding libraries with resources section in the instructions):

  1. In the Project Explorer, right-click your project and select Properties.
  2. In the Library pane, click Add.
  3. Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-appcompat.
  4. In the properties window, click OK.

Except use gridlayout instead of appcompat, of course

Also, the remaining steps that you did (with the Build and Export tab) should be done to the gridlayout project, not your own project (also detailed in the same section of the instructions).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top