Kristopher
Kristopher

Reputation: 31

Android build error not showing R content

So I just transferred my app to another laptop and when I tried to build this error prompted. please help. What do I need to change?

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  Output:  C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:651: error: <item> inner element must either be a resource reference or empty.
  C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:652: error: <item> inner element must either be a resource reference or empty.

  Command: C:\Users\Rhylle Vincent\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\f919f683d074912d6e0f1b8bf0931ab0\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
          -o \
          C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\res\merged\debug \
          C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
  Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
  Output:  C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\src\main\res\values\ids.xml:4:5-54: AAPT: error: <item> inner element must either be a resource reference or empty.

  C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\src\main\res\values\ids.xml:3:5-47: AAPT: error: <item> inner element must either be a resource reference or empty.

  Command: C:\Users\Rhylle Vincent\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\f919f683d074912d6e0f1b8bf0931ab0\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
          -o \
          C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\res\merged\debug \
          C:\Users\Rhylle Vincent\Desktop\01-03-2018-740pm\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
  Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s

ids.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="timebar" type="id">Time</item>
    <item name="textClock" type="id">textClock</item>
</resources>

Upvotes: 1

Views: 90

Answers (2)

Shahzad Afridi
Shahzad Afridi

Reputation: 2158

On your Resource File remove the closing tag plus the Body i.e Remove "tv_deviceName"

  <item type="id" name="button_ok">tv_deviceName</item>

Id should be like this as below

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item type="id" name="button_ok" />
    <item type="id" name="dialog_exit" />
</resources>

Then, this layout snippet uses the "button_ok" ID for a Button widget:

<Button android:id="@id/button_ok"
    .... />

Notice that the android:id value does not include the plus sign in the ID reference, because the ID already exists, as defined in the ids.xml example above. (When you specify an ID to an XML resource using the plus sign—in the format android:id="@+id/name"—it means that the "name" ID does not exist and should be created.)

As another example, the following code snippet uses the "dialog_exit" ID as a unique identifier for a dialog:

showDialog(R.id.dialog_exit);

Refrence: Click here.

Upvotes: 1

navylover
navylover

Reputation: 13579

Should be:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="timebar" type="id"/>
    <item name="textClock" type="id"/>
</resources>

the ref is here.

Upvotes: 1

Related Questions