0
votes

I have had issues with this simple app that are causing a force close on the device. I am very new to android and just messing around with some views. I have tried going through the forums, but I have been unable to find a solution. Any help would be much appreciated. I have included the log info.

I apologize for the weird formatting, however I could not post this without adding paragraphs of more details to my question because I have too much code

XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical"
    >

    <ImageView
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:id="@+id/rainbowbackground"
        android:src="@drawable/rainbow"
        android:scaleType="fitXY"

        />

    <ImageView
        android:id="@+id/trollface"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/trollface" />


    <TextView
        android:background="#3f51b5"
        android:padding="16dp"
        android:fontFamily="sans-serif-light"
        android:textColor="@android:color/white"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="Smile, Sebastian!"
        android:textStyle="bold"
        android:textSize="25sp"
        android:id="@+id/textview_1"
        />


    <TextView
        android:background="@android:color/black"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:padding="16dp"
        android:fontFamily="sans-serif-light"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textview_2"
        android:textSize="25sp"
        android:text="It's Your Birthday!"
        />


</RelativeLayout>

MainActivity.java

package com.example.android.happbirthdaysebastian;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

Errors

W/ApplicationPackageManager: getCSCPackageItemText() I/dalvikvm: Could not find method android.view.Window$Callback.onPointerCaptureChanged, referenced from method android.support.v7.view.WindowCallbackWrapper.onPointerCaptureChanged W/dalvikvm: VFY: unable to resolve interface method 15988: Landroid/view/Window$Callback;.onPointerCaptureChanged (Z)V D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 I/dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts W/dalvikvm: VFY: unable to resolve interface method 15990: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;) I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested W/dalvikvm: VFY: unable to resolve interface method 15992: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode W/dalvikvm: VFY: unable to resolve interface method 15996: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode; D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations W/dalvikvm: VFY: unable to resolve virtual method 704: Landroid/content/res/TypedArray;.getChangingConfigurations ()I D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002 I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType W/dalvikvm: VFY: unable to resolve virtual method 726: Landroid/content/res/TypedArray;.getType (I)I D/dalvikvm: VFY: replacing opcode 0x6e at 0x0008 I/dalvikvm: Could not find method android.content.Context.createDeviceProtectedStorageContext, referenced from method android.support.v4.content.ContextCompat.createDeviceProtectedStorageContext W/dalvikvm: VFY: unable to resolve virtual method 485: Landroid/content/Context;.createDeviceProtectedStorageContext ()Landroid/content/Context; D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 I/dalvikvm: Could not find method android.content.Context.getCodeCacheDir, referenced from method android.support.v4.content.ContextCompat.getCodeCacheDir W/dalvikvm: VFY: unable to resolve virtual method 491: Landroid/content/Context;.getCodeCacheDir ()Ljava/io/File; D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 I/dalvikvm: Could not find method android.content.Context.getColor, referenced from method android.support.v4.content.ContextCompat.getColor W/dalvikvm: VFY: unable to resolve virtual method 492: Landroid/content/Context;.getColor (I)I D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v4.content.ContextCompat.getColorStateList W/dalvikvm: VFY: unable to resolve virtual method 493: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList; D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 I/dalvikvm: Could not find method android.content.Context.getDataDir, referenced from method android.support.v4.content.ContextCompat.getDataDir W/dalvikvm: VFY: unable to resolve virtual method 495: Landroid/content/Context;.getDataDir ()Ljava/io/File; D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 I/dalvikvm: Could not find method android.content.Context.getDrawable, referenced from method android.support.v4.content.ContextCompat.getDrawable W/dalvikvm: VFY: unable to resolve virtual method 496: Landroid/content/Context;.getDrawable (I)Landroid/graphics/drawable/Drawable; D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 I/dalvikvm: Could not find method android.content.Context.getNoBackupFilesDir, referenced from method android.support.v4.content.ContextCompat.getNoBackupFilesDir W/dalvikvm: VFY: unable to resolve virtual method 503: Landroid/content/Context;.getNoBackupFilesDir ()Ljava/io/File; D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 I/dalvikvm: Could not find method android.content.Context.isDeviceProtectedStorage, referenced from method android.support.v4.content.ContextCompat.isDeviceProtectedStorage W/dalvikvm: VFY: unable to resolve virtual method 516: Landroid/content/Context;.isDeviceProtectedStorage ()Z D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 I/dalvikvm: Could not find method android.content.Context.startForegroundService, referenced from method android.support.v4.content.ContextCompat.startForegroundService W/dalvikvm: VFY: unable to resolve virtual method 531: Landroid/content/Context;.startForegroundService (Landroid/content/Intent;)Landroid/content/ComponentName; D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 I/dalvikvm: Could not find method android.widget.FrameLayout.startActionModeForChild, referenced from method android.support.v7.widget.ActionBarContainer.startActionModeForChild W/dalvikvm: VFY: unable to resolve virtual method 16457: Landroid/widget/FrameLayout;.startActionModeForChild (Landroid/view/View;Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode; D/dalvikvm: VFY: replacing opcode 0x6f at 0x0002 I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v7.content.res.AppCompatResources.getColorStateList W/dalvikvm: VFY: unable to resolve virtual method 493: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList; D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006 W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/graphics/drawable/Icon;) I/dalvikvm: Could not find method android.widget.ImageButton.setImageIcon, referenced from method android.support.v7.widget.AppCompatImageButton.setImageIcon W/dalvikvm: VFY: unable to resolve virtual method 16480: Landroid/widget/ImageButton;.setImageIcon (Landroid/graphics/drawable/Icon;)V D/dalvikvm: VFY: replacing opcode 0x6f at 0x0000 I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable W/dalvikvm: VFY: unable to resolve virtual method 667: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable; D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002 I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity W/dalvikvm: VFY: unable to resolve virtual method 669: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable; D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002 E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering W/dalvikvm: VFY: unable to resolve instanceof 193 (Landroid/graphics/drawable/RippleDrawable;) in Landroid/support/v7/widget/AppCompatImageHelper; D/dalvikvm: VFY: replacing opcode 0x20 at 0x000c I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeMaxTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMaxTextSize W/dalvikvm: VFY: unable to resolve virtual method 16776: Landroid/widget/TextView;.getAutoSizeMaxTextSize ()I D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeMinTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMinTextSize W/dalvikvm: VFY: unable to resolve virtual method 16777: Landroid/widget/TextView;.getAutoSizeMinTextSize ()I D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeStepGranularity W/dalvikvm: VFY: unable to resolve virtual method 16778: Landroid/widget/TextView;.getAutoSizeStepGranularity ()I D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextAvailableSizes, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextAvailableSizes W/dalvikvm: VFY: unable to resolve virtual method 16779: Landroid/widget/TextView;.getAutoSizeTextAvailableSizes ()[I D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextType, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextType W/dalvikvm: VFY: unable to resolve virtual method 16780: Landroid/widget/TextView;.getAutoSizeTextType ()I D/dalvikvm: VFY: replacing opcode 0x6f at 0x0008 I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithConfiguration, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithConfiguration W/dalvikvm: VFY: unable to resolve virtual method 16823: Landroid/widget/TextView;.setAutoSizeTextTypeUniformWithConfiguration (IIII)V D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithPresetSizes, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithPresetSizes W/dalvikvm: VFY: unable to resolve virtual method 16824: Landroid/widget/TextView;.setAutoSizeTextTypeUniformWithPresetSizes ([II)V D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeWithDefaults, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeWithDefaults W/dalvikvm: VFY: unable to resolve virtual method 16825: Landroid/widget/TextView;.setAutoSizeTextTypeWithDefaults (I)V D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006 I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextHelper.loadFromAttributes W/dalvikvm: VFY: unable to resolve virtual method 16778: Landroid/widget/TextView;.getAutoSizeStepGranularity ()I D/dalvikvm: VFY: replacing opcode 0x6e at 0x0197 I/dalvikvm: Could not find method android.text.StaticLayout$Builder.obtain, referenced from method android.support.v7.widget.AppCompatTextViewAutoSizeHelper.createStaticLayoutForMeasuring W/dalvikvm: VFY: unable to resolve static method 15266: Landroid/text/StaticLayout$Builder;.obtain (Ljava/lang/CharSequence;IILandroid/text/TextPaint;I)Landroid/text/StaticLayout$Builder; D/dalvikvm: VFY: replacing opcode 0x71 at 0x0014 W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/graphics/drawable/Icon;) I/dalvikvm: Could not find method android.widget.ImageView.setImageIcon, referenced from method android.support.v7.widget.AppCompatImageView.setImageIcon W/dalvikvm: VFY: unable to resolve virtual method 16515: Landroid/widget/ImageView;.setImageIcon (Landroid/graphics/drawable/Icon;)V D/dalvikvm: VFY: replacing opcode 0x6f at 0x0000 W/ResourceType: Failure getting entry for 0x7f060062 (t=5 e=98) in package 0 (error -75) W/ResourceType: Failure getting entry for 0x7f060062 (t=5 e=98) in package 0 (error -75) D/AndroidRuntime: Shutting down VM W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41748da0) E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.android.happbirthdaysebastian, PID: 30078 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.happbirthdaysebastian/com.example.android.happbirthdaysebastian.MainActivity}: android.view.InflateException: Binary XML file line #0: Error inflating class ImageView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363) at android.app.ActivityThread.access$900(ActivityThread.java:161) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5356) 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:1265) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class ImageView at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719) at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) at android.view.LayoutInflater.inflate(LayoutInflater.java:498) at android.view.LayoutInflater.inflate(LayoutInflater.java:398) at android.view.LayoutInflater.inflate(LayoutInflater.java:354) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.example.android.happbirthdaysebastian.MainActivity.onCreate(MainActivity.java:11) at android.app.Activity.performCreate(Activity.java:5426) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)  at android.app.ActivityThread.access$900(ActivityThread.java:161)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:157)  at android.app.ActivityThread.main(ActivityThread.java:5356)  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:1265)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)  at dalvik.system.NativeStart.main(Native Method)  Caused by: android.content.res.Resources$NotFoundException: Resource ID

