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

时间:2018-06-18 13:36:28

标签: java android android-emulator avd

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

错误仅出现在MainActivity.java中,如下所示。它是一个基本的应用程序来增加或减少订购的“咖啡”的数量和计算净成本的基本数学表达式。来自Android应用程序开发的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行也出现第二个错误:“错误:预期” 我知道他们在课程中粘贴时都是正确的。

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

1 个答案:

答案 0 :(得分:0)

该行public void submitView view)应为

  

public void submit(查看视图)

您必须错误地编辑了该文件。那是line 40的错误。