gpt4 book ai didi

android - 将 gridlayout 支持库添加到项目中是否存在问题?

转载 作者:行者123 更新时间:2023-11-29 01:49:15 25 4
gpt4 key购买 nike

当我点击使用 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代码导入工作区->找到v7网格布局文件并点击完成

2)转到支持的gridlayout包和libs文件夹,右键单击.jar文件,并将其添加到我的构建路径(我对bin文件做了同样的事情)

3)点击我自己的项目->Properties->Library pane->Add JARs(如下所示)

enter image description here

然后我还有如下标记的订单和导出选项卡:

enter image description here

然后这两个库出现在我的项目“引用库”部分中。 enter image description here

但无论我做什么,我仍然会遇到同样的错误。我这样做是否正确?

最佳答案

您的步骤不正确。而不是这个:

3)Clicked on my own project->Properties->Library pane->Add JARs (as seen below)

执行此操作(来自说明中的 Adding libraries with resources 部分):

  1. In the Project Explorer, right-click your project and select Properties.
  2. In the Library pane, click Add.
  3. Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-appcompat.
  4. In the properties window, click OK.

当然,除了使用 gridlayout 而不是 appcompat

此外,您执行的其余步骤(使用构建和导出选项卡)应该针对 gridlayout 项目完成,而不是您自己的项目(在说明的同一部分中也有详细说明)。

关于android - 将 gridlayout 支持库添加到项目中是否存在问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19340253/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com