Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Is it possible to alias R from app and lib to distinguish between the two?
    primarykey
    data
    text
    <p>Can I somehow alias a generated <code>R</code> file from a library and a generated <code>R</code> file from an application?</p> <p><code>IE</code>: I have two projects, one being a library. I reference the library in the application. The library creates one <code>R</code> file, the application creates two: <code>com.example.mapplication.R</code> and the <code>R</code> from the referenced library, <code>com.example.mlibrary.R</code>. However, since I want to use both frequently in the application, I want to alias both the <code>R</code> classes. For example, call the library <code>R</code> something like <code>libR</code> and the app <code>R</code> something like <code>appR</code>.</p> <p>I tried a couple of things which are of such stupidity, I won't even fully mention them, but I did some things like <code>private com.example.mapplication.R appR = com.example.mapplication.R</code> (immediately realising this wasn't gonna work), and <code>private Class&lt;com.example.mapplication.R&gt; appRclass = com.example.mapplication.R.class;</code>, but that didn't give me the desired effect. I do, however, use the latter method and some reflection to make it possible to be able to get the field and inner classes like this:</p> <pre><code>Class&lt;com.example.mapplication.R&gt; appRclass = com.example.mapplication.R.class; int activity_main_layoutid = Toolkit.getFromClass(appR). getMeTheInnerClass("layout").getMeAField("activity_main"); </code></pre> <p>I haven't fully implemented the Toolkit method, but as we all know refletion can do this kind of stuff, but at the end of the day it's just as much work as just typing <code>com.example.mapplication.R</code> or <code>com.example.mlibrary.R</code> everywhere.</p> <p>So to wrap thing up: <strong>Is it possible to alias multiple <code>R</code>'s</strong> so that I can use <code>appR</code> and <code>libR</code> to distinguish the two? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload