Я пытаюсь запустить мое приложение с телефоном (Galaxy Nexus), но он постоянно показывает ошибку: Unfortunately, <app name> has stopped.
К сожалению, <app name> остановился. (Андроид студия)
Вот мой styles.xml
файл:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
<itemname="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#872657</item>
<item name="android:titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>
<item name="android:colorBackground">#872657</item>
</style>
<style name="AppTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.StatusBar.Title">
<item name="android:textColor">#dfe3ee</item>
<item name="android:background">#872657</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#dfe3ee</item></style>
</resources>
Вот мой activity_main.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=".MainActivity"
android:background="#872657">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/SplashImageView"
android:layout_gravity="center"
>
</ImageView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView" />
<Button
android:id="@+id/dialer_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next"
android:background="#dfe3ee"
android:onClick="onGetNameClick"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Enter Your Name"
android:id="@+id/textView2"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/textView"
android:layout_alignRight="@+id/dialer_button"
android:layout_alignEnd="@+id/dialer_button"
android:textColor="#fefbf7"
android:typeface="normal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Enter Your Phone Number"
android:id="@+id/textView3"
android:layout_below="@+id/textView2"
android:layout_toRightOf="@+id/textView"
android:layout_marginTop="40dp"
android:layout_alignRight="@+id/textView2"
android:layout_alignEnd="@+id/textView2"
android:textColor="#fefbf7"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Enter E-Mail ID"
android:id="@+id/textView4"
android:layout_marginTop="47dp"
android:layout_below="@+id/textView3"
android:layout_toRightOf="@+id/textView"
android:layout_alignRight="@+id/textView3"
android:layout_alignEnd="@+id/textView3"
android:textColor="#fefbf7"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Enter Emergency Contact Number"
android:id="@+id/textView5"
android:layout_below="@+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/editText3"
android:layout_alignEnd="@+id/editText3"
android:textColor="#fefbf7"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/editText"
android:layout_toRightOf="@+id/textView"
android:layout_alignRight="@+id/textView2"
android:layout_alignEnd="@+id/textView2"
android:layout_below="@+id/textView2" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/editText3"
android:layout_below="@+id/textView4"
android:layout_toRightOf="@+id/textView"
android:layout_alignRight="@+id/textView4"
android:layout_alignEnd="@+id/textView4" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="@+id/editText2"
android:layout_below="@+id/textView3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/textView3"
android:layout_alignEnd="@+id/textView3" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="@+id/editText4"
android:layout_below="@+id/textView5"
android:layout_toRightOf="@+id/textView"
android:layout_alignRight="@+id/textView5"
android:layout_alignEnd="@+id/textView5" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="App Coded by ©Ananay Batra"
android:id="@+id/textView6"
android:layout_below="@+id/editText4"
android:layout_centerHorizontal="true"
android:layout_marginTop="59dp"
android:textColor="#fefbf7"/>
<TextView android:id="@android:id/text1"
style="?android:textAppearanceLarge"
android:textStyle="bold"
android:textColor="#fff"
android:layout_width="match_parent"
android:layout_height="wrap_content"></TextView></RelativeLayout>
Вот мой MainActivity.java
:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
} }
Вот мой Second_layout1.xml
файл:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="left"
android:padding="20dp"
android:weightSum="1"
android:background="#872657">
<RadioButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Follow Me"
android:id="@+id/radioButton"
android:layout_weight="0.09"
android:textSize="20dp"
android:layout_toRightOf="@+id/linearLayout"
android:layout_toEndOf="@+id/linearLayout"
android:layout_below="@+id/linearLayout"
android:textColor="#fefbf7"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/linearLayout">
</LinearLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Post Location on Facebook"
android:id="@+id/button2"
android:layout_weight="0.09"
android:background="#dfe3ee"
android:padding="20dp"
android:layout_below="@+id/radioButton"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="47dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send Message to Emergency Contact"
android:id="@+id/button"
android:background="#dfe3ee"
android:layout_below="@+id/button2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="38dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" /></RelativeLayout>
Я бы очень хотел, чтобы кто-то ответить !!
А также объяснить, что я сделал неправильно в моем коде
LogCat:
4758-4758/com.example.ananaybatra.rape_freeindia D/AndroidRuntime﹕ Shutting down VM
04-24 01:39:13.014 4758-4758/com.example.ananaybatra.rape_freeindia W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x415ffba8)
04-24 01:39:13.030 4758-4758/com.example.ananaybatra.rape_freeindia E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.ananaybatra.rape_freeindia, PID: 4758
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ananaybatra.rape_freeindia/com.example.ananaybatra.rape_freeindia.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2221)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2280)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5059)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:152)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:149)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
at com.example.ananaybatra.rape_freeindia.MainActivity.onCreate(MainActivity.java:15)
at android.app.Activity.performCreate(Activity.java:5312)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2178)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2280)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5059)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
Пожалуйста, разместите свой logcat (любые ошибки, которые вы получаете) –
Пожалуйста, разместите свой LogCat (любые ошибки, которые вы получаете) –
Аналогичный вопрос: http://stackoverflow.com/questions/21814825/you-need-to -use-a-theme-appcompat-theme-or-descendant-with-this-activity – Titus