2

I have my Android project divided into 5 modules. The 'app' module handles all the views and processing with the UI having all the resource drawables.

Now, I am implementing an algorithm to compare images and the source code must not be in the 'app' module. What is the correct way to access these drawables? I think that to maintain the project architecture I should create/add these drawables in this module, if so... how can I access them? because this only works when the java class is in 'app' module, which I don't want.

bmpimg1 = BitmapFactory.decodeResource(application.getApplicationContext().getResources(), R.drawable.example);

Do I have to add some lines on the gradle files? Thanks in advance.

1 Answer 1

2

I solved the issue by adding these lines to the build.gradle of the new module:

sourceSets{
    main.res.srcDirs = ['src/main/res']
}

and then the drawables of this module placed in the res/drawable folder were recognized:

bmpimg1 = BitmapFactory.decodeResource(application.getApplicationContext().getResources(), R.drawable.example);

Thanks.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.