第一次在这里发帖,在使用Stackoverflow超过一年之后刚刚创建了一个帐户。我一直在尝试让我的简单应用程序工作超过一个小时。我发现java中的任何一个活动都没有错误,也不知道在日志中要查找什么。我已经没有选择,并且认为我会在重写之前尝试这里,所以如果将来发生,我将能够解决它。
日志就是这个
11-02 21:03:37.535 19010-19010/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: net.androidbootcamp.celticsongsapp, PID: 19010
java.lang.RuntimeException: Unable to start activity ComponentInfo{net.androidbootcamp.celticsongsapp/net.androidbootcamp.celticsongsapp.SplashActivity}: android.view.InflateException: Binary XML file line #31: Error inflating class com.android.internal.widget.ActionBarContainer
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441)
at android.app.ActivityThread.access$800(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5431)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
Caused by: android.view.InflateException: Binary XML file line #31: Error inflating class com.android.internal.widget.ActionBarContainer
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3743)
at com.android.internal.policy.impl.PhoneWindowEx.generateLayout(PhoneWindowEx.java:22)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3815)
at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1996)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:148)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:60)
at net.androidbootcamp.celticsongsapp.SplashActivity.onCreate(SplashActivity.java:16)
at android.app.Activity.performCreate(Activity.java:6056)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441)
at android.app.ActivityThread.access$800(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5431)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3743)
at com.android.internal.policy.impl.PhoneWindowEx.generateLayout(PhoneWindowEx.java:22)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3815)
at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1996)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:148)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:60)
at net.androidbootcamp.celticsongsapp.SplashActivity.onCreate(SplashActivity.java:16)
at android.app.Activity.performCreate(Activity.java:6056)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441)
at android.app.ActivityThread.access$800(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5431)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 13
at android.content.res.TypedArray.getDrawable(TypedArray.java:747)
at android.view.View.<init>(View.java:3748)
at android.view.ViewGroup.<init>(ViewGroup.java:498)
at android.widget.FrameLayout.<init>(FrameLayout.java:115)
at android.widget.FrameLayout.<init>(FrameLayout.java:111)
at android.widget.FrameLayout.<init>(FrameLayout.java:107)
at com.android.internal.widget.ActionBarContainer.<init>(ActionBarContainer.java:60)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3743)
at com.android.internal.policy.impl.PhoneWindowEx.generateLayout(PhoneWindowEx.java:22)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3815)
at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1996)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:148)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:60)
at net.androidbootcamp.celticsongsapp.SplashActivity.onCreate(SplashActivity.java:16)
at android.app.Activity.performCreate(Activity.java:6056)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441)
at android.app.ActivityThread.access$800(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5431)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
我希望我没有做错,但我真的很沮丧
要求包含.xml和.class文件
SplashActivity的课程
package net.androidbootcamp.celticsongsapp;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import java.util.Timer;
import java.util.TimerTask;
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
TimerTask task = new TimerTask() {
@Override
public void run() {
finish();
startActivity(new Intent(SplashActivity.this, MainActivity.class));
}
};
Timer opening = new Timer( );
opening.schedule(task,4000);
}
}
这是XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".SplashActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/txtCeltic"
android:id="@+id/txtTitle"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@drawable/celtic"
android:textSize="26sp"
android:gravity="center|bottom"
android:textColor="#000000"
android:textStyle="bold" />
</RelativeLayout>
答案 0 :(得分:0)
尝试为您的活动充气 ActionBarContainer 时会发生这种情况。
因为它很引人注目,我认为你不想要一个动作栏。下面的解决方案假定为。
不看你的布局XML,主要是因为它是一个Splash活动而且它应该是微不足道的,我认为你的问题是因为你应用于活动的主题而发生的。
要修复此问题,请在清单中为Splash活动添加特定主题。
STUDIO
并创建一个主题(在此示例中,在 styles.xml 中称为LIVE and STUDIO
。
<activity
android:name=".view.ActivitySplash"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>