R.java中没有得到正确生成为Android图书馆中的应用 [英] R.java not getting generated properly for Android Library Application

查看:80
本文介绍了R.java中没有得到正确生成为Android图书馆中的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的Andr​​oid应用程序库包含一个TextView仅有1活动。它工作正常,但是当我将其标记为在另一个应用程序库和参考,这是给错误,当我试图让使用findViewById(R.id.welcome_textview)的文本视图。

I have created a simple Android Library application with just 1 activity containing a TextView. It works fine, but when I mark it as a library and reference in another application, it is giving errors when I am trying to get the Text View using findViewById(R.id.welcome_textview).

据生成R.java,但在第二个应用程序,其中我引用库,它不包含ID字段。这里有越来越生成的两个R.java文件: -

It generated R.java, but in the second app where I am referencing the library, it does not contain the id field. Here are the both R.java files that are getting generated: -

图书馆中的应用

    /* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * aapt tool from the resource data it found.  It
 * should not be modified by hand.
 */

package com.example.mylibrary;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int icon=0x7f020000;
    }
    public static final class id {
        public static final int welcome_textview=0x7f050000;
    }
    public static final class layout {
        public static final int main=0x7f030000;
    }
    public static final class string {
        public static final int app_name=0x7f040001;
        public static final int hello=0x7f040000;
    }
}

在其他应用程序相同的文件

Same file in the other Application

/* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * aapt tool from the resource data it found.  It
 * should not be modified by hand.
 */

package com.example.mylibrary;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int icon=0x7f020000;
    }
    public static final class layout {
        public static final int main=0x7f030000;
    }
    public static final class string {
        public static final int app_name=0x7f040001;
        public static final int hello=0x7f040000;
    }
}

我在哪里去了?

Where am I going wrong?

推荐答案

在尝试了很多东西小时,终于发现了问题。在引用的项目,有被自动创建这是空的布局文件夹。删除该文件夹固定的问题。希望这可以帮助别人。

After hours of trying a lot of stuff, finally found the problem. In the referenced project, there was the Layout folder that was created automatically which was empty. Deleting that folder fixed the issue. Hope this helps someone.

这篇关于R.java中没有得到正确生成为Android图书馆中的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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