gpt4 book ai didi

java - .apk 不会安装在 AVD 上。 list 未更新?

转载 作者:太空宇宙 更新时间:2023-11-04 14:12:48 27 4
gpt4 key购买 nike

因此,我构建了这个简单的应用程序,作为我正在参加的自学 Android 类(class)的一部分。它运行良好,直到我对 Java 文件进行了一些更改,然后尝试重新安装并再次启动。根据我所做的研究,我认为这与 list 有关,但我不确定出了什么问题。如果您需要查看其他内容,请询问。我真的很难过这个。它一直在工作,直到我添加了 switch 语句。它是一个 if else 集群,我被告知尝试使用 switch 语句 来完成它。它似乎在 eclipse 中检查出来,但我就是无法弄清楚。这是 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.access$800(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

这是 list :

    <?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

您的错误是引起的:java.lang.InstantiationException:..

解决方案是

public class TrafficLightsActivity

关于java - .apk 不会安装在 AVD 上。 list 未更新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28092202/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com