启动器活动未启动它在Android Studio中按下“运行”按钮时崩溃。虽然那里的代码不多,但仍然存在。我已经将logcat粘贴到它下面的setContentView(R.layout.activity_main);
的MainActivity
我试过添加
`res/color/abc_hint_foreground_material_dark.xml`
到目录但仍然得到错误,而前我发布的屏幕截图得到3 VoteDown但是没有解决我的问题,如果你不知道请不要打扰。发布这个问题stackover flow一直要求我添加更多细节我应该添加更多内容?
11-06 17:06:02.890 21445-21445/com.dekhou.UrduKeyboard E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dekhou.UrduKeyboard, PID: 21445
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dekhou.UrduKeyboard/com.dekhou.UrduKeyboard.MainActivity}: android.content.res.Resources$NotFoundException: File res/color/abc_hint_foreground_material_dark.xml from color state list resource ID #0x7f0c0050
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2432)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2492)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1358)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5458)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
Caused by: android.content.res.Resources$NotFoundException: File res/color/abc_hint_foreground_material_dark.xml from color state list resource ID #0x7f0c0050
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2810)
at android.content.res.Resources.loadColorStateList(Resources.java:2759)
at android.content.res.TypedArray.getColorStateList(TypedArray.java:487)
at android.widget.TextView.<init>(TextView.java:749)
at android.widget.TextView.<init>(TextView.java:674)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:54)
at android.support.v7.widget.Toolbar.setTitle(Toolbar.java:756)
at android.support.v7.widget.ToolbarWidgetWrapper.setTitleInt(ToolbarWidgetWrapper.java:261)
at android.support.v7.widget.ToolbarWidgetWrapper.setWindowTitle(ToolbarWidgetWrapper.java:243)
at android.support.v7.widget.ActionBarOverlayLayout.setWindowTitle(ActionBarOverlayLayout.java:615)
at android.support.v7.app.AppCompatDelegateImplV9.onTitleChanged(AppCompatDelegateImplV9.java:636)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:333)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.dekhou.UrduKeyboard.MainActivity.onCreate(MainActivity.java:28)
at android.app.Activity.performCreate(Activity.java:6323)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2385)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2492)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1358)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5458)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
Caused by: java.lang.NumberFormatException: Invalid float: "0.70000005dip"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:164)
at java.lang.StringToReal.parseFloat(StringToReal.java:323)
at java.lang.Float.parseFloat(Float.java:306)
at android.content.res.TypedArray.getFloat(TypedArray.java:398)
at android.content.res.ColorStateList.inflate(ColorStateList.java:275)
at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:222)
at android.content.res.ColorStateList.createFromXml(ColorStateList.java:201)
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2806)
at android.content.res.Resources.loadColorStateList(Resources.java:2759)
at android.content.res.TypedArray.getColorStateList(TypedArray.java:487)
at android.widget.TextView.<init>(TextView.java:749)
at android.widget.TextView.<init>(TextView.java:674)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:54)
at android.support.v7.widget.Toolbar.setTitle(Toolbar.java:756)
at android.support.v7.widget.ToolbarWidgetWrapper.setTitleInt(ToolbarWidgetWrapper.java:261)
at android.support.v7.widget.ToolbarWidgetWrapper.setWindowTitle(ToolbarWidgetWrapper.java:243)
at android.support.v7.widget.ActionBarOverlayLayout.setWindowTitle(ActionBarOverlayLayout.java:615)
at android.support.v7.app.AppCompatDelegateImplV9.onTitleChanged(AppCompatDelegateImplV9.java:636)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:333)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.dekhou.UrduKeyboard.MainActivity.onCreate(MainActivity.java:28)
at android.app.Activity.performCreate(Activity.java:6323)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2385)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2492)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1358)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5458)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)'
abc_hint_foreground_material_dark.xml
<item android:alpha="@dimen/hint_pressed_alpha_material_dark" android:color="@color/foreground_material_dark" android:state_pressed="true" android:state_enabled="true"/>
<item android:alpha="@dimen/hint_alpha_material_dark" android:color="@color/foreground_material_dark"/>
</selector>
答案 0 :(得分:1)
基于
android:alpha="@dimen/hint_alpha_material_dark
和
Caused by: java.lang.NumberFormatException: Invalid float: "0.70000005dip"
您似乎正在尝试将维度用作Alpha值。请改用float资源,例如
android:alpha="@integer/hint_alpha_material_dark_float"
并在价值资源中:
<item name="hint_alpha_material_dark_float" format="float" type="integer">0.7</item>