Android xml 文件突然显示 java 代码. [英] Android xml files are showing java code suddenly.

查看:30
本文介绍了Android xml 文件突然显示 java 代码.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨晚我刚刚更改了 build.gradle 文件调试部分中的基本 url,因为我的基本 url 已更改.一切都很好,直到今天我启动我的个人电脑和 android studio 并看到我的所有 xml 文件都有 java 代码并且所有 xml 代码都被删除/消失了.我真的很恐慌.我不知道具体该怎么做.以下是这些 xml 文件中的内容:

I just changed base url in my build.gradle file debug section last night, since my base url was changed. It was all fine until today when i started my pc and android studio and saw that all of my xml files has java codes and all xml code has been erased/gone. I am really panicking. I dont know what exactly to do. Here is what is written in those xml files:

/* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * gradle plugin from the resource data it found. It
 * should not be modified by hand.
 */
package com.google.android.gms.measurement.api;

public final class R {
    private R() {}

}

每一个 xml 文件都有一些新的 java 代码或完全写入其中的新东西.

Each and every xml files has some new java code or something new written in them completely.

另外我想分享一下,我已经从 bitbucket 克隆了这个项目,它有旧的或其他的 gradle 版本,我现在有更新的一个或最新的一个(gradle 版本 4.6),但在我克隆它的那天它正在工作.现在我什至无法正确构建或重建,它总是显示此错误:

Also i would like to share that I have cloned this project from bitbucket which has old or other gradle version and i have newer one or latest one as of now (gradle version 4.6), but it was working the day i cloned it. Now i am not even able to build or rebuild properly, it always shows this error:

 Android resource compilation failed
    Output:  D:\Android projects\my_android\app\src\main\res\layout\activity_splash.xml:1: error: not well-formed (invalid token).

    Command: C:\Users\Datta\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\236d054aed32e77c579cff2f4ee8d067\aapt2-3.2.0-4818971-windows\aapt2.exe compile --legacy \
            -o \
            D:\Android projects\my_android\app\build\intermediates\res\merged\debug \
            D:\Android projects\my_android\app\src\main\res\layout\activity_splash.xml
    Daemon:  AAPT2 aapt2-3.2.0-4818971-windows Daemon #2

请帮我解决这个问题或提出建议.

Please help me with this or suggest something.

推荐答案

res\layout\activity_splash.xml 文件中似乎存在一些问题,需要检查是否声明小部件等是否有问题.

It seems like there is-are some issues in : res\layout\activity_splash.xml file which needs to check if declaration of widgets or etc have issues or not.

您还可以使用网站来检查 xml 文件是否有效,例如这个.

You can also use websites for checking the xml file for if it is valid or not like this one.

这篇关于Android xml 文件突然显示 java 代码.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