0x7f060062

                  at android.content.res.Resources.getValue(Resources.java:2009)
                  at android.support.v7.widget.ResourcesWrapper.getValue(ResourcesWrapper.java:208)
                  at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:330)
                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195)
                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
                  at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
                  at android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:58)
                  at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:78)
                  at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
                  at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
                  at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024)
                  at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
                  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
                  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                  at com.example.android.happbirthdaysebastian.MainActivity.onCreate(MainActivity.java:11) 
                  at android.app.Activity.performCreate(Activity.java:5426) 
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269) 
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363) 
                  at android.app.ActivityThread.access$900(ActivityThread.java:161) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265) 
                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                  at android.os.Looper.loop(Looper.java:157) 
                  at android.app.ActivityThread.main(ActivityThread.java:5356) 
                  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:1265) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 
                  at dalvik.system.NativeStart.main(Native Method)
3
What are the drawable trollface and rainbow?realdm
@realdm the trollface is a transparent png while the rainbow is a jpegCodySDEV

3 Answers

1
votes

Logcat shows two lines that could give a clue of what is wrong:

  1. android.view.InflateException: Binary XML file line #0: Error inflating class ImageView

  2. android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path)

So it seems something's wrong with either @drawable/rainbow and/or @drawable/trollface. Are those pictures (jpg, png)? Are they located in drawable folder? Do the names match? If everything is OK, you should be able to see them in your layout designer. You could also try to copy some other pictures to the drawable folder and try to reference those from your XML.

0
votes

The code looks okey. you can try to modify your xml and see if it works. On top include the following line:

xmlns:app="http://schemas.android.com/apk/res-auto"

And then, when including a drawablable, modify your code like in the following example:

app:srcCompat="@drawable/trollface"
0
votes

Ok. So apparently I had both images in the drawable-v24 folder. After moving both images to the drawable, everything worked fine. I'm not sure why this made a difference though.