Danny Higgins Danny Higgins - 3 months ago 68
Android Question

Error:(41) Error parsing XML: not well-formed (invalid token) + cannot resolve the symbol R

I can't find it anywhere. I have looked for over an hour now and am having zero luck. Do you see it?

I am also getting this error message:

Error:Execution failed for task ':app:processDebugResources'.


com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\danle\AppData\Local\Android\Sdk\build-tools\24.0.0\aapt.exe'' finished with non-zero exit value 1


<?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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.musicplayer.MainActivity">

<TextView android:text="@string/music_player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textview"
android:textSize="35sp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dana_higz"
android:id="@+id/textView"
android:layout_below="@+id/textview"
android:layout_centerHorizontal="true"
android:textColor="#ff7aff24"
android:textSize="35sp" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true"
android:src="@drawable/abc"
android:contentDescription="@string/player_icon" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="|<<"
android:id="@+id/reset"
android:layout_centerInParent="true"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/play"

/>


<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=">>"
android:id="@+id/play"
android:layout_centerInParent="true"
android:layout_alignParentBottom="true"

/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="||"
android:id="@+id/pause"
android:layout_centerInParent="true"
android:layout_toRightOf="@+id/play"
android:layout_alignParentBottom="true"
/>



</RelativeLayout>








package com.example.musicplayer;

import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

MediaPlayer mediaPlayer;

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

mediaPlayer = MediaPlayer.create(this, R.raw.gorillaz);

Button play = (Button) findViewById(R.id.play);
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

mediaPlayer.start();
}
});

Button pause = (Button) findViewById(R.id.pause);
pause.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mediaPlayer.pause();
}
});

Button reset = (Button) findViewById(R.id.reset);
reset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mediaPlayer.reset();
}
});




}
}

Answer

You can't use < in XML literally:

android:text="|<<"

Try replacing it with

android:text="|&lt;&lt;"
Comments