.apk 不会安装在 AVD 上。清单不更新?

.apk will not install on AVD. Manifest not updating?

所以我构建了这个简单的应用程序作为自学的一部分 android class 我正在学习。在我对 Java 文件进行一些更改然后尝试重新安装并再次启动之前,它一直运行良好。从我所做的研究来看,我认为这与清单有关,但我不确定哪里出了问题。如果您需要查看其他任何内容,请询问。我真的很难过这个。在我添加 switch 语句之前它一直在工作。它曾经是一个 if else 集群,我被告知尝试使用 switch statement 来完成它。它似乎在日食中检查出来,但我就是想不通。这是 logcat 输出。

01-22 07:43:12.106: E/libprocessgroup(1717): failed to make and chown /acct/uid_10054: Read-only file system 01-22 07:43:12.106: W/Zygote(1717): createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT? 01-22 07:43:12.107: I/art(1717): Not late-enabling -Xcheck:jni (already on) 01-22 07:43:12.192: D/AndroidRuntime(1717): Shutting down VM 01-22 07:43:12.192: D/AndroidRuntime(1717): --------- beginning of crash 01-22 07:43:12.193: E/AndroidRuntime(1717): FATAL EXCEPTION: main 01-22 07:43:12.193: E/AndroidRuntime(1717): Process: com.codeherenow.trafficlights, PID: 1717 01-22 07:43:12.193: E/AndroidRuntime(1717): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.codeherenow.trafficlights/com.codeherenow.trafficlights.TrafficLightsActivity}: java.lang.InstantiationException: class com.codeherenow.trafficlights.TrafficLightsActivity cannot be instantiated 01-22 07:43:12.193: E/AndroidRuntime(1717): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209) 01-22 07:43:12.193: E/AndroidRuntime(1717): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 01-22 07:43:12.193: E/AndroidRuntime(1717): at android.app.ActivityThread.access0(ActivityThread.java:144) 01-22 07:43:12.193: E/AndroidRuntime(1717): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 01-22 07:43:12.193: E/AndroidRuntime(1717): at android.os.Handler.dispatchMessage(Handler.java:102) 01-22 07:43:12.193: E/AndroidRuntime(1717): at android.os.Looper.loop(Looper.java:135) 01-22 07:43:12.193: E/AndroidRuntime(1717): at android.app.ActivityThread.main(ActivityThread.java:5221) 01-22 07:43:12.193: E/AndroidRuntime(1717): at java.lang.reflect.Method.invoke(Native Method) 01-22 07:43:12.193: E/AndroidRuntime(1717): at java.lang.reflect.Method.invoke(Method.java:372) 01-22 07:43:12.193: E/AndroidRuntime(1717): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 01-22 07:43:12.193: E/AndroidRuntime(1717): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 01-22 07:43:12.193: E/AndroidRuntime(1717): Caused by: java.lang.InstantiationException: class com.codeherenow.trafficlights.TrafficLightsActivity cannot be instantiated 01-22 07:43:12.193: E/AndroidRuntime(1717): at java.lang.Class.newInstance(Class.java:1553) 01-22 07:43:12.193: E/AndroidRuntime(1717): at android.app.Instrumentation.newActivity(Instrumentation.java:1065) 01-22 07:43:12.193: E/AndroidRuntime(1717): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199) 01-22 07:43:12.193: E/AndroidRuntime(1717): ... 10 more 01-22 07:48:13.660: I/Process(1717): Sending signal. PID: 1717 SIG: 9

这是清单:

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

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

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name="com.codeherenow.trafficlights.TrafficLightsActivity"
            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>

这是java:

package com.codeherenow.trafficlights;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public abstract class TrafficLightsActivity extends Activity implements OnClickListener {

        private ImageView redLight;
        private ImageView yellowLight;
        private ImageView greenLight;

        private Button redButton;
        private Button yellowButton;
        private Button greenButton;



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

        redLight=(ImageView) findViewById(R.id.red_light);
        yellowLight=(ImageView) findViewById(R.id.yellow_light);
        greenLight=(ImageView) findViewById(R.id.green_light);


        redButton=(Button) findViewById(R.id.Red_Button);
        yellowButton=(Button) findViewById(R.id.Yellow_Button);
        greenButton=(Button) findViewById(R.id.Green_Button);


        redButton.setOnClickListener(this);
        yellowButton.setOnClickListener(this);
        greenButton.setOnClickListener(this);
        redLight.setOnClickListener(this);
        yellowLight.setOnClickListener(this);
        greenLight.setOnClickListener(this);


    }



    public void onClick (View v) {
        int v2=v.getId();
         turnOffLight();

        // TODO Auto-generated method stub
        switch(v2){
        case R.id.Red_Button:case R.id.red_light:
            turnOnRedLight();
            break;

        case R.id.Yellow_Button: case R.id.yellow_light:
            turnOnYellowLight();
            break;

        case R.id.Green_Button: case R.id.green_light:
            turnOnGreenLight();
            break;

            default:
            break;


        }

    }



    private void turnOffLight() {
        // TODO Auto-generated method stub
        redLight.setImageResource(R.drawable.light_off);
        greenLight.setImageResource(R.drawable.light_off);
        yellowLight.setImageResource(R.drawable.light_off);
    }





    private void turnOnGreenLight() {
        // TODO Auto-generated method stub
        greenLight.setImageResource(R.drawable.green_on);
    }



    private void turnOnYellowLight() {
        // TODO Auto-generated method stub
        yellowLight.setImageResource(R.drawable.yellow_on);
    }



    private void turnOnRedLight() {
        // TODO Auto-generated method stub
        redLight.setImageResource(R.drawable.red_on);
    }

}
public abstract class TrafficLightsActivity

而你的错误是 Caused by: java.lang.InstantiationException:..

解决方案是

public class TrafficLightsActivity