2013-04-18 2 views
0

Я сделал начало простого приложения для Android, он прошел хорошо, но поскольку я добавил яму, у меня есть ошибка: «Приложение неожиданно остановилось, попробуйте еще раз». Я нашел много темы на эту тему, но мне не удалось исправить мои. Это мое первое реальное приложение, которое я делаю сам, надеюсь, вы могли бы мне помочь. В LogCat я есть:Приложение неожиданно остановилось, повторите попытку. Android

04-18 14:59:13.926: E/AndroidRuntime(331): FATAL EXCEPTION: main 
04-18 14:59:13.926: E/AndroidRuntime(331): java.lang.RuntimeException: Unable to start  activity ComponentInfo{com.example.joignabilite/com.example.joignabilite.Identification}: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.RelativeLayout 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.os.Handler.dispatchMessage(Handler.java:99) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.os.Looper.loop(Looper.java:123) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.app.ActivityThread.main(ActivityThread.java:3683) 
04-18 14:59:13.926: E/AndroidRuntime(331): at java.lang.reflect.Method.invokeNative(Native Method) 
04-18 14:59:13.926: E/AndroidRuntime(331): at java.lang.reflect.Method.invoke(Method.java:507) 
04-18 14:59:13.926: E/AndroidRuntime(331): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
04-18 14:59:13.926: E/AndroidRuntime(331): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
04-18 14:59:13.926: E/AndroidRuntime(331): at dalvik.system.NativeStart.main(Native Method) 
04-18 14:59:13.926: E/AndroidRuntime(331): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.RelativeLayout 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.view.LayoutInflater.createView(LayoutInflater.java:518) 
04-18 14:59:13.926: E/AndroidRuntime(331): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.view.LayoutInflater.inflate(LayoutInflater.java:386) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 
04-18 14:59:13.926: E/AndroidRuntime(331): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.app.Activity.setContentView(Activity.java:1657) 
04-18 14:59:13.926: E/AndroidRuntime(331): at com.example.joignabilite.Identification.onCreate(Identification.java:12) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 
04-18 14:59:13.926: E/AndroidRuntime(331): ... 11 more 
04-18 14:59:13.926: E/AndroidRuntime(331): Caused by: java.lang.reflect.InvocationTargetException 
04-18 14:59:13.926: E/AndroidRuntime(331): at java.lang.reflect.Constructor.constructNative(Native Method) 
04-18 14:59:13.926: E/AndroidRuntime(331): at java.lang.reflect.Constructor.newInstance(Constructor.java:415) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.view.LayoutInflater.createView(LayoutInflater.java:505) 
04-18 14:59:13.926: E/AndroidRuntime(331): ... 21 more 
04-18 14:59:13.926: E/AndroidRuntime(331): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060001 a=-1 r=0x7f060001} 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.content.res.Resources.loadDrawable(Resources.java:1681) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.view.View.<init>(View.java:1951) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.view.View.<init>(View.java:1899) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.view.ViewGroup.<init>(ViewGroup.java:286) 
04-18 14:59:13.926: E/AndroidRuntime(331): at android.widget.RelativeLayout.<init>(RelativeLayout.java:173) 
04-18 14:59:13.926: E/AndroidRuntime(331): ... 24 more 

Моя активность:

<?xml version="1.0" encoding="utf-8"?> 
<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:background="@style/AppTheme" 
android:orientation="horizontal" 
tools:context=".Identification" > 

<TextView 
    android:id="@+id/headerFond" 
    android:layout_width="fill_parent" 
    android:layout_height="40dp" 
    android:background="@drawable/header_band" 
    tools:ignore="SelectableText" /> 

<TextView 
    android:id="@+id/headerLogo2" 
    android:layout_width="40dp" 
    android:layout_height="30dp" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="5dp" 
    android:background="@drawable/logo2_part2" 
    tools:ignore="SelectableText" /> 

<TextView 
    android:id="@+id/headerLogo1" 
    android:layout_width="80dp" 
    android:layout_height="40dp" 
    android:layout_toLeftOf="@id/headerLogo2" 
    android:background="@drawable/logo2_part1" 
    tools:ignore="SelectableText" /> 

</RelativeLayout> 

Мои Identification.java:

package com.example.joignabilite; 

import android.os.Bundle; 
import android.app.Activity; 
import android.view.Menu; 

public class Identification extends Activity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_identification); 
} 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.identification, menu); 
    return true; 
} 

} 

И мой манифест:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.joignabilite" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="17" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name="com.example.joignabilite.Identification" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

</manifest> 
+0

Похож на некоторые проблемы с ресурсами. Попытайтесь проверить, что вы. Чтобы убедиться, что это правильный ответ, вы можете удалить строки: android: background = "@ drawable/header_band" android: background = "@ drawable/logo2_part2" android: background = "@ drawable/logo2_part1" –

+0

'Caused by: android .content.res.Resources $ NotFoundException: ресурс не является Drawable (цвет или путь): TypedValue {t = 0x1/d = 0x7f060001 a = -1 r = 0x7f060001} 'это ваша фактическая ошибка, я думаю, существует какая-то доступная doenst , проверьте @drawables. Хороший способ проверить - использовать помощь кода (ctrl + space), чтобы увидеть, действительно ли они существуют – x4rf41

ответ

0

Вы получаете ошибка, потому что линии:

android:background="@style/AppTheme" 

Атрибут background занимает @drawable и @color ресурсы. Вы не можете поставить там стиль.

+0

Спасибо, что это был андроид: фон! Отлично ! – Underground72

Смежные вопросы