Android Developing Error Help

Endrit Shabani

New member
Apr 21, 2017
1
0
0
I am a beginner in android development I am following courses in Udacity but I am following everything and my code seems right but when I run the application and after I click on the button the app stops working here is my code and the error
MainActivity.java
package com.example.endrit.justjava;

import android.icu.text.NumberFormat;
import android.os.Build;
import android.os.Bundle;

import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

@override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

@RequiresApi(api = Build.VERSION_CODES.N)
public void submitOrder(View view) {

display(2);
displayPrice(2*5);
}

private void display(int number) {

TextView quantityTextView = (TextView) findViewById(R.id.quantity);

quantityTextView.setText("" + number);

}

@RequiresApi(api = Build.VERSION_CODES.N)
private void displayPrice(int number) {

TextView priceTextView = (TextView) findViewById(R.id.price);

priceTextView.setText(NumberFormat.getCurrencyInstance().format(number));

}

}
activity_main.xml
<LinearLayout
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"
android:padding="16dp"
android:orientation="vertical"
tools:context="com.example.endrit.justjava.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Quantity"
android:layout_marginLeft="4dp"
android:textAllCaps="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/quantity"
android:text="0"
android:layout_marginLeft="4dp"
android:textSize="16sp"
android:textColor="@android:color/black"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Price"
android:layout_marginTop="16dp"
android:layout_marginLeft="4dp"
android:textSize="16sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$0"
android:layout_marginLeft="4dp"
android:layout_marginTop="16dp"
android:textSize="16sp"
android:textColor="@android:color/black"
android:id="@+id/price"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Order"
android:layout_marginTop="16dp"
android:onClick="submitOrder"/>

</LinearLayout>

Logcat
04-21 21:10:13.465 11045-11045/? I/SELinux: Function: selinux_android_load_priority [0], There is no sepolicy file.

04-21 21:10:13.465 11045-11045/? I/SELinux: Function: selinux_android_load_priority [1], There is no sepolicy version file.

04-21 21:10:13.465 11045-11045/? I/SELinux: Function: selinux_android_load_priority , priority version is VE=SEPF_GT-I9301I_4.4.2_0043


