java 在 Intellij 想法中使用 android.support.v4 库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33253381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
using android.support.v4 library in Intellij idea
提问by PepeHands
In my android project I tryed to use android.support.v4.widget.DrawerLayout
.
在我的 android 项目中,我尝试使用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
)
在它之前我将它添加到libs
库 ( cp MySdkForder/extras/android/support/v4/android-support-v4.jar MyProjectFolder/libs
)
After that I added it to the classpath
like this:
之后,我将其添加到classpath
这样的:
So I have a code like this in my main.xml
file
所以我有这样的代码在我的main.xml
文件
<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
这是我在某处拿的 developer.android.com
Idea renders this code totally fine
想法呈现此代码完全没问题
Problems starts when I'm trying to launch it. When I press run
I have the following error from adb
当我尝试启动它时,问题就开始了。当我按下时run
,出现以下错误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
看起来像这样
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)
有趣的是我什至无法关闭它(它一次又一次地出现)。但这不是我的问题。问题是如何使这项android.support.v4
工作?因为我认为我已经完成了我需要的一切(添加了这个库libs
并建立了依赖关系)adb
但仍然不想工作(它工作得很好如果我不使用android.support.v4
,只是标准功能)
回答by IgorOK
I am using Genymotion and I don't need android wear images. I did following:
我正在使用 Genymotion,我不需要 android 磨损图像。我做了以下:
Uninstalled using SDK manager:
a) Android 5.1.1 (API 22) -> Android Wear ARM EABI v7a System Image
b) Android 5.1.1 (API 22) -> Android Wear Intel x86 Atom System Image
Removed all devices using AVD manager and create new one.
使用 SDK 管理器卸载:
a) Android 5.1.1 (API 22) -> Android Wear ARM EABI v7a 系统镜像
b) Android 5.1.1 (API 22) -> Android Wear Intel x86 Atom System Image
使用 AVD 管理器删除所有设备并创建新设备。
Works for me.
对我来说有效。
回答by user5471688
I just had this problem go here: usr/lib/android/android-sdk-linux/system-images/android-22
我刚刚遇到了这个问题: usr/lib/android/android-sdk-linux/system-images/android-22
And remove the android wear folder.
并删除android磨损文件夹。
回答by Numan Turkeri
Solution For android Studio. Open sdk manager
android Studio 的解决方案。打开sdk管理器
delete Android Wear ARM EABI v7a System Image and Android Wear Intel x86 Atom System Image packet. @gosha is told true.works for me.
删除 Android Wear ARM EABI v7a System Image 和 Android Wear Intel x86 Atom System Image 数据包。@gosha 被告知 true.works 对我有用。
回答by Abhishek Tamta
回答by Siddarth Kanted
Delete these 2 packages using Android SDK Manager.
使用 Android SDK Manager 删除这两个包。
- ARM EABI v7a System Image
- Android Wear Intel x86 Atom System Image
- ARM EABI v7a 系统映像
- Android Wear Intel x86 Atom 系统镜像
View the image link here for more clarification. http://i.stack.imgur.com/wq2tK.png
查看此处的图片链接以获得更多说明。 http://i.stack.imgur.com/wq2tK.png
回答by Peter Moh
Use text editor to open Android\android-sdk\system-images\android-22\android-wear\armeabi-v7a\devices.xml
Search 280dpi
Change it to hdpi
用文本编辑器打开 Android\android-sdk\system-images\android-22\android-wear\armeabi-v7a\devices.xml 搜索 280dpi 改成
hdpi
Do the same for Android\android-sdk\system-images\android-22\android-wear\x86\devices.xml
对 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
如果您使用的是 Windows,文件可能位于 C:\Program Files (x86)\Android\android-sdk\system-images\android-22\android-wear\armeabi-v7a\devices.xml C:\Program文件 (x86)\Android\android-sdk\system-images\android-22\android-wear\x86\devices.xml
回答by Michael A.
Looking at the error message, I suspect the problem is the setup of your Android Virtual Device, rather than anything with the project.
查看错误消息,我怀疑问题在于您的 Android 虚拟设备的设置,而不是项目的任何问题。
Have you tried running the project on an actual Android Device including the support library? If that works, there is not problem with your project setup.
您是否尝试在包含支持库的实际 Android 设备上运行该项目?如果可行,则您的项目设置没有问题。
If the problem is the AVD, as surmised, you need to go into your AVD manager and take a look at what the setup of your devices look like. I don't use VDs a lot myself, but one potential issue is that you may be missing the Google APIs in your setup.
如果问题是 AVD,正如推测的那样,您需要进入您的 AVD 管理器并查看您的设备设置是什么样的。我自己并不经常使用 VD,但一个潜在的问题是您可能在设置中缺少 Google API。
Edit:
编辑:
Just noted your clarification about using IntelliJ. It sounds like your project/IDE setup of the AVD has some issues. It is probably possible to hunt down and figure out the what has gone wrong by doing diffs on a working Android Studio project, but you'd probably save yourself a lot of time and effort by simply installing and using Android Studio. It's not very different, but there are enough Android-specific features in Studio that I think it is worth it even if it means you have two or more IDEs installed.
刚刚注意到您对使用 IntelliJ 的澄清。听起来您的 AVD 项目/IDE 设置存在一些问题。通过对正在运行的 Android Studio 项目进行差异处理,可能可以找到并找出问题所在,但只需安装和使用 Android Studio,您可能会节省大量时间和精力。它没有太大的不同,但是 Studio 中有足够多的 Android 特定功能,我认为即使这意味着您安装了两个或多个 IDE,这也是值得的。
回答by John Williams
The cause of the error is the version of android being used by idea in it's android plug-in which is installed under plugins/android/lib/
.
错误的原因是idea在它的android插件中使用的android版本,该插件安装在plugins/android/lib/
.
I can see that this should be addressed in IDEA 15 as that will use a later version of android in the plug-in. That version has an entry for 280dpi
in it's devices-2.xsdthat is packaged in the sdk-tools.jar.
我可以看到这应该在 IDEA 15 中解决,因为这将在插件中使用更高版本的 android。该版本280dpi
在它的devices-2.xsd中有一个条目,该条目打包在sdk-tools.jar 中。
I tried to hack the entry into the current devices-2.xsdbut that causes the plug-in to completely fail later on. So don't try do do that!
我试图破解当前devices-2.xsd的条目,但这导致插件稍后完全失败。所以不要尝试这样做!
If you aren't doing wear development, then the answers saying to remove those directories from the platform image are valid.
如果您不进行磨损开发,那么从平台映像中删除这些目录的答案是有效的。
You can also livewith the problem by positioning the annoying error dialogue so that it's ok button is over which ever element you are trying to click in Choose Devicedialogue beneath it. Then double click. Tedious, but you do get there.
您还可以现场与定位恼人的错误对话,它的确定按钮是在其曾经元素你想点击的问题选择设备在它下面的对话。然后双击。乏味,但你确实到达那里。
回答by GeekHades
we can see the error: we can get the info, this error is about sdk/system-iamges/android-22/android-wear iamge.
我们可以看到错误:我们可以得到信息,这个错误是关于 sdk/system-iamges/android-22/android-wear iamge。
So we can delete the sdk/system-iamges/android-22/android-wear directory. it works for me!
所以我们可以删除sdk/system-iamges/android-22/android-wear目录。这个对我有用!