Android 支持设计 gradle 错误
Android Support Design gradle error
这是我的 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>
但我不想放弃这种方法,因为我有一些 Activities
使用 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);
启用或禁用 [=29=]。
正如我所说,在我添加 'com.android.support:design:22.2.0'
或将 appcompat-v7:22.0.0
更新为 22.2.0 之前,它工作得很好。我只想使用 TabLayout
,但我想我不会...
从版本 AppCompat 22.1.0, you should use AppCompatEditText 开始,而不是内部版本 TintEditText
。
这是我的 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>
但我不想放弃这种方法,因为我有一些 Activities
使用 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);
启用或禁用 [=29=]。
正如我所说,在我添加 'com.android.support:design:22.2.0'
或将 appcompat-v7:22.0.0
更新为 22.2.0 之前,它工作得很好。我只想使用 TabLayout
,但我想我不会...
从版本 AppCompat 22.1.0, you should use AppCompatEditText 开始,而不是内部版本 TintEditText
。