04-21 21:10:13.465 11045-11045/? I/SELinux: selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts
04-21 21:10:13.485 11045-11045/? D/dalvikvm: Late-enabling CheckJNI
04-21 21:10:13.715 11045-11045/com.example.endrit.justjava I/dalvikvm: Could not find method android.icu.text.NumberFormat.getCurrencyInstance, referenced from method com.example.endrit.justjava.MainActivity.displayPrice
04-21 21:10:13.715 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to resolve static method 803: Landroid/icu/text/NumberFormat;.getCurrencyInstance ()Landroid/icu/text/NumberFormat;
04-21 21:10:13.715 11045-11045/com.example.endrit.justjava D/dalvikvm: VFY: replacing opcode 0x71 at 0x0009
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava I/dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to resolve interface method 17000: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to resolve interface method 17002: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to resolve interface method 17006: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to resolve virtual method 461: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
04-21 21:10:13.735 11045-11045/com.example.endrit.justjava D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-21 21:10:13.745 11045-11045/com.example.endrit.justjava I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
04-21 21:10:13.745 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to resolve virtual method 483: Landroid/content/res/TypedArray;.getType (I)I
04-21 21:10:13.745 11045-11045/com.example.endrit.justjava D/dalvikvm: VFY: replacing opcode 0x6e at 0x0008
04-21 21:10:13.795 11045-11045/com.example.endrit.justjava I/dalvikvm: Could not find method android.widget.FrameLayout.startActionModeForChild, referenced from method android.support.v7.widget.ActionBarContainer.startActionModeForChild
04-21 21:10:13.795 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to resolve virtual method 17437: Landroid/widget/FrameLayout;.startActionModeForChild (Landroid/view/View;Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
04-21 21:10:13.795 11045-11045/com.example.endrit.justjava D/dalvikvm: VFY: replacing opcode 0x6f at 0x0002
04-21 21:10:13.805 11045-11045/com.example.endrit.justjava I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v7.content.res.AppCompatResources.getColorStateList
04-21 21:10:13.805 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to resolve virtual method 275: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
04-21 21:10:13.805 11045-11045/com.example.endrit.justjava D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-21 21:10:13.815 11045-11045/com.example.endrit.justjava I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
04-21 21:10:13.815 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to resolve virtual method 424: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
04-21 21:10:13.815 11045-11045/com.example.endrit.justjava D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-21 21:10:13.815 11045-11045/com.example.endrit.justjava I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
04-21 21:10:13.815 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to resolve virtual method 426: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
04-21 21:10:13.815 11045-11045/com.example.endrit.justjava D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-21 21:10:13.825 11045-11045/com.example.endrit.justjava E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
04-21 21:10:13.825 11045-11045/com.example.endrit.justjava W/dalvikvm: VFY: unable to resolve instanceof 141 (Landroid/graphics/drawable/RippleDrawable;) in Landroid/support/v7/widget/AppCompatImageHelper;
04-21 21:10:13.825 11045-11045/com.example.endrit.justjava D/dalvikvm: VFY: replacing opcode 0x20 at 0x000c
04-21 21:10:13.935 11045-11045/com.example.endrit.justjava I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: ()
OpenGL ES Shader Compiler Version: E031.24.00.07
Build Date: 01/27/14 Mon
Local Branch: base_au149_adreno_au169_patches
Remote Branch:
Local Patches:
Reconstruct Branch:
04-21 21:10:13.985 11045-11045/com.example.endrit.justjava D/OpenGLRenderer: Enabling debug mode 0
04-21 21:10:22.125 11045-11045/com.example.endrit.justjava D/AndroidRuntime: Shutting down VM
04-21 21:10:22.125 11045-11045/com.example.endrit.justjava W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x416edda0)
04-21 21:10:22.135 11045-11045/com.example.endrit.justjava E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.endrit.justjava, PID: 11045
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java:4633)
at android.view.View$PerformClick.run(View.java:19270)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5476)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:4633)*
at android.view.View$PerformClick.run(View.java:19270)*
at android.os.Handler.handleCallback(Handler.java:733)*
at android.os.Handler.dispatchMessage(Handler.java:95)*
at android.os.Looper.loop(Looper.java:136)*
at android.app.ActivityThread.main(ActivityThread.java:5476)*
at java.lang.reflect.Method.invokeNative(Native Method)*
at java.lang.reflect.Method.invoke(Method.java:515)*
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)*
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)*
at dalvik.system.NativeStart.main(Native Method)*
Caused by: java.lang.NoClassDefFoundError: android.icu.text.NumberFormat
at com.example.endrit.justjava.MainActivity.displayPrice(MainActivity.java:57)
at com.example.endrit.justjava.MainActivity.submitOrder(MainActivity.java:34)
at java.lang.reflect.Method.invokeNative(Native Method)*
at java.lang.reflect.Method.invoke(Method.java:515)*
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)*
at android.view.View.performClick(View.java:4633)*
at android.view.View$PerformClick.run(View.java:19270)*
at android.os.Handler.handleCallback(Handler.java:733)*
at android.os.Handler.dispatchMessage(Handler.java:95)*
at android.os.Looper.loop(Looper.java:136)*
at android.app.ActivityThread.main(ActivityThread.java:5476)*
at java.lang.reflect.Method.invokeNative(Native Method)*
at java.lang.reflect.Method.invoke(Method.java:515)*
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)*
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)*
at dalvik.system.NativeStart.main(Native Method)*
04-21 21:10:24.555 11045-11045/? I/Process: Sending signal. PID: 11045 SIG: 9
 
Moved from the Android Apps forum to the Software Development forum.