当我尝试运行我的JustJava coffe应用程序时,它会一直停止并且根本不会运行。请

时间:2018-04-25 19:11:30

标签: android android-studio

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.android.justjava.MainActivity">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />


<TextView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="Quantity"
        android:textSize="16dp"
        android:paddingLeft="16dp"
        android:paddingTop="16dp"
        android:paddingBottom="16dp"
        android:id="@+id/line1"
        />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="0"
    app:layout_constraintTop_toBottomOf="@id/line1"
    android:paddingLeft="16dp"
    android:textSize="16dp"
    android:textColor="#040D01"
    android:id="@+id/quantity_text_view"
    />

<Button
    android:id="@+id/button_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    android:paddingLeft ="16dp"
    android:text="Order"
    app:layout_constraintTop_toBottomOf="@id/quantity_text_view"
    android:onClick="submitOrder"
     />

</android.support.constraint.ConstraintLayout>

那是xml,这是java。有一次我不得不改变android:context的结尾。现在结束时说MainActivity,但它曾经说过JustJava并且产生了一个错误。请帮助:)这是来自udacity的JustJava咖啡应用程序。如果我点击日志然后显示为错误

  

04-25 12:09:51.410 26834-26834 / com.example.android.justjava E / AndroidRuntime:FATAL EXCEPTION:main
  过程:com.example.android.justjava,PID:26834
  java.lang.RuntimeException:无法实例化活动ComponentInfo {com.example.android.justjava / com.example.android.justjava.JustJava}:java.lang.ClassNotFoundException:找不到类&#34; com。 example.android.justjava.JustJava&#34; on path:DexPathList [[zip file&#34; /data/app/com.example.android.justjava-1/base.apk",
  zip文件&#34; /data/app/com.example.android.justjava-1/split_lib_dependencies_apk.apk",
  zip文件&#34; /data/app/com.example.android.justjava-1/split_lib_slice_0_apk.apk",
  zip文件&#34; /data/app/com.example.android.justjava-1/split_lib_slice_1_apk.apk",
  zip文件&#34; /data/app/com.example.android.justjava-1/split_lib_slice_2_apk.apk",
  zip文件&#34; /data/app/com.example.android.justjava-1/split_lib_slice_3_apk.apk",
  zip文件&#34; /data/app/com.example.android.justjava-1/split_lib_slice_4_apk.apk",
  zip文件&#34; /data/app/com.example.android.justjava-1/split_lib_slice_5_apk.apk",
  zip文件&#34; /data/app/com.example.android.justjava-1/split_lib_slice_6_apk.apk",
  zip文件&#34; /data/app/com.example.android.justjava-1/split_lib_slice_7_apk.apk",
  zip文件&#34; /data/app/com.example.android.justjava-1/split_lib_slice_8_apk.apk",
  zip文件&#34; /data/app/com.example.android.justjava-1/split_lib_slice_9_apk.apk"],
  nativeLibraryDirectories = [/ data / app / com.example.android.justjava-1 / lib / arm64,/ system / lib64,/ vendor / lib64]]

package com.example.android.justjava;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

/**
 * 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 order button is clicked.
     */
    public void submitOrder(View view) {
        display(1);
    }

    /**
     * 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);
    }
}

0 个答案:

没有答案