【问题标题】:Error:(41) Error parsing XML: not well-formed (invalid token) + cannot resolve the symbol R错误:(41) 解析 XML 时出错:格式不正确(无效令牌)+ 无法解析符号 R
【发布时间】:2016-12-12 09:35:30
【问题描述】:

我在任何地方都找不到它。我现在已经找了一个多小时,运气为零。你看到了吗?

我也收到此错误消息:

错误:任务 ':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'' 以非零退出值 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();
            }
        });




    }
}

【问题讨论】:

  • 可以是java的,能贴出代码吗?
  • 我已经添加了 java.lang.我也遇到了 cannot resolve the symbol r 错误。
  • 问题已解决。谢谢

标签: java android xml


【解决方案1】:

你不能在 XML 中直接使用&lt;

android:text="|<<"

尝试替换为

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

【讨论】:

  • 解决了!谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-08-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-25
相关资源
最近更新 更多