Jar file under res / raw folder

I need to place a third-party jar file as a source resource under res / raw in my apk. But with Android Studio (Im using 1.3.1), it seems like the file disappears from the latest apk. Presumably due to the jar extension.

I cannot rename it and do not want it to be included in dex classes. My application needs access to the jar runtime as a raw resource.

Any advice (possibly modifying gradle tasks) how is this achieved?

+4
source share
1 answer

According to official Android documentation, you should always put .jar files only in the /libs folder.

See official documentation

raw /

For arbitrary raw files. Saving asset files here is essentially the same as storing them in the assets / directory. The only difference is how you refer to them. These files are processed by the aapt command and there must be a link from the application using the resource identifier in the R class. For example, this is a good place for media such as MP3 or Ogg files.

libs /

Contains private libraries. The module is stored in the main application.

Once you have placed the .jar file inside the /libs folder, you can easily reference it through the gradle.build file,

For example, I put this acra-4.6.2.jar file in the /libs folder

enter image description here

and made a link in the gradle.build file as follows:

 dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile files('libs/acra-4.6.2.jar') } 
+1
source

All Articles