bcorso
bcorso

Reputation: 47068

Android Error Importing Library which references R resource

I have an Android Library that I've uploaded to Artifactory and include in a separate application using

compile 'com:mycompany:mylibrary:0.0.1'

The gradle syncs properly and imports the library to my 'External Libraries', however when I run the application I get errors referencing code in the library:

// Code in my android library dependency
AUTHORITY = getContext().getString(R.string.content_provider_authority);
                                   ^ error: package R does not exist

If anyone has ideas on what's going on please let me know.

Upvotes: 1

Views: 76

Answers (2)

bcorso
bcorso

Reputation: 47068

Turns out I needed a .aar file not a .jar file for android library dependency. The .aar file is a zip file which contains everything you need for your android library.

Upvotes: 1

Lab Ipoh
Lab Ipoh

Reputation: 9

  1. For AUTHORIY, you should use constant string like this:

private static final String AUTHORITY = "your_package"

  1. For your case, make sure you check gen folder when exporting to jar files

Upvotes: 0

Related Questions