【发布时间】: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>
但我不想放弃这种方法,因为我有一些使用 ActionBar 的 Activities 和其他不使用的。我的风格是:
<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