Issue
I'd just started learning to write Android Studio apps so please pardon the noob question.
I'm using the book Android App Development for Dummies and trying to follow it to create the Silent Mode Toggle App.
In the book, it says that upon dragging an image into the src/main/res/drawable xxhdpi folder in AS (in AS 3.2.1, I believe should be src/main/res/mipmap-xxhdpi), "..., it regenerates the build/generated folder, and the R.java file is updated to include a reference to the two new images you added". However, mine doesn't seem to. And when I typed the "android:src="@" part, I don't see the resource "ringer_on" in the dropdown list.
(without the android:id & android:src line, there is no error)
I tried to clean project and rebuild but it shows me the below error:
Android resource linking failed
Output: C:\Users\xxx\AndroidStudioProjects\SilentModeToggle\app\src\main\res\layout\activity_main.xml:7: error: resource drawable/ringer_on (aka com.dummies.silentmodetoggle:drawable/drawable/ringer_on) not found. error: failed linking file resources.
In the book, it says to create the silenttoggle app as a module within the helloworld project. So I tried to create the silenttoggle app as a new project and it's still the same error.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/phone_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ringer_on"/>
</FrameLayout>
Also, I can't seem to find the r.java file anywhere.
My screen is as below: enter image description here
Please help :( Thanks!
Solution
Your drawable is in mipmap folder and not drawable try @mipmap/ringer_on in place of "@drawable/ringer_on". change and it will work.
Answered By - karan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.