当我尝试运行我的应用程序时,它表明应用程序已停止运行,我认为问题是在手机更新后开始的。我想那是从那以后开始的。
我的代码:
package com.example.android.courtcounter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.example.android.courtcounter.R;
public class MainActivity extends AppCompatActivity {
int score;
/**
* Displays the given score for Team A.
*/
public void displayForTeamA(int score) {
TextView scoreView = (TextView) findViewById(R.id.team_a_score);
scoreView.setText(String.valueOf(score));
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
displayForTeamA(1);
}
public void scoreThree(View view){
score=score+3;
display(score);
}
public void scoreTwo(View view){
score=score+2;
display(score);
}
public void scoreFreeThrow(View view){
score=score+1;
display(score);
}
public void display (int number){
TextView countViewer = (TextView)findViewById(R.id.team_a_score);
countViewer.setText(""+ number);
}
}
执行时导致以下错误:
07/19 00:37:18: Launching app
$ adb install-multiple -r -t C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\split-apk\debug\slices\slice_1.apk C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\split-apk\debug\dep\dependencies.apk C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\split-apk\debug\slices\slice_2.apk C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\split-apk\debug\slices\slice_5.apk C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\split-apk\debug\slices\slice_8.apk C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\split-apk\debug\slices\slice_7.apk C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\split-apk\debug\slices\slice_6.apk C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\split-apk\debug\slices\slice_9.apk C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\split-apk\debug\slices\slice_4.apk C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\split-apk\debug\slices\slice_3.apk C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\split-apk\debug\slices\slice_0.apk C:\Users\harish\AndroidStudioProjects\CourtCounter\app\build\intermediates\instant-run-apk\debug\app-debug.apk
Split APKs installed
$ adb shell am start -n "com.example.android.courtcounter/com.example.android.courtcounter.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Connected to process 25781 on device samsung-sm_g610f-520355065199144d
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/InstantRun: starting instant run server: is main process
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.courtcounter, PID: 25781
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.courtcounter/com.example.android.courtcounter.MainActivity}: android.view.InflateException: Binary XML file line #25: Binary XML file line #25: Error inflating class Buttonview
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: android.view.InflateException: Binary XML file line #25: Binary XML file line #25: Error inflating class Buttonview
Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class Buttonview
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.Buttonview" on path: DexPathList[[zip file "/data/app/com.example.android.courtcounter-2/base.apk", zip file "/data/app/com.example.android.courtcounter-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.android.courtcounter-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.android.courtcounter-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.android.courtcounter-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.android.courtcounter-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.android.courtcounter-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.android.courtcounter-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.android.courtcounter-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.android.courtcounter-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.android.courtcounter-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.android.courtcounter-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.android.courtcounter-2/lib/arm, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:616)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:707)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:724)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:792)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:286)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.android.courtcounter.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6956)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Application terminated.