安卓支持设计gradle错误

3
这是我的 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
...

在我的扩展了 TintEditTextCustomEditText 中,以及所有使用该 CustomEditText 的活动中。
导入没有抛出任何错误,也没有 Class:
import android.support.v7.internal.widget.TintEditText;


这可能是什么呢?

更新: 使用ianhanniballake的建议,将内部的TintEditText替换为AppCompatEditText可以解决编译时错误并回答此问题,但现在我遇到了运行时错误:

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>

但我不想采用这种方法,因为我的一些活动使用了ActionBar,而其他的则没有。我的样式如下:

<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。 - Psypher
1个回答

6

AppcompatEdittext和普通的Edittext有什么区别?我看不出它们之间有任何区别。 - Psypher
@Ranjith - 正如我在回答这个问题时提到的文档和博客文章中所指出的,当您使用AppCompatActivity或等效类时,EditText会自动替换为AppCompatEditText,因此您不会看到任何区别。只有在构建EditText的自定义子类但需要AppCompat提供的着色功能时,AppCompatEditText才有用。 - ianhanniballake
TintEditText在appcompat-v7:22.0.0中运行良好,直到我添加了design:22.2.0,这很奇怪。 好吧,这解决了编译时错误,但现在我有一个运行时错误:Caused by: java.lang.IllegalArgumentException: AppCompat不支持当前主题功能。 - GuilhE
从22.0.0升级到22.2.0,包含了非常重要的Android Support Library 22.1.0版本 - 搜索“不支持当前主题”会出现作者本人的回答 - ianhanniballake
在我发布这个问题之前,我能够找到Chris Banes的问题,但他的解决方案对我不起作用。由于我只有两个选项卡,所以我使用了Google IO的方法,它起作用了。也许将来如果我必须充分利用TabLayout,我可以让它起作用。谢谢。 - GuilhE

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接