Cykl życia aplikacji - nieznany błąd

0

Program do symulacji cyklu życia aplikacji kompiluje się, ale gdy wrzucam do AVD wyskakuje "unfortunately app has stopped android", a na fonie "wystąpił problem podczas parsowania pakietu". Wszelkie: minimum SDK itd. mam dobrze. Ktoś ma pomysł czemu to nie działa?

 package com.example.xyz.test;


import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.content.Intent;
import android.text.format.DateFormat;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;




public class MainActivity extends AppCompatActivity {

   private Button PrzyciskNastepnaAktywnosc;
    private TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tv = (TextView) findViewById(R.id.textView1);
            PrzyciskNastepnaAktywnosc = (Button) findViewById(R.id.button1);
        PrzyciskNastepnaAktywnosc.setOnClickListener(new OnClickListener()
        {public void onClick(View v) {

            Intent startAnotherActivity = new Intent (getApplicationContext(), NastepnaActivity.class);
            startActivity(startAnotherActivity);
        }
        });
        Komunikat ("MainActivity onCreate");
        }

            private void Komunikat (String komunikat){
            SimpleDateFormat formatczasu = new SimpleDateFormat("H:m:s S");
            Date akt = Calendar.getInstance().getTime();
            String text = tv.getText().toString() + komunikat + " " + formatczasu.format(akt) + "\n";
            tv.setText(text);
        }
        @Override
        protected void onRestart(){
            Komunikat("MainActivity onRestart");
            super.onDestroy();
        }
        @Override
        protected void onStart(){
            Komunikat("MainActivity onStart");
            super.onDestroy();
        }
        @Override
        protected void onResume(){
            Komunikat("MainActivity onResume");
            super.onDestroy();
        }
        @Override
        protected void onPause(){
            Komunikat("MainActivity onPause");
            super.onDestroy();
        }
        @Override
        protected void onStop(){
            Komunikat("MainActivity onStop");
            super.onDestroy();
        }
        @Override
        protected void onDestroy(){
            Komunikat("MainActivity onDestroy");
            super.onDestroy();
        }
    }


 package com.example.xyz.test;

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

public class NastepnaActivity extends Activity {
    @Override
        protected void onCreate (Bundle savedInstanceState){
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_nastepny);

    }
}

<?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:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    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="com.example.xyz.test.MainActivity">

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="start!" />
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="uruchom następną Aktywnośc!" />


</RelativeLayout>
 
 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Następna aktywność!"

        />

</LinearLayout>

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest> 
0

Jeżeli pojawił Ci się taki błąd, to w LogCat pojawił się stacktrace i dodkładne informacje dlaczego. Jeżeli po nich nie rozwiążesz problemu to wrzuć tutaj to co tam wyleciało.

0

Dzisiaj kompiluję ,a tu tyle errorów.. Przykład z książki co do słowa.

 
03/07 11:40:00: Launching app
$ adb push C:\Users\Artur\AndroidStudioProjects\Praca\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.example.xyz.test
$ adb shell pm install -r "/data/local/tmp/com.example.xyz.test"
	pkg: /data/local/tmp/com.example.xyz.test
Success


$ adb shell am start -n "com.example.xyz.test/com.example.xyz.test.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Connected to process 1216 on device Nexus_4_API_16 [emulator-5554]
D/dalvikvm: Not late-enabling CheckJNI (already on)
E/Trace: error opening trace file: No such file or directory (2)
I/dalvikvm: Could not find method android.app.Application.registerOnProvideAssistDataListener, referenced from method com.android.tools.fd.runtime.BootstrapApplication.registerOnProvideAssistDataListener
W/dalvikvm: VFY: unable to resolve virtual method 240: Landroid/app/Application;.registerOnProvideAssistDataListener (Landroid/app/Application$OnProvideAssistDataListener;)V
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
I/dalvikvm: Could not find method android.app.Application.unregisterOnProvideAssistDataListener, referenced from method com.android.tools.fd.runtime.BootstrapApplication.unregisterOnProvideAssistDataListener
W/dalvikvm: VFY: unable to resolve virtual method 243: Landroid/app/Application;.unregisterOnProvideAssistDataListener (Landroid/app/Application$OnProvideAssistDataListener;)V
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
I/InstantRun: Instant Run Runtime started. Android package is com.example.xyz.test, real application class is null.
E/InstantRun: Could not find slices in APK; aborting.
W/InstantRun: No instant run dex files added to classpath
E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.monkeyPatchExistingResources
W/dalvikvm: VFY: unable to resolve check-cast 1508 (Landroid/util/ArrayMap;) in Lcom/android/tools/fd/runtime/MonkeyPatcher;
D/dalvikvm: VFY: replacing opcode 0x1f at 0x025e
E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.pruneResourceCache
W/dalvikvm: VFY: unable to resolve const-class 1508 (Landroid/util/ArrayMap;) in Lcom/android/tools/fd/runtime/MonkeyPatcher;
D/dalvikvm: VFY: replacing opcode 0x1c at 0x0060
I/dalvikvm: Could not find method android.view.ViewGroup.onRtlPropertiesChanged, referenced from method android.support.v7.widget.Toolbar.onRtlPropertiesChanged
W/dalvikvm: VFY: unable to resolve virtual method 13601: Landroid/view/ViewGroup;.onRtlPropertiesChanged (I)V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0007
I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
W/dalvikvm: VFY: unable to resolve virtual method 638: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
W/dalvikvm: VFY: unable to resolve virtual method 660: Landroid/content/res/TypedArray;.getType (I)I
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
D/AndroidRuntime: Shutting down VM
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x2bc9a300)
E/AndroidRuntime: FATAL EXCEPTION: main
                  java.lang.RuntimeException: Unable to resume activity {com.example.xyz.test/com.example.xyz.test.MainActivity}: 
java.lang.NullPointerException
                      at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2575)
                      at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2603)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2089)
                      at android.app.ActivityThread.access$600(ActivityThread.java:130)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
                      at android.os.Handler.dispatchMessage(Handler.java:99)
                      at android.os.Looper.loop(Looper.java:137)
                      at android.app.ActivityThread.main(ActivityThread.java:4745)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:511)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                      at dalvik.system.NativeStart.main(Native Method)
                   Caused by: java.lang.NullPointerException
                      at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1476)
                      at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:1965)
                      at android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:316)
                      at android.support.v7.app.AppCompatActivity.onDestroy(AppCompatActivity.java:158)
                      atcom.example.xyz.test.MainActivity.onResume(MainActivity.java:60)
                      at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1184)
                      at android.app.Activity.performResume(Activity.java:5082)
                      at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2565)
                      at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2603) 
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2089) 
                      at android.app.ActivityThread.access$600(ActivityThread.java:130) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
                      at android.os.Handler.dispatchMessage(Handler.java:99) 
                      at android.os.Looper.loop(Looper.java:137) 
                      at android.app.ActivityThread.main(ActivityThread.java:4745) 
                      at java.lang.reflect.Method.invokeNative(Native Method) 
                      at java.lang.reflect.Method.invoke(Method.java:511) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
                      at dalvik.system.NativeStart.main(Native Method) 
D/dalvikvm: GC_CONCURRENT freed 257K, 4% free 10959K/11335K, paused 27ms+9ms, total 184ms
I/Process: Sending signal. PID: 1216 SIG: 9
Application terminated.

1 użytkowników online, w tym zalogowanych: 0, gości: 1