2013-11-15 7 views
0

다른 유사한 질문을 찾아서 해결책을 찾을 수 없으므로 여기에 있습니다. 저는 C와 Mathematica 및 ROOT와 같은 몇 가지 특정 프로그램뿐만 아니라 C++ 및 Python에 대한 기본 지식이 있지만 Java 및 Android 프로그래밍에 대한 완벽한 초보자입니다.안드로이드 프로그래밍에서 또 다른 치명적인 예외가 발생했습니다

나는 매우 간단한 안드로이드 응용 프로그램을 만들려고했다 : 번호가 표시되고 숫자가 올라가거나 내려가는 두 개의 버튼이 있지만 오류가 많다. 도와 주실 시간이 있으면이 첫 번째 임팩트에 실망합니다.

이 내 .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:background="@style/AppTheme" 
    android:orientation="vertical" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".StartActivity" > 


    <TextView 

     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/text1" 
     android:textSize="45sp" 
     android:layout_gravity="center" 
     android:gravity="center" 
     android:id="@+id/tvDisplay" 
     /> 

    <Button 
     android:id="@+id/bSub" 
     android:layout_width="250sp" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:text="@string/button2" 
     android:textSize="20sp" /> 

    <Button 
     android:id="@+id/bAdd" 
     android:layout_width="250sp" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tvDisplay" 
     android:layout_below="@+id/tvDisplay" 
     android:layout_marginTop="30dp" 
     android:text="@string/button1" 
     android:textSize="20sp" /> 

</RelativeLayout> 

그리고 이것은 내 된 .java 파일입니다 : 내가 프로그램을 실행으로

package com.appdiprova.giovanni; 

import android.os.Bundle; 
import android.app.Activity; 
import android.view.Menu; 
import android.view.View; 
import android.widget.Button; 
import android.widget.TextView; 

public class StartActivity extends Activity { 

    int counter; 
    Button add,sub; 
    TextView display; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_start); 
     counter=0; 
     add= (Button) findViewById(R.id.bAdd); 
     sub= (Button) findViewById(R.id.bSub); 
     display = (TextView) findViewById(R.id.tvDisplay); 

     add.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 
       counter=counter+1; 
       display.setText("Your total is " + counter); 
      } 
     }); 
     sub.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 
       counter=counter-1; 
       display.setText("Your total is " + counter); 
      } 
     }); 
    } 


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

} 

나는 긴 목록 로그 캣 얻을 오류 중 첫 번째는 치명적 예외 주를 나에게 알려줍니다.

나는이 문제를 어떻게 해결할 수 있습니까? 당신에게 대단히 감사합니다

편집 미안 해요, 나 또한 매니페스트와 로그 캣

적하 목록을 게시합니다

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

    <uses-sdk 
     android:minSdkVersion="15" 
     android:targetSdkVersion="19" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="com.appdiprova.giovanni.StartActivity" 
      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> 

좋아 지금부터 상당히 혼란 스러워요 나는 더 이상 치명적인 오류를 얻지 않지만, 여전히 많은 오류가 있습니다 :

