Can't find resource symbol from plugin (Android)

Oh no.  That “SimpleLuaExtensions” sample project is certainly *not* deprecated.  I’m going to have to flog the person who wrote that.  I personally wrote all of the Enterprise sample projects for Android, kept them up to date, and they’re by far the simplest most well documented examples that we’ve got.  The “App” template is intended for plugin developers.  I’m so sorry for the confusion.

If you want to make your social media a separate Android library and avoid the resource issue, then the solution is to create an “Android library project”.  This has a very particular directory structure which would look a lot like the Corona or Facebook Android library folders.  If you do it this way, then all you have to do is reference your library project via the “project.properties” file.  Then when you build your application project, the Android build system will merge the resource files from all the library projects and the application project into one and generate a single “R.java” file for all projects, avoiding the duplicate resource ID issue.

Google documents how to set up Android library projects here…

   https://developer.android.com/tools/projects/index.html#LibraryProjects

<p>Don’t flog the guy, have mercy <img class=“bbc_emoticon” src=“http://forums.coronalabs.com/public/style_emoticons/default/smile.png” title=":)" /></p>
<p> </p>
<p>Anyway, it doesn’t take much for me to change from LuaLoader but the problem still the same. Here’s my class, it’s abit long but you only need to care about public function show() where I need to access R.drawable.kqpromo :<br />
 </p>

<p>“UMImage(CoronaEnvironment.getCoronaActivity(),R.drawable.kqpromo));” -> Still cause problem cause the symbol R.drawable.kqpromo isn’t found.<br />
<br />
Sorry if the code is too long but I don’t want to leave anything out.</p>

I think the problem is with your “import android.R;” statement.

The Android build system will generate an “R.java” file under the package name (aka: namespace) you specified in your “AndroidManifest.xml” file.  That’s the one you need to import because it contains your app’s resource constants.

Assuming that your package name is “com.iplayalldaystudio.kqiplay”, try changing your import statement to this…

   import com.iplayalldaystudio.kqiplay.R;

…or if your Java code is already in the “com.iplayalldaystudio.kqiplay” package/namspace, then you don’t need to import the “R” class at all.

That solved it! Thanks Joshua for the support though it has more to do with me being a noob android coder rather than an enterprise issue.

I really appreciate it, my lingering question is… using packagename.R didn’t work before and consult in stackoverflow and someone suggest that android.R is the right way to do.

Nvm… will read the docs later but at least now it’s working :slight_smile:

Happy to help!  Oh and the “android.R” class that you imported belongs to Google and is what’s documented in the link below.  That’s definitely not the one you wanted.  :slight_smile:

   http://developer.android.com/reference/android/R.html