通过命令行添加库的资源 [英] Adding libs with resources via command line

查看:141
本文介绍了通过命令行添加库的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图完成的http:// developer.android.com/tool​​s/support-library/setup.html#libs-with-res 不使用Eclipse或摇篮;但是,官方文件不支持。在过去的几个小时里,我一直在谷歌搜索一切我能想到的,但我没有找到任何有用的信息。

具体而言,我想加入 support.v7.appcompat 库。我能够在jar添加到我的项目,但我找不到任何方法来添加相关资源。我不断收到 java.lang.IllegalStateException:你需要使用Theme.AppCompat主题(或后代)与本次活动尽管我已经添加了机器人:主题=@风格/ Theme.AppCompat<舱单>我 AndroidManifest的元素。 XML 每较早,貌似相关的搜索结果之一。我还添加了 android.library.reference.1 =< SDK> /演员/安卓/支持/ V7 / appcompat 我的本地。性能,都无济于事。

是否有人可以教我如何在命令行中添加此库?

解决方案
  

不过,官方文档不支持

借助一般的Andr​​oid库项目说明应该很好地工作。

  

我能够将JAR添加到我的项目

这不是你应该做的事情。

  

我还添加android.library.reference.1 =< SDK> /演员/安卓/支持/ V7 / appcompat我local.properties,无果

这是进去 project.properties ,不是 local.properties 。它需要一个相对路径,对于一些疯狂的原因,所以一定要设置成这样。

就个人而言,我建议您的预算转移到摇篮的时间。


事实证明,有问题的两个层次。除了获得命令行建立正确设置文件,主题未注册相当正确的方式。

如果你要直接引用 Theme.AppCompat 在清单中,它可以:

  • 应该在<应用> 元素,或者
  • 应该是每一个<活性GT; 元素,其中的活性从继承 AppCompatActivity

或者,如果你要坚持你自己的 AppTheme ,它继承自 Theme.AppCompat ,您需要以确保您调整所有的相关的样式资源。例如,您可以调整 AppBaseTheme RES /价值/ styles.xml 继承Theme.AppCompat ,按通常生成(再有 AppTheme AppBaseTheme 继承) code。然而,也有可能是 AppBaseTheme 的定义在其他目录(例如, RES /值-V11 / styles.xml )需要被调整,以及

I'm trying to accomplish http://developer.android.com/tools/support-library/setup.html#libs-with-res without using eclipse or gradle; however, the official documentation doesn't support that. For the last couple hours, I've been Googling everything I can think of, but I'm not finding any helpful information.

Specifically, I'm trying to add the support.v7.appcompat library. I'm able to add the jar to my project, but I can't find any way to add the relevant resources. I keep getting java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. even though I've added android:theme="@style/Theme.AppCompat" to the <manifest> element of my AndroidManifest.xml per one of the earlier, seemingly-relevant search results. I've also added android.library.reference.1=<sdk>/extras/android/support/v7/appcompat to my local.properties, to no avail.

Can someone please instruct me on how to add this library from the command line?

解决方案

however, the official documentation doesn't support that

The general Android library project instructions should work fine.

I'm able to add the jar to my project

That's not what you are supposed to do.

I've also added android.library.reference.1=<sdk>/extras/android/support/v7/appcompat to my local.properties, to no avail.

That goes in project.properties, not local.properties. And it needs to be a relative path, for some crazy reason, so make sure you set it up that way.

Personally, I'd recommend that you budget the time to move to Gradle.


It turns out that there were two tiers of problems. In addition to getting the command-line build files set up properly, the theme wasn't registered quite the right way.

If you are going to directly reference Theme.AppCompat in the manifest, it either:

  • should be on the <application> element, or
  • should be on every <activity> element where the activity inherits from AppCompatActivity

Or, if you are going to stick with your own AppTheme that inherits from Theme.AppCompat, you need to ensure that you adjust all of the relevant style resources. For example, you might adjust AppBaseTheme in res/values/styles.xml to inherit from Theme.AppCompat (and then have AppTheme inherits from AppBaseTheme), per commonly-generated code. However, there may also be definitions of AppBaseTheme in other directories (e.g., res/values-v11/styles.xml) that need to be adjusted as well.

这篇关于通过命令行添加库的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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