11-15 08:39:35.410: E/SoundPool(370): error loading /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:35.410: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:35.420: E/SoundPool(370): error loading /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:35.420: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:35.420: E/SoundPool(370): error loading /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:35.420: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:35.420: E/SoundPool(370): error loading /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:35.420: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:35.430: E/SoundPool(370): error loading /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:35.430: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:35.430: E/SoundPool(370): error loading /system/media/audio/ui/KeypressStandard.ogg 
11-15 08:39:35.430: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg 
11-15 08:39:35.450: E/SoundPool(370): error loading /system/media/audio/ui/KeypressSpacebar.ogg 
11-15 08:39:35.450: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg 
11-15 08:39:35.450: E/SoundPool(370): error loading /system/media/audio/ui/KeypressDelete.ogg 
11-15 08:39:35.450: I/ActivityManager(370): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.appdiprova.giovanni/.StartActivity} from pid 546 
11-15 08:39:35.460: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg 
11-15 08:39:35.460: E/SoundPool(370): error loading /system/media/audio/ui/KeypressReturn.ogg 
11-15 08:39:35.470: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg 
11-15 08:39:35.470: E/SoundPool(370): error loading /system/media/audio/ui/KeypressInvalid.ogg 
11-15 08:39:35.470: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg 
11-15 08:39:35.470: W/AudioService(370): onLoadSoundEffects(), Error -1 while loading samples 
11-15 08:39:35.560: E/gralloc_goldfish(50): gralloc_alloc: Mismatched usage flags: 246 x 410, usage 333 
11-15 08:39:35.560: W/GraphicBufferAllocator(50): alloc(246, 410, 1, 00000333, ...) failed -22 (Invalid argument) 
11-15 08:39:35.560: E/(50): GraphicBufferAlloc::createGraphicBuffer(w=246, h=410) failed (Invalid argument), handle=0x0 
11-15 08:39:35.560: E/BufferQueue(370): [ScreenshotClient] dequeueBuffer: SurfaceComposer::createGraphicBuffer failed 
11-15 08:39:35.570: W/WindowManager(370): Screenshot failure taking screenshot for (246x410) to layer 21005 
11-15 08:39:35.780: D/LightsService(370): Excessive delay setting light: 392ms 
11-15 08:39:35.850: D/dalvikvm(924): Not late-enabling CheckJNI (already on) 
11-15 08:39:35.870: I/ActivityManager(370): Start proc com.appdiprova.giovanni for activity com.appdiprova.giovanni/.StartActivity: pid=924 uid=10051 gids={50051} 
11-15 08:39:36.610: D/AndroidRuntime(924): Shutting down VM 
11-15 08:39:36.610: W/dalvikvm(924): threadid=1: thread exiting with uncaught exception (group=0xb3ad1b90) 
11-15 08:39:36.630: E/AndroidRuntime(924): FATAL EXCEPTION: main 
11-15 08:39:36.630: E/AndroidRuntime(924): Process: com.appdiprova.giovanni, PID: 924 
11-15 08:39:36.630: E/AndroidRuntime(924): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.appdiprova.giovanni/com.appdiprova.giovanni.StartActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.app.ActivityThread.access$700(ActivityThread.java:135) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.os.Handler.dispatchMessage(Handler.java:102) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.os.Looper.loop(Looper.java:137) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.app.ActivityThread.main(ActivityThread.java:4998) 
11-15 08:39:36.630: E/AndroidRuntime(924): at java.lang.reflect.Method.invokeNative(Native Method) 
11-15 08:39:36.630: E/AndroidRuntime(924): at java.lang.reflect.Method.invoke(Method.java:515) 
11-15 08:39:36.630: E/AndroidRuntime(924): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 
11-15 08:39:36.630: E/AndroidRuntime(924): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 
11-15 08:39:36.630: E/AndroidRuntime(924): at dalvik.system.NativeStart.main(Native Method) 
11-15 08:39:36.630: E/AndroidRuntime(924): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.view.LayoutInflater.createView(LayoutInflater.java:620) 
11-15 08:39:36.630: E/AndroidRuntime(924): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.view.LayoutInflater.inflate(LayoutInflater.java:469) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
11-15 08:39:36.630: E/AndroidRuntime(924): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.app.Activity.setContentView(Activity.java:1928) 
11-15 08:39:36.630: E/AndroidRuntime(924): at com.appdiprova.giovanni.StartActivity.onCreate(StartActivity.java:20) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.app.Activity.performCreate(Activity.java:5243) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140) 
11-15 08:39:36.630: E/AndroidRuntime(924): ... 11 more 
11-15 08:39:36.630: E/AndroidRuntime(924): Caused by: java.lang.reflect.InvocationTargetException 
11-15 08:39:36.630: E/AndroidRuntime(924): at java.lang.reflect.Constructor.constructNative(Native Method) 
11-15 08:39:36.630: E/AndroidRuntime(924): at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
11-15 08:39:36.630: E/AndroidRuntime(924): ... 23 more 
11-15 08:39:36.630: E/AndroidRuntime(924): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060001 a=-1 r=0x7f060001} 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.content.res.Resources.loadDrawable(Resources.java:2068) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.content.res.TypedArray.getDrawable(TypedArray.java:602) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.view.View.<init>(View.java:3545) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.view.View.<init>(View.java:3475) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.view.ViewGroup.<init>(ViewGroup.java:464) 
11-15 08:39:36.630: E/AndroidRuntime(924): at android.widget.RelativeLayout.<init>(RelativeLayout.java:236) 
11-15 08:39:36.630: E/AndroidRuntime(924): ... 26 more 
11-15 08:39:36.650: W/ActivityManager(370): Force finishing activity com.appdiprova.giovanni/.StartActivity 
11-15 08:39:37.050: I/WindowManager(370): Screenshot max retries 4 of Token{b40edef0 ActivityRecord{b40edd90 u0 com.appdiprova.giovanni/.StartActivity t3 f}} appWin=Window{b41b27f0 u0 Starting com.appdiprova.giovanni} drawState=4 
11-15 08:39:37.050: W/WindowManager(370): Screenshot failure taking screenshot for (480x800) to layer 21010 
11-15 08:39:37.560: W/ActivityManager(370): Activity pause timeout for ActivityRecord{b40edd90 u0 com.appdiprova.giovanni/.StartActivity t3 f} 
11-15 08:39:37.900: W/EGL_emulation(546): eglSurfaceAttrib not implemented 
11-15 08:39:38.640: E/SoundPool(370): error loading /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:38.640: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:38.640: E/SoundPool(370): error loading /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:38.640: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:38.640: E/SoundPool(370): error loading /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:38.650: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:38.650: E/SoundPool(370): error loading /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:38.650: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:38.650: E/SoundPool(370): error loading /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:38.650: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg 
11-15 08:39:38.680: E/SoundPool(370): error loading /system/media/audio/ui/KeypressStandard.ogg 
11-15 08:39:38.680: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg 
11-15 08:39:38.710: E/SoundPool(370): error loading /system/media/audio/ui/KeypressSpacebar.ogg 
11-15 08:39:38.710: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg 
11-15 08:39:38.720: E/SoundPool(370): error loading /system/media/audio/ui/KeypressDelete.ogg 
11-15 08:39:38.720: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg 
11-15 08:39:38.720: E/SoundPool(370): error loading /system/media/audio/ui/KeypressReturn.ogg 
11-15 08:39:38.720: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg 
11-15 08:39:38.730: E/SoundPool(370): error loading /system/media/audio/ui/KeypressInvalid.ogg 
11-15 08:39:38.730: W/AudioService(370): Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg 
11-15 08:39:38.730: W/AudioService(370): onLoadSoundEffects(), Error -1 while loading samples 
11-15 08:39:38.800: I/Process(924): Sending signal. PID: 924 SIG: 9 
11-15 08:39:38.800: W/InputMethodManagerService(370): Window already focused, ignoring focus gain of: [email protected] attribute=null, token = [email protected] 
11-15 08:39:38.830: I/ActivityManager(370): Process com.appdiprova.giovanni (pid 924) has died. 
11-15 08:39:42.300: D/MobileDataStateTracker(370): default: setPolicyDataEnable(enabled=true) 
11-15 08:39:43.530: E/NetdConnector(370): NDC Command {47 bandwidth setiquota eth0 9223372036854775807} took too long (782ms) 
+2

