Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8276051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:15:54+00:00 2026-06-08T08:15:54+00:00

I am facing problems getting the id of a resource by name when using

  • 0

I am facing problems getting the id of a resource by name when using a library project:

int resId = context.getResources().getIdentifier("myresname", "drawable", "net.iberdroid.mygamecore");

It seems like this always returns 0 when using the project as a library, but it were working flawlessly while it was an standalone project.

net.iberdroid.mygamecore is where those resources resides, and in fact they are there.

That code is even executed within the library project package, not from the android project that links it.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:15:55+00:00Added an answer on June 8, 2026 at 8:15 am

    I found a solution, but it is a bit weird and since I use a library for not making repetitive changes on different versions of same game (tipically free and pay versions), also a bit annoying.

    In this context, net.iberdroid.mygamecore is the Library Project shared by payment and free versions, and net.iberdroid.gamefree and net.iberdroid.gamepro are the Android Projects for free and pay versions of the game.

    If I change the package name on the previous code by “net.iberdroid.gamefree” it works fine. But the problem is that that code is within the library, and will be used also by “net.iberdroid.gamepro”, so putting the package name of the free version will broken the pay one and viceversa.

    So if I want to still share that code within the library, I will need to get the package name of the project dinamically. So this will do the trick:

    public static int getDrawableId(String dname) {
        String pn = context.getPackageName();
        int resId = context.getResources().getIdentifier(dname, "drawable", pn);
        return resId;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guyz facing problems with creating a push notification service (for android) using Google C2DM
I am facing some problems for using placement new for contiguous memory.Please guide me,
I am facing problem in getting Facebook data I am using Facebook SDK for
i am facing this problem here. i want to show item's name by getting
I am using cwac-endless adapter , and i am facing problems in disabling the
I am new to cufon and i am facing some problems in getting it
I am using canvas in wp7 silverlight application. I am facing two problems. So
Q:-Now a days I am facing problem in getting IP address of android device
I am facing a problem with EF Code First with TPH. I am getting
Hi I am facing a problem in Message dialog, getting Force close my code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.