Android 模拟器 (Nexus S) 在安装新的 AVD 后不再运行应用程序



我运行Android Studio,我在Marshmallow OS(6.0(上使用模拟器Nexus S。为了在不同的设备上尝试,我安装了带有牛轧糖操作系统的Google Pixel模拟器。它无法运行,所以我卸载了它。现在,当我使用棉花糖运行Nexus S模拟器时,我遇到了两个错误。我认为这是之前为Nougat安装文件的结果,但我不知道在哪里可以找到这些额外的文件,并且真的没有经验来解决这个问题而不会进一步搞砸。

这些错误仅出现在 MainActivity.java 中,如下所示。这是一个基本的应用程序,用于增加或减少订购的"咖啡"数量,以及计算净成本的基本数学表达式。来自 Udacity 安卓应用程序开发课程:https://classroom.udacity.com/courses/ud836

package com.example.android.justjava;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import java.text.NumberFormat;
/**
* This app displays an order form to order coffee.
*/
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/**
* This method is called when the + button is clicked.
*/
public void increment(View view) {
int quantity = 2;
quantity = 3;
display(quantity);
}
/**
* This method is called when the - button is clicked.
*/
public void decrement(View view) {
int quantity = 1;
display(quantity);
}
/**
* This method is called when the order button is clicked.
*/
public void submitView view) {
int coffeesNum = 2;
display(coffeesNum);
displayPrice(coffeesNum * 5);
}
/**
* This method displays the given price on the screen.
*/
private void displayPrice(int number) {
TextView priceTextView = (TextView) findViewById(R.id.price_text_view);
priceTextView.setText(NumberFormat.getCurrencyInstance().format(number));
}
/**
* This method displays the given quantity value on the screen.
*/
private void display(int number) {
TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
quantityTextView.setText("" + number);
}

}

第一个错误发生在第 40 行:"错误:'('预期( 第二个错误也发生在第 40 行:"错误:预期" 我知道它们都是正确的,因为我从课程中粘贴了它们。

非常感谢帮助,提前感谢。

该行public void submitView view)应该是

公开无效提交 (查看视图(

您一定错误地编辑了该文件。这就是line 40的问题所在.

最新更新