LogCat을 게시 할 수 있습니까? –

+0

이 코드는 순서에있는 것 같습니다. Manifest XML에서 활동을 선언 했습니까? – wvdz

+0

Logcat은 일이 왜 작동하지 않는지에 대한 아주 좋은 설명을 제공합니다. 따라서 FATAL EXCEPTION을 계속 읽으면 그 이유를 알 수 있습니다. 코드가 보이기 때문에 매니페스트에서 활동을 선언하지 않았다고 추측합니다 앞서 말한대로 순서대로 –

답변

1

나는 문제가 당신의 RelativeLayoutandroid:background 속성입니다 생각 :

android:background="@style/AppTheme" 

안드로이드 시스템은 background 자원이 Drawable 아니라 스타일이 될 것으로 기대하고 당신

Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060001 a=-1 r=0x7f060001} 

에게 알려줍니다. 스타일을 설정하거나 android:backgroundDrawable가 배경으로 사용되는 설정 style를 사용

style="@style/AppTheme" 

업데이트 :the docs about android:background에서 :

당김이 배경으로 사용하기. 전체 드로어 블 리소스 (PNG 이미지, 9 패치, XML 상태 목록 설명 등) 또는 "#ff000000"(검정색)과 같은 단색 중 하나 일 수 있습니다.

Android developer guide에서 스타일 및 테마에 대해 자세히 읽을 수 있습니다.

+0

대단히 고맙습니다. 지금은 조금 나빠 보이지만 문제가 해결되었습니다! 내가 튜토리얼을 따라했기 때문에 나는 혼란 스러웠다. 그리고 그 사람의 프로그램은 아무런 문제없이 일했다. –

+0

@ user2992124 도와 줘서 기뻐요! 그것이 당신을 도운다면 대답을 수락하십시오 :) –

관련 문제