问题描述
我正在开发一个不幸尚未迁移到Android Studio的项目。我想在Google的新的support.design库中使用浮动操作按钮,但是我无法将其包含在我的项目中。
I'm working on a project that unfortunately hasn't been migrated to Android Studio yet. I want to utilize the floating action button in Google's new support.design library but I can't manage to get it included in my project.
我更新了支持库Android SDK管理器。
I updated the support libraries in the Android SDK Manager.
-
首先,我尝试将库导入到Eclipse中,并使用项目→属性→Android 在我的应用程序,但设计项目没有显示为图书馆项目。
First, I tried importing the library into Eclipse and adding it as a dependency using Project → Properties → Android on my app but the design project isn't showing up as a library project.
然后我尝试复制.jar形式的 / libs /
目录中的设计库,并将其包含在我的项目中。这允许我 import android.support.design.widget.FloatingActionButton;
但是当我运行应用程序崩溃,因为它找不到资源 android .support.design.widget.FloatingActionButton
,不能夸大XML。
Then I tried copying the .jar form the /libs/
directory of the design library and including that in my project. That allowed me to import android.support.design.widget.FloatingActionButton;
but when I ran the app it crashed because it could not find the resource android.support.design.widget.FloatingActionButton
and couldn't inflate the XML.
接下来,我尝试添加导入的设计项目到应用程序的构建路径,但我有与上述相同的问题。
Next, I tried adding the imported design project to the build path of the app but I had the same issue as above.
然后,我尝试从构建路径工具添加JAR,但是我又遇到了XML问题。
Then I tried adding the JAR from the build path tool, but again I ran into the XML issue.
我尝试将Android SDK的文件夹中的项目作为外部类文件夹添加,但不起作用。
I tried adding project from my Android SDK's folder as an external class folder but that didn't work.
我没有想法。我意识到现在我们应该使用Android Studio,但是我没有办法做到这一点。有没有人知道如何在Eclipse中工作?
I'm out of ideas. I realize we should be using Android Studio by now but there's nothing I can do about that. Does anyone know how I could get this working in Eclipse?
推荐答案
通过Eclipse的项目属性对话框(项目→属性),不仅可以附加到图书馆项目,还可以将项目标记为图书馆项目。
Through Eclipse's project properties dialog (Project → Properties), not only can you attach to a library project, but you can mark a project as being a library project.
通常当您导入项目时,该信息将从 project.properties
文件中提取。唉,Android支持设计项目没有一个 project.properties
文件,因此Eclipse的库存导入过程假设您正在导入应用程序。
Normally, when you import a project, that information is pulled from the project.properties
file. Alas, the Android Support Design Project does not have a project.properties
file, and Eclipse's stock import process therefore assumes that you are importing an app.
只需进入项目→属性→Android ,并通过Is Library复选框将导入的库标记为库。然后,您可以将其附加到希望使用该图书馆的应用程序。
Just go into Project → Properties → Android and mark the imported library as being a library, via the "Is Library" checkbox. Then, you can attach it to the app that wishes to use the library.
请注意,您将需要重复此图书馆的未来版本的图书馆废话当您导入那些替换您现有的文件时,Google会向库发送更新。
Note that you will need to repeat this "Is Library" nonsense with future editions of the library, when you import those to replace your existing one, when Google ships updates to the library.
当您切换到Android Studio时,所有这些头痛都会消失很容易),尽管它可能会被新的令人兴奋的头痛所取代。 : - )
All of this headache will go away when you switch to Android Studio (adding libraries is much easier), though it will probably be replaced by new and exciting headaches. :-)
这篇关于在Eclipse中使用支持设计库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!