Problem using android.support.v7.widget.GridLayout with gradle/Android Studio

3,498 vistas
Ir al primer mensaje no leído

Reece Dunn

no leída,
6 jun 2013, 10:36:45 a.m.6/6/13
para adt...@googlegroups.com
I am trying to add support for android.support.v7.widget.GridLayout. I have:

    compile files('libs/android-support-v7-gridlayout.jar')
    compile project(':actionbarsherlock')

in my build.gradle file. This is the latest android-support-v7-gridlayout.jar from the SDK.

I have the following activity_main.xml:

-----
<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".ConverterActivity">

</android.support.v7.widget.GridLayout>
-----

This builds without error, likewise if I add a:

    import android.support.v7.widget.GridLayout;

statement. However, when I run the application it crashes with:

        java.lang.RuntimeException: Unable to start activity ComponentInfo{...}: android.view.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.GridLayout
        ...
        Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.GridLayout
        ...
        ... 11 more
        Caused by: java.lang.reflect.InvocationTargetException
        at android.support.v7.widget.GridLayout.<init>(GridLayout.java:274)
        at java.lang.reflect.Constructor.constructNative(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
        at android.view.LayoutInflater.createView(LayoutInflater.java:500)
        ... 20 more
        Caused by: java.lang.NoClassDefFoundError: android.support.v7.gridlayout.R$dimen
        at android.support.v7.widget.GridLayout.<init>(GridLayout.java:255)
        ... 24 more

Also, using the Design view in Android Studio I get a similar error:

        java.lang.ClassNotFoundException: android.support.v7.gridlayout.R$dimen

I am using com.android.tools.build:gradle:0.4 to build ActionBarSherlock (using the build.gradle files in the dev branch of that project). I am using com.android.tools.build:gradle:0.4.2 to build my project using ActionBarSherlock and the GridLayout support library.

Xavier Ducrohet

no leída,
6 jun 2013, 11:48:37 a.m.6/6/13
para adt...@googlegroups.com
Don't do that. Use the maven artifact found in the "Android Support Repository" SDK Component (that you'll have to install).

Once this is install you can do 

   compile 'com.android.support:gridlayout-v7:13.0.0'

It's packaged as an aar.



--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Václav Souhrada

no leída,
23 ago 2013, 3:17:23 a.m.23/8/13
para adt...@googlegroups.com
Hello, 

I added compile 'com.android.support:gridlayout-v7:13.0.0' and if I run my application => everything is ok, but I have a problem in the Android Studion when I want to display layout preview an exception appears:

The following classes could not be instantiated: android.support.widget.GridLayout ......


Do you know what I'm doing wrong?

--
Vaclav Souhrada

Jonathan Steele

no leída,
24 ago 2013, 10:31:34 p.m.24/8/13
para adt...@googlegroups.com

android.support.v7.gridlayout

Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos