java Android Studio FloatingActionButton 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35675855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Studio FloatingActionButton error
提问by oscaro
I installed Android Studio yesterday, and after battling multiple java and other errors, I have come to an error that I cannot seem to fix. I have not added anything or done any code, I have simply just started a new project and I get this error in the Preview over the phone:
我昨天安装了 Android Studio,在与多个 java 和其他错误作斗争后,我遇到了一个似乎无法修复的错误。我没有添加任何内容或执行任何代码,我只是刚刚开始一个新项目,但我在电话预览中收到此错误:
Rendering Problems:
渲染问题:
The following classes could not be instantiated:
-?android.support.design.widget.FloatingActionButton
Followed by a bunch of Exception Details. All help appreciated, I'm getting desperate. Also, please be specific with complicated answers, as I am not very savvy with this as of yet.
后面是一堆异常详细信息。感谢所有帮助,我越来越绝望。另外,请具体说明复杂的答案,因为我目前对此还不是很精通。
If Exception Details are needed:
如果需要异常详细信息:
android.content.res.Resources$NotFoundException: Unable to find resource ID #0x1080029
??at android.content.res.Resources.getResourceName(Resources.java:2235)
??at android.content.res.Resources.loadDrawableForCookie(Resources.java:2602)
??at android.content.res.Resources.loadDrawable(Resources.java:2540)
??at android.content.res.Resources.getDrawable(Resources.java:806)
??at android.content.Context.getDrawable(Context.java:458)
??at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:26)
??at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:321)
??at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
??at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:70)
??at android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:39)
??at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:65)
??at android.support.design.widget.VisibilityAwareImageButton.<init>(VisibilityAwareImageButton.java:37)
??at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:109)
??at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:105)
??at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
??at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
??at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)
??at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
??at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
??at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
??at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
??at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
回答by Handrata Samsul
I also got this problem today,
我今天也遇到这个问题
Check your build.gradlefile, do you use support design lib version 23.2, like
检查您的build.gradle文件,您是否使用支持设计库版本 23.2,例如
compile 'com.android.support:design:23.2.0'
if so, change it to version 23.1.0
如果是这样,请将其更改为版本 23.1.0
compile 'com.android.support:design:23.1.0'
then rebuild your project... seems version 23.2 is still buggy
然后重建你的项目......似乎版本 23.2 仍然有问题
回答by Connor Goddard
In addition to the change detailed in @Handrata Samsul's answer, I also had to make another change in the build.gradle
file.
除了@Handrata Samsul 的回答中详述的更改之外,我还必须对build.gradle
文件进行另一项更改。
Modify:
调整:
compile 'com.android.support:appcompat-v7:23.2.0'
to become:
成为:
compile 'com.android.support:appcompat-v7:23.1.0'
Therefore, the sum of all changes were as follows:
因此,所有变化的总和如下:
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
Thanks.
谢谢。
回答by Kev
This worked for me:
这对我有用:
I changed in the build.gradle
file.
我在build.gradle
文件里改了 。
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:design:23.2.0'
to
到
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:design:23.1.0'
Then clean, rebuild, then "refresh" each layout file. The refresh button on the top right in the layout editor.
然后清理,重建,然后“刷新”每个布局文件。布局编辑器右上角的刷新按钮。
回答by IntelliJ Amiya
android.content.res.Resources$NotFoundException: Unable to find resource ID #0x1080029
android.content.res.Resources$NotFoundException:无法找到资源 ID #0x1080029
This exception is thrown by the resource APIs when a requested resource can not be found.
当找不到请求的资源时,资源 API 会抛出此异常。
You should use stable version .You can then start using the Design librarywith a single new dependency with :
您应该使用稳定版本。然后您可以开始使用具有单个新依赖项的设计库:
Do
做
compile 'com.android.support:design:23.1.0'
Then Clean-Rebuild-Sync
Your IDE.Hope this helps .
那么Clean-Rebuild-Sync
你的IDE。希望这会有所帮助。
Don't
别
compile 'com.android.support:design:23.2.0'
Version 23.2.0
is buggy .Its not stable . You should go for stable above version 23.1.0
.
版本23.2.0
有问题。不稳定。你应该选择稳定版以上23.1.0
。
回答by Kukki
The configuration compile
is obsolete and has been replaced with implementation
and api
.
该配置compile
已过时并已替换为implementation
和api
。
You should use:
你应该使用:
implementation 'com.android.support:design:23.0.0'
or:
或者:
implementation 'com.android.support:design:28.0.0'
as per your compileSDK version instead of:
根据您的 compileSDK 版本而不是:
compile 'com.android.support:design:23.0.0'
回答by Jan Rabe
also update gradle version you're using for compiling, e.g. 2.13 instead of 2.9/2.10 which fails with higher support libs usually
还要更新您用于编译的 gradle 版本,例如 2.13 而不是 2.9/2.10,它通常会因更高的支持库而失败
easiest is to to a gradle task in your main build.gradle:
最简单的方法是在主 build.gradle 中执行 gradle 任务:
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}
and then run it with
然后运行它
gradle wrapper
回答by Henry98
That error pops up if any of the following things happen :
如果发生以下任何事情,则会弹出该错误:
You don't have the latest SDK versions installed. Make sure you have the right versions. You need to have Android M installed to use the floating action button. (Use the Android SDK Installer)
Your gradle dependencies are wrong.
您没有安装最新的 SDK 版本。确保您拥有正确的版本。您需要安装 Android M 才能使用浮动操作按钮。(使用 Android SDK 安装程序)
您的 gradle 依赖项是错误的。
If you are new to Android Studios, chances are the problem is both 1 and 2.
如果您是 Android Studios 的新手,那么问题很可能是 1 和 2。
For the 2nd issue, go to your gradle file and put this in :
对于第二个问题,转到您的 gradle 文件并将其放入:
dependencies {
compile 'com.android.support:design:23.0.0'
}
That should fix the issue.
那应该可以解决问题。