當我點擊我的窗口小部件,使用了GridLayout支持庫,我得到這個錯誤:問題添加gridlayout支持庫到項目?
10-12 17:15:14.373: E/dalvikvm(3957): Could not find class 'com.example.awesomefilebuilderwidget.Drag_and_Drop_App$MyDragListener', referenced from method com.example.awesomefilebuilderwidget.Drag_and_Drop_App.onCreate
10-12 17:15:14.433: E/AndroidRuntime(3957): FATAL EXCEPTION: main
10-12 17:15:14.433: E/AndroidRuntime(3957): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.awesomefilebuilderwidget/com.example.awesomefilebuilderwidget.Drag_and_Drop_App}: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.GridLayout
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1833)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1854)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1041)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.os.Handler.dispatchMessage(Handler.java:99)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.os.Looper.loop(Looper.java:150)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.app.ActivityThread.main(ActivityThread.java:4333)
10-12 17:15:14.433: E/AndroidRuntime(3957): at java.lang.reflect.Method.invokeNative(Native Method)
10-12 17:15:14.433: E/AndroidRuntime(3957): at java.lang.reflect.Method.invoke(Method.java:507)
10-12 17:15:14.433: E/AndroidRuntime(3957): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-12 17:15:14.433: E/AndroidRuntime(3957): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-12 17:15:14.433: E/AndroidRuntime(3957): at dalvik.system.NativeStart.main(Native Method)
10-12 17:15:14.433: E/AndroidRuntime(3957): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v7.widget.GridLayout
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-12 17:15:14.433: E/AndroidRuntime(3957): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:231)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.app.Activity.setContentView(Activity.java:1712)
10-12 17:15:14.433: E/AndroidRuntime(3957): at com.example.awesomefilebuilderwidget.Drag_and_Drop_App.onCreate(Drag_and_Drop_App.java:22)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1797)
10-12 17:15:14.433: E/AndroidRuntime(3957): ... 11 more
10-12 17:15:14.433: E/AndroidRuntime(3957): Caused by: java.lang.reflect.InvocationTargetException
10-12 17:15:14.433: E/AndroidRuntime(3957): at java.lang.reflect.Constructor.constructNative(Native Method)
10-12 17:15:14.433: E/AndroidRuntime(3957): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
10-12 17:15:14.433: E/AndroidRuntime(3957): ... 20 more
10-12 17:15:14.433: E/AndroidRuntime(3957): Caused by: java.lang.NoClassDefFoundError: android.support.v7.gridlayout.R$dimen
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.support.v7.widget.GridLayout.<init>(GridLayout.java:255)
10-12 17:15:14.433: E/AndroidRuntime(3957): at android.support.v7.widget.GridLayout.<init>(GridLayout.java:274)
10-12 17:15:14.433: E/AndroidRuntime(3957): ... 23 more
我跟着官方Android開發人員指南,以支持庫添加到我的項目,但我仍然得到錯誤。
正如我相信這或多或少是我的錯某處沿線繼承人的步驟,我把添加它:
1)赴文件 - >導入 - >將現有Android代碼到Workspace->發現V7 GridLayout的文件,並點擊完成
2)又到了支持GridLayout的包,到庫文件夾,右鍵點擊.jar文件,並將其添加到我的構建路徑(我做了bin文件相同)
3)點擊我自己的項目 - >屬性 - >庫窗格 - >添加JAR(如下所示)
然後我也有訂單和出口標籤如下標註:
隨後兩個庫在我的項目「引用的庫」部分顯示出來。
但無論我做什麼,我仍然得到同樣的錯誤。我是否正確地做這件事?
好的,謝謝!我還注意到,我對「庫窗格」的內容感到困惑,所以我想到了它出現在「Android」部分。 – user1628978