【问题标题】:No Theme available while using Maven使用 Maven 时没有可用的主题
【发布时间】:2026-01-24 06:50:02
【问题描述】:

我在 Maven 中使用 ABS 时遇到问题。我通过以下方式在我的 POM 中添加了 ABS 支持:

 <dependencies>
   <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>4.0.1.2</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>support-v4</artifactId>
        <version>r10</version>
    </dependency>       

    <dependency>
      <groupId>com.actionbarsherlock</groupId>
      <artifactId>library</artifactId>
      <version>4.2.0</version>
      <type>apklib</type>
      <exclusions>
          <exclusion>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
          </exclusion>
        </exclusions>
    </dependency>

    <dependency>
      <groupId>com.actionbarsherlock</groupId>
      <artifactId>library</artifactId>
      <version>4.2.0</version>
      <type>jar</type>
      <exclusions>
          <exclusion>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
          </exclusion>
        </exclusions>
    </dependency>
</dependencies>

我的源代码编译正常,但我无法添加 ABS 主题,因为没有可用的 ABS 主题。我尝试通过以下方式添加主题:

 <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
            android:theme="@android:style/Theme.Sherlock" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

这会产生错误“找不到与给定名称匹配的资源”。

如何添加 ABS 主题?

提前致谢, 米尔科

【问题讨论】:

  • 请问你有进展吗?

标签: android maven actionbarsherlock


【解决方案1】:

使用@style/Theme.Sherlock 而不是@android:style/Theme.Sherlock

http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme

这篇文章也可能有帮助:

Setting ActionBarSherlock Theme for Android app

【讨论】:

    【解决方案2】:

    我可以假设您使用的是 Android Studio 吗? 如果是这样,这个网站帮助了我,现在我所有的应用程序都基于这种方法:ABS and Android Studio 它每次都对我有用,只需稍作修改:

      1.您不必从其 Git 存储库中分叉 ABS,只需从 ActionBarSherlock.com 获取 zip
      2. 创建一个库文件夹,然后创建一个子文件夹 `ActionBarSherlock`,将 zip 中的所有内容解压缩到 \libraries\ActionBarSherlock
      3. 按照指南中的说明创建/编辑 build.gradle 文件。

    当您修改文件时,Android Studio 会不断地向您抛出错误,并且它会尝试在您进行时继续编译它们.. 一直到最后。

    【讨论】:

      最近更新 更多