错误导致类info.hoang8f.widget.FButton

时间:2017-10-26 06:56:00

标签: java android xml

错误日志:

  

10-26 12:22:33.144 26926-26926 /? E / AndroidRuntime:致命异常:主要                                                      处理:ksmk.sahip.com.ecom,PID:26926                                                      java.lang.RuntimeException:无法启动活动ComponentInfo {ksmk.sahip.com.ecom / ksmk.sahip.com.ecom.MainActivity}:android.view.InflateException:二进制XML文件行#0:二进制XML文件行#0 :错误膨胀类info.hoang8f.widget.FButton                                                          在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)                                                          在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)                                                          在android.app.ActivityThread.-wrap12(ActivityThread.java)                                                          在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1460)                                                          在android.os.Handler.dispatchMessage(Handler.java:102)                                                          在android.os.Looper.loop(Looper.java:154)                                                          在android.app.ActivityThread.main(ActivityThread.java:6077)                                                          at java.lang.reflect.Method.invoke(Native Method)                                                          在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:866)                                                          在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)                                                       引起:android.view.InflateException:二进制XML文件行#0:二进制XML文件行#0:错误导致类info.hoang8f.widget.FButton                                                       引起:android.view.InflateException:二进制XML文件行#0:错误导致类info.hoang8f.widget.FButton                                                       引起:java.lang.reflect.InvocationTargetException                                                          at java.lang.reflect.Constructor.newInstance0(Native Method)                                                          at java.lang.reflect.Constructor.newInstance(Constructor.java:430)                                                          在android.view.LayoutInflater.createView(LayoutInflater.java:645)                                                          在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)                                                          在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)                                                          在android.view.LayoutInflater.rInflate(LayoutInflater.java:858)                                                          在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)                                                          在android.view.LayoutInflater.rInflate(LayoutInflater.java:861)                                                          在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)                                                          在android.view.LayoutInflater.inflate(LayoutInflater.java:518)                                                          在android.view.LayoutInflater.inflate(LayoutInflater.java:426)                                                          在android.view.LayoutInflater.inflate(LayoutInflater.java:377)                                                          在android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)                                                          在android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)                                                          在ksmk.sahip.com.ecom.MainActivity.onCreate(MainActivity.java:36)                                                          在android.app.Activity.performCreate(Activity.java:6662)                                                          在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)                                                          在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)                                                          在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)                                                          在android.app.ActivityThread.-wrap12(ActivityThread.java)                                                          在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1460)                                                          在android.os.Handler.dispatchMessage(Handler.java:102)                                                          在android.os.Looper.loop(Looper.java:154)                                                          在android.app.ActivityThread.main(ActivityThread.java:6077)                                                          at java.lang.reflect.Method.invoke(Native Method)                                                          在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:866)                                                          在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)                                                       引起:java.lang.UnsupportedOperationException:无法将索引1处的值转换为color:type = 0x5                                                          在android.content.res.TypedArray.getColor(TypedArray.java:463)                                                          在info.hoang8f.widget.FButton.parseAttrs(FButton.java:116)                                                          在info.hoang8f.widget.FButton。(FButton.java:52)                                                          at java.lang.reflect.Constructor.newInstance0(Native Method)                                                          at java.lang.reflect.Constructor.newInstance(Constructor.java:430)                                                          在android.view.LayoutInflater.createView(LayoutInflater.java:645)                                                          在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)                                                          在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)                                                          在android.view.LayoutInflater.rInflate(LayoutInflater.java:858)                                                          在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)                                                          在android.view.LayoutInflater.rInflate(LayoutInflater.java:861)                                                          在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)                                                          在android.view.LayoutInflater.inflate(LayoutInflater.java:518)                                                          在android.view.LayoutInflater.inflate(LayoutInflater.java:426)                                                          在android.view.LayoutInflater.inflate(LayoutInflater.java:377)                                                          在android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)                                                          在android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)                                                          在ksmk.sahip.com.ecom.MainActivity.onCreate(MainActivity.java:36)                                                          在android.app.Activity.performCreate(Activity.java:6662)                                                          在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)                                                          在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)                                                          在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)                                                          在android.app.ActivityThread.-wrap12(ActivityThread.java)                                                          在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1460)                                                          在android.os.Handler.dispatchMessage(Handler.java:102)                                                          在android.os.Looper.loop(Looper.java:154)                                                          在android.app.ActivityThread.main(ActivityThread.java:6077)                                                          at java.lang.reflect.Method.invoke(Native Method)                                                          在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:866)                                                          在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)   10-26 12:22:33.692 1305-1305 /? E / EGL_emulation:tid 1305:eglCreateSyncKHR(1901):错误0x3004(EGL_BAD_ATTRIBUTE)

6 个答案:

答案 0 :(得分:2)

到目前为止,android gradle插件版本3.0.0中出现此问题。所以只需将android gradle插件版本更改为2.3.3。您可以在build.gradle(项目级别)文件中更改它,例如:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

答案 1 :(得分:1)

使用此依赖关系将解决错误

  implementation 'com.github.jd-alexander:android-flat-button:v1.1'

在代码中使用此按钮来投射按钮

 Button btn_CreateNewVideo;
 btn_CreateNewVideo = (FButton) findViewById(R.id.createnewvideo);

答案 2 :(得分:0)

如果您已将Android工作室版本更新为3.o,请转到文件 - >项目结构 - >项目 - >将gradle插件版本更改为2.3.0并将gradle版本更改为3.3

我希望这会有所帮助

答案 3 :(得分:0)

可以在此处找到相同的平面FButton主题:

将库用作依赖项https://github.com/jd-alexander/android-flat-button

https://jitpack.io/#jd-alexander/android-flat-button/v1.1

 dependencies {
    implementation  'com.github.jd-alexander:android-flat-button:v1.1'

}

答案 4 :(得分:0)

我找到的另一种解决方案

更改:

Dependence {
      implementation 'info.hoang8f:android-segmented:1.0.6'
}

您可以将施放(FButton)更改为具有相同先前依赖关系的(按钮)

答案 5 :(得分:0)

所以,前段时间我遇到了完全相同的错误,因为我的 Android Studio 版本高于实施 info.hoang8f 的版本,所以,一步一步如何修复它:

  1. 在您的 build.gradle project:level 中,在 allprojects -> repositories 中添加这一行:maven { url 'https://jitpack.io' }

  2. 在您的 build.gradle app:level 中,在依赖项中添加这一行:implementation 'com.github.jd-alexander:android-flat-button:v1.1'

  3. 移除'info.hoang8f...'Clean Project的实现线;

  4. 请记住,这个新实现使用 fButtonColor,因此,您需要将 XML 文件中的 app:buttonColor='@color/someColor' 更改为:app:fButtonColor='@color/someColor'

不要:

  • 更改您的 Gradle 版本,这可能会引发一些实现错误;