using android.support.v4 library in Intellij idea

2019-02-05 16:29发布

In my android project I tryed to use android.support.v4.widget.DrawerLayout.

Before it I added it to the libs library (cp MySdkForder/extras/android/support/v4/android-support-v4.jar MyProjectFolder/libs)

After that I added it to the classpath like this:

my project settings

So I have a code like this in my main.xml file

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <ListView android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:background="#111" />
</android.support.v4.widget.DrawerLayout>

This one I took somewhere on developer.android.com

Idea renders this code totally fine

how idea renders this code

Problems starts when I'm trying to launch it. When I press run I have the following error from adb

Cannot reload AVD list: cvc-enumeration-valid: Value '280dpi' is not facet-valid with respect to enumeration '[ldpi, mdpi, tvdpi, hdpi, xhdpi, 400dpi, xxhdpi, 560dpi, xxxhdpi]'. It must be a value from the enumeration.
Error parsing /usr/lib/android/android-sdk-linux/system-images/android-22/android-wear/armeabi-v7a/devices.xml
cvc-enumeration-valid: Value '280dpi' is not facet-valid with respect to enumeration '[ldpi, mdpi, tvdpi, hdpi, xhdpi, 400dpi, xxhdpi, 560dpi, xxxhdpi]'. It must be a value from the enumeration.
Error parsing /usr/lib/android/android-sdk-linux/system-images/android-22/android-wear/x86/devices.xml
cvc-enumeration-valid: Value '280dpi' is not facet-valid with respect to enumeration '[ldpi, mdpi, tvdpi, hdpi, xhdpi, 400dpi, xxhdpi, 560dpi, xxxhdpi]'. It must be a value from the enumeration.
Error parsing /usr/lib/android/android-sdk-linux/system-images/android-22/android-wear/armeabi-v7a/devices.xml
cvc-enumeration-valid: Value '280dpi' is not facet-valid with respect to enumeration '[ldpi, mdpi, tvdpi, hdpi, xhdpi, 400dpi, xxhdpi, 560dpi, xxxhdpi]'. It must be a value from the enumeration.
Error parsing /usr/lib/android/android-sdk-linux/system-images/android-22/android-wear/x86/devices.xm

It looks like this

Error message

The funny thing is that I can't even close it (It appears again and again). But that's not my question. The question is how to make this android.support.v4 work? As I think I've done everything what I needed (added this library to libs and made dependencies) and adb still doesn't want to work (It works absolutely fine If I don't use android.support.v4, just standard features)

9条回答
神经病院院长
2楼-- · 2019-02-05 17:00

Use text editor to open Android\android-sdk\system-images\android-22\android-wear\armeabi-v7a\devices.xml Search 280dpi
Change it to hdpi

Do the same for Android\android-sdk\system-images\android-22\android-wear\x86\devices.xml

Close eclipse. Restart eclipse. The error should disappear.

If you are working with windows, the files could be in C:\Program Files (x86)\Android\android-sdk\system-images\android-22\android-wear\armeabi-v7a\devices.xml C:\Program Files (x86)\Android\android-sdk\system-images\android-22\android-wear\x86\devices.xml

查看更多
爷、活的狠高调
3楼-- · 2019-02-05 17:04

I just had this problem go here: usr/lib/android/android-sdk-linux/system-images/android-22

And remove the android wear folder.

查看更多
何必那么认真
4楼-- · 2019-02-05 17:04

Error Solution:-

  1. Uninstall Android Wear ARM EABI v7a System Image.
  2. Uninstall Android Wear Intel x86 Atom System Image.

Restart Android Studio...and enjoy!!

enter image description here

查看更多
登录 后发表回答