【问题标题】:Android app crashes/fails when using Titanium Studio 3.3.0.GA使用 Titanium Studio 3.3.0.GA 时 Android 应用程序崩溃/失败
【发布时间】:2014-07-25 21:18:55
【问题描述】:

我不断收到此错误:

Error: No resource found that matches the given name (at 'theme' with value '@android:style/Theme.AppCompat.Light').

这是我的 tiap.xml 的样子:

<android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <application android:theme="@android:style/Theme.AppCompat.Light"/>
            <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
            <supports-screens android:anyDensity="false"/>
        </manifest>
</android>

当我将它改回之前的状态时,即"@android:style/Theme.Holo.Light",应用程序将崩溃并且我会收到此错误:

You need to use a Theme.AppCompat theme (or descendant) with this activity.

注意:我希望它是 HoloLight 主题。

【问题讨论】:

  • 结帐this链接。

标签: android titanium titanium-mobile titanium-alloy


【解决方案1】:

我想通了

这是不正确的(使用 3.3.0 时):

<application android:theme="@android:style/Theme.AppCompat.Light"/>

这是正确的:

<application android:theme="@style/Theme.AppCompat.Light"/>

你不需要@符号后面的“android”部分。

【讨论】:

    【解决方案2】:

    无法使用普通 Theme.Holo.Light 样式的原因是因为您的 SDK 最低版本为 10,不支持 Holo Light Theme。因此,编译器建议您将使用的样式更改为支持您尝试开发的较低 SDK 的样式。解决此问题的一种简单方法是不支持较旧的 Android 版本,但这可能不适合您。

    由于您使用的是 Titanium Studio,我知道当其他人都在使用 Eclipse 和 Android Studio 时,找到修复可能会有点困难(他们可能会告诉您需要将支持库添加到您的build path 或 build.gradle,它并不能完全转换为 Titanium Studio),但我相信这个修复应该可以工作。

    基本上,您要做的是让运行较新版本 Android 的设备使用 Holo Light Theme,而旧版本将仅显示较旧的 Light Theme。我打算只写关于如何做到这一点的说明,但在 Appcelerator 的网站上有一个旧的论坛帖子详细说明了确切的步骤。这是具体答案的链接(这是一个有 8 票的答案):

    http://developer.appcelerator.com/question/130719/how-do-you-build-your-app-with-holo-theme#answer-250415

    我相信遵循这些步骤应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多