Eclipse和Android SL GridLayout无法一起工作 - “android.support.v7.widget.GridLayout无法实例化” [英] Eclipse and Android SL GridLayout not working together - "android.support.v7.widget.GridLayout could not be instantiated"

查看:402
本文介绍了Eclipse和Android SL GridLayout无法一起工作 - “android.support.v7.widget.GridLayout无法实例化”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android开发的新手,所以这可能是一个简单的问题。道歉,如果是 - 我花了相当多的时间搜索,但找不到任何有效的。

I'm new to Android development, so it's possible this is a simple question. Apologies if it is - I spent quite some time searching but couldn't find anything that worked.

我正在尝试在我的项目中使用GridLayout,但理想情况下Android支持库,所以我可以定位较低版本的API。当我将GridLayout拖动到图形布局设计器中时,会弹出一个消息,要求解释我需要一个兼容性库,用于14岁以上的API版本,并询问我是否要安装此库。我点击安装,让Eclipse做它的事情,但在Eclipse图形布局设计器中出现错误:
以下类不能被实例化:
- android.support .v7.widget.GridLayout
有关详细信息,请参阅错误日志(窗口>显示视图)。
截图

I'm trying to use a GridLayout in my project, but ideally with the Android Support Library so I can target lower versions of the API. When I drag a GridLayout into the graphical layout designer, a message pops up asking explaining I need a compatibility library for API versions older than 14, and asks if I want to install this library. I hit "Install" and let Eclipse do its thing, but an error shows up in the Eclipse graphical layout designer: The following classes could not be instantiated: - android.support.v7.widget.GridLayout See the Error Log ( Window > Show View) for more details. (Screenshot)

从错误日志中,
android.support.v7 .widget.GridLayout无法实例化。 这是堆栈跟踪

我的搜索引起了这个错误这个SO线程,这似乎很有希望;我检查了我的Java,Eclipse和ADT版本,但似乎都是合理的最新版本(Java 7更新17,Eclipse Juno版本,ADT 21.1)。随着更新检查的出现,我看了一下这个SO用户是如何设置他的项目的:Gridlayout的一个图书馆项目,在这个主项目中这个库的一个项目引用,并将gridlayout jar复制到主项目的libs中夹。在Eclipse安装兼容性库消息之后,已经为我创建了一个gridlayout库项目,但项目引用尚未设置,并且没有复制gridlayout jar。我做了这两件事,但是GridLayout仍然没有实例化。

My search for this error turned up this SO thread, which seemed promising; I checked my Java, Eclipse and ADT versions but all seem to be reasonably up-to-date (Java 7 update 17, Eclipse Juno release, ADT 21.1). With the update checks out of the way, I looked at how that SO user had his project set up: a library project for the gridlayout, a project reference to this library in the main project, and the gridlayout jar copied into the main project's libs folder. Following the Eclipse "install compatibility library" message, a gridlayout library project had already been created for me, but the project reference had not been set up and the gridlayout jar hadn't been copied. I did both these things but still the GridLayout fails to instantiate.

我继续搜索,发现另一个SO线程。尽管线程不使用Eclipse,我尝试将答案转换为Eclipse等效项,与上述线程大致相同。 (将gridlayout jar复制到项目的libs文件夹,从gridlayout创建一个库项目,并从主项目中添加一个项目引用到该库项目。)我还验证了gridlayout jar在主项目的构建路径上。 (截图

I continued searching and found another SO thread. Despite that thread not using Eclipse, I attempted to translate the answer into the Eclipse equivalent, which was roughly the same as given by the thread above. (Copy the gridlayout jar to the project's libs folder, create a library project from gridlayout, and add a project reference to that library project from within the main project.) I also verified that the gridlayout jar is on the main project's build path. (Screenshot)

我也是试图按照相关造型Android blogpost 中的说明进行操作,但更糟糕的是,当我尝试将GridLayout拖到我的项目中,它会抛出两个错误,一个 RelativeLayoutRule.onDropped()失败:
java.lang.NullPointerException
此堆栈跟踪初始化项目状态此堆栈跟踪。基于初始化项目状态堆栈跟踪中提到的IOException,我推测问题可能是我的Android SDK的安装位置:%APPDATA%\Local\Android 。我终于尝试卸载SDK并将其重新安装到%PROGRAMFILES%\Android ,但没有任何运气。

I also attempted to follow the instructions in the relevant Styling Android blogpost, but that's even worse: when I try to drag a GridLayout into my project, it throws two errors, a RelativeLayoutRule.onDropped() failed: java.lang.NullPointerException with this stack trace and an Initializing project state with this stack trace. Based on the IOException mentioned in the "Initializing project state" stack trace, I speculated the problem might be my install location for the Android SDK: %APPDATA%\Local\Android. I finally tried uninstalling the SDK and reinstalling it to %PROGRAMFILES%\Android but without any luck.

我我真的不知道从哪里走。如果有人可以给我指向正确的方向,我真的很感激!

I'm not really sure where to go from here. If anyone could give me a pointer in the right direction, I'd really appreciate it!

推荐答案

尝试:
文件 - >导入 - >现有的Android代码到工作空间
指定android-sdk- [platform] / extras / android / support / v7 / gridlayout

Try: File->Import->Existing Android code into workspace Specify android-sdk-[platform]/extras/android/support/v7/gridlayout

将GridLayout项目作为Android库项目导入工作。

You need to import the GridLayout project as an Android library project for it to work.

这篇关于Eclipse和Android SL GridLayout无法一起工作 - “android.support.v7.widget.GridLayout无法实例化”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