【问题标题】:Android Support Design gradle errorAndroid支持设计gradle错误
【发布时间】:2015-06-15 18:20:50
【问题描述】:

这是我的build.gradle 文件:

...
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:cardview-v7:21.0.+'
    ...
}

在我补充之前:

compile 'com.android.support:design:22.2.0'

现在,当我构建或重建我的项目时(我已经同步了几次 gradle),我收到了以下错误:

.../utils/CustomEditText.java
Error:(6, 42) Gradle: error: cannot find symbol class TintEditText
Error:(14, 35) Gradle: error: cannot find symbol class TintEditText
Error:(37, 8) Gradle: error: cannot find symbol method isInEditMode()
Error:(57, 3) Gradle: error: cannot find symbol method setTypeface(Typeface)
Error:(65, 5) Gradle: error: method does not override or implement a method from a supertype
Error:(67, 23) Gradle: error: cannot find symbol variable super
...

在我的CustomEditText(扩展TintEditText)和使用CustomEditText 的所有活动中。

导入不会引发任何错误,Class:

import android.support.v7.internal.widget.TintEditText;


会是什么?

更新: 使用 ianhanniballake 建议,AppCompatEditText 而不是内部的 TintEditText,解决了编译时错误并回答了这个问题,但现在我遇到了运行时错误:

java.lang.IllegalArgumentException: AppCompat does not support the current theme features 

我看到了一些与此相关的问题,提到的解决方案类似于:

<style name="MyMaterialTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        ...
</style>

但我不想放弃这种方法,因为我有一些使用 ActionBarActivities 和其他不使用的。我的风格是:

<style name="MyTheme" parent="Theme.AppCompat.Light">
        <item name="colorControlNormal">@color/txt_light_grey</item>
        <item name="colorControlActivated">@color/default_orange</item>
        <item name="colorControlHighlight">@color/txt_light_grey</item>
    </style>

    <style name="MyTheme.ActionBar.Orange" parent="MyTheme">
        <item name="windowActionBarOverlay">false</item>
        <item name="colorPrimary">@color/default_orange</item>
    </style>

    <style name="MyTheme.FullScreen" parent="MyTheme">
        <item name="windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>

在我的基地Activity 我愿意:

getWindow().requestFeature(mActionBarView != null ? Window.FEATURE_ACTION_BAR : Window.FEATURE_NO_TITLE);

启用或禁用ActionBar
正如我所说,在我添加 'com.android.support:design:22.2.0' 或将 appcompat-v7:22.0.0 更新为 22.2.0 之前,这非常有效。我只想使用TabLayout,但我想我不会...

【问题讨论】:

  • 更新到最新的android设计库后我也遇到了这个错误。我刚改成Edittext。

标签: android android-gradle-plugin android-appcompat android-support-design


【解决方案1】:

AppCompat 22.1.0 版本开始,您应该使用AppCompatEditText 而不是内部的TintEditText

【讨论】:

  • AppcompatEdittext 和普通的 Edittext 有什么区别..我看不出它们之间有什么区别
  • @Ranjith - 正如我在该问题的答案中链接到的文档和博客文章中所述,当您使用 AppCompatActivity 或等效项时,EditText 会自动替换为 AppCompatEditText您不会看到区别 - AppCompatEditText 仅在您构建 EditText 的自定义子类但想要 AppCompat 提供的着色时才有用。
  • TintEditText 与 appcompat-v7:22.0.0 配合得很好,直到我添加了 design:22.2.0 这很奇怪。好吧,这修复了编译时错误,但现在我有一个运行时错误:原因:java.lang.IllegalArgumentException:AppCompat 不支持当前主题功能
  • 从 22.0.0 到 22.2.0 包括非常大的 Android Support Library 22.1.0 release - 搜索“不支持当前主题”会弹出 answer from the author himself
  • 在我发布这个问题之前,我能够找到 Chris Banes 的问题,但他的解决方案对我不起作用。因为我只有 2 个标签,所以我使用了 Google IO 方法并且它有效。也许在未来的晚些时候,如果我必须充分利用 TabLayout,我可以让它发挥作用。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-08-21
  • 1970-01-01
  • 2015-10-23
  • 1970-01-01
  • 1970-01-01
  • 2019-01-21
  • 1970-01-01
相关资源
最近更新 更多