的IntelliJ和android.support.v7.widget.GridLayout [英] IntelliJ and android.support.v7.widget.GridLayout
问题描述
我遇到麻烦或者建立支持V7网格布局库在我的IntelliJ的项目,或者适当地在我的code引用它。
I am running into trouble either setting up the support v7 GridLayout library in my IntelliJ project, or properly referencing it in my code.
我目前使用在我的项目的ActionBarSherlock和Facebook库,并建立了支持网格布局库以同样的方式(不具有源src文件夹中,我告诉的IntelliJ使用项目目录作为一个jar文件夹)。一切似乎都很正常,构建并部署到我的测试设备,但是当我试图膨胀的布局,我的应用程序崩溃。
I currently use the ActionBarSherlock and Facebook libraries in my project, and have set up the support GridLayout library the same way (not having source in the src folder, I told IntelliJ to use the project dir as a jar folder). Everything looked fine, built and deployed to my test device, but when I tried to inflate the layout, my app crashed.
09-17 17:07:43.916: ERROR/AndroidRuntime(4143): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainHostActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.v7.widget.GridLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2753)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.access$2500(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2117)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.v7.widget.GridLayout
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.decoderhq.indieshuffle.PlayerFragment.onCreateView(PlayerFragment.java:63)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:846)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1160)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:857)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:251)
at com.example.MainHostActivity.onCreate(MainHostActivity.java:58)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
... 11 more
Caused by: java.lang.ClassNotFoundException: android.support.v7.widget.GridLayout in loader dalvik.system.PathClassLoader[/data/app/com.example.MyApp.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at android.view.LayoutInflater.createView(LayoutInflater.java:466)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
... 30 more
的IntelliJ也告诉我,我的网格布局在XML设计师,我无法找到在各种搜索引擎的帮助不准在这里。我的布局(截断长度)如下:
IntelliJ is also telling me that my GridLayout is "not allowed here" in the XML designer, which I unable to find any help on in various search engines. My layout (truncated for length) is as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:grid="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.GridLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
grid:columnCount="3"
grid:rowCount="2"
android:id="@+id/player_grid">
<!-- previous artist label button/view -->
<LinearLayout
android:id="@+id/prev_artist_label_layout"
android:background="@drawable/player_prev_artist_bg_full"
android:padding="10dp"
grid:layout_column="0"
grid:layout_row="0">
<TextView
android:id="@+id/prev_artist_label"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="center"
android:singleLine="true"
style="@style/PlayerArtistText"
android:ellipsize="end"/>
<ImageView
android:id="@+id/prev_artist_label_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"/>
</LinearLayout>
<!-- more cells in the grid [truncated for length] -->
</android.support.v7.widget.GridLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/player_grid">
<TextView
android:id="@+id/curr_time_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
style="@style/PlayerTimeLabels"
android:text="00:00"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"/>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:id="@+id/seek_bar"/>
<TextView
android:id="@+id/duration_time_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
style="@style/PlayerTimeLabels"
android:text="00:00"
android:layout_marginLeft="10dp"
android:layout_marginRight="20dp"/>
</LinearLayout>
</RelativeLayout>
科尔斯注:我有一个RelativeLayout的支持网格布局和LinearLayout中,坐在上面,锚定在RelativeLayout的底部。
Coles Notes: I have a support GridLayout in a RelativeLayout and a LinearLayout that sits on top, anchored at the bottom of the RelativeLayout.
日志表明我缺少的一类。我希望我只是没有设置库正确,我想不出还有什么它可能是。希望有人与一些的IntelliJ / Android的知识能够在正确的方向指向我。
The log indicates I am missing a class. I am hoping I just didn't set the library up properly, as I can't think of what else it could be. Hopefully someone with some IntelliJ/Android knowledge can point me in the right direction.
请宽容我,如果这个问题是缺少一些信息 - 这是我第一次尝试在使用计算器,以寻求帮助。
Please go easy on me if this question is missing some info - this is my first try at using stackoverflow to ask for help.
在此先感谢
推荐答案
好吧,我想通了这一点。原来这是一个配置问题。这是我做过什么来建立支持网格布局库,以及引用的类code。
Ok, I figured this out. Turns out it was a configuration issue. Here is what I did to set up the support GridLayout library, as well as reference the classes in code.
- 复制[Android的SDK文件夹] /演员/安卓/支持/ V7 / GridLayout的文件夹到您的项目libs文件夹
设置支持网格布局库的IntelliJ:
Set up support GridLayout library in IntelliJ:
- 在项目结构 - >在项目设置面板模块 - >新建模块
- 创建从头模块 - >下一步
- 将项目命名为,浏览到您的库/ GridLayout的文件夹并选择为内容的根,离开模块根目录的内容根分配设置,然后选择Android的模块类型 - >下一步
- 请不要创建源目录 - >下一步
- 请不要创建Android应用程序结构 - >完成
- 在项目设置面板中选择构面 - >选择新的模块 - >检查是图书馆计划
添加在扶养的IntelliJ项目:
Add dependancy to project in IntelliJ:
- 在项目设置面板中选择模块 - >选择您希望使用GridLayout的支持项目
- 选择依赖关系选项卡 - >单击[+],添加新的模块扶养
- 从previous节选择您的支持库
您还需要添加一个引用的扶持项目库目录的支持V7 GridLayout的jar文件。
You also need to add a reference to the support v7 GridLayout jar file in the support project libs dir.
- 还是关于依赖关系选项卡 - >单击[+]以添加新的图书馆 - > Java的
- 浏览到库/网格布局/ libs文件夹,然后选择支持V7网格布局的.jar
- 选择级别(我只需要项目级) - >确定
我希望这可以帮助别人 - 我最浪费的是我的一天。 = |
Hopefully this helps someone else - I wasted most my day on it. =|
这篇关于的IntelliJ和android.support.v7.widget.GridLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!