• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by swquinn · Nov 21, 2014 at 02:28 PM · androidjar

Where can .jar files be placed under Assets/Plugins/Android?

Where should I be placing .jar files in Unity's directory structure under Plugins/Android? Should they be placed in the root-level of this directory, or can they be placed in sub-directories, e.g. Plugins/Android/libs, Plugins/Android/MyProj/libs, etc.?

I was looking for documentation on this, and seem to remember seeing some place that Plugins/Android, Plugins/Android/libs, and Plugins/Android/bin were all viable locations, but certain plugin vendors have different directory structures than this.

More Details...

I've recently been playing around with a couple of Android plugins (specifically, Google Mobile Ads SDK and Google Play Games) and have been trying to wrap my head around the directory structure for Android-builds.

For instance, Google Play Games creates the following directory structure when it is imported and configured:

 Plugins
 |- Android
    |- BaseGameUtils
       |- libs
       |- res
    |- google-play-services_lib
       |- libs
       |- res
       |- src
    |- MainLibProj
       |- libs


In the above directory structure, the specific plugin component (e.g. BaseGameUtils) is collected in its own folder and underneath it has the /libs, /res, etc. directories that should contain the appropriate compiled Java classes, resources, etc. that the component relies upon.

Disclaimer: Because I'm a bit neurotic and also like to go against the grain, I modified the directory structure some, because BaseGameUtils and MainLibProj meant nothing to me, currently I've renamed them such that my directory structure is named after the associated package in the android manifest (e.g. com.google.example.games.basegameutils), in hindsight these names don't mean much more to me than their originals, but it serves as a good example of arbitrary folder names:

 Plugins
 |- Android
    |- com.google.android.gms (NB: was "google-play-services_lib")
       |- libs
       |- res
       |- src
    |- com.google.example.games.basegameutils (NB: was "BaseGameUtils")
       |- libs
       |- res
    |- com.google.example.games.pluginsupport (NB: "MainLibProj")
       |- libs

What I have noticed, and I have yet to test this with the original directory names, is that when I compile and publish a build to an Android device or emulator, the classes referenced in base-game-utils.jar, under Plugins/Android/com.example.games.basegameutils/libs are not being found by code that uses them. Furthermore, if I look at the staging area for the project, under Temp/StagingArea/plugins I don't see the .jar files that are present under nested libs directories in Plugins/Android.

If I move the jars to the root-level of Plugins/Android, say for example base-game-utils.jar I will see this .jar file referenced under the staging area and it will be found by Unity when resolving class references in Android, rather than giving me a ClassNotFoundException.

I am currently using one of the 4.6 beta releases (4.6.0b21).

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image swquinn · Nov 21, 2014 at 04:03 PM 0
Share

As an aside, I found reference to the fact that subfolders are not supported as of this writing (November, 2014) for iOS (see: http://docs.unity3d.com/$$anonymous$$anual/PluginsForIOS.html), but there is no mention of such a limitation in the current Android documentation.

3 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by Yury-Habets · Nov 21, 2014 at 08:53 PM

We support the following Android plugin types:

  • plain compiled .jar files - can be placed in Assets/Plugins/Android, Assets/Plugins/Android/bin and Assets/Plugins/Android/libs. They are copied to StagingArea and compiled into resulting .dex. No resource or manifest merging available here (only complete overriding the manifest by placing it into Assets/Plugins/Android/AndroidManifest.xml)

  • Android library projects - this is a subdir in Assets/Plugins/Android with its own project structure (just as you described in the original post). The compiled .jar file can be placed in libs/ or bin/, resources and manifests are merged. Please refer to Android Library Project section in http://docs.unity3d.com/Manual/PluginsForAndroid.html for more details.

My wild guess is that your subdirs are not being identified as Android Library projects because the project.properties file does not contain

 android.library=true 

line. Try adding it... Though you would probably also need some magic with the manifests, but the classes should be present now.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image swquinn · Nov 21, 2014 at 09:05 PM 0
Share

Ah! I think you're right! Let me try the android.library property. I forgot completely about that! I actually think I may have made a change to that property haphazardly before. Do you happen to know where (if at all) that property is documented? I couldn't find it.

avatar image swquinn · Nov 22, 2014 at 12:42 AM 0
Share

Thanks Yury, that was exactly the issue that I was experiencing. Both in the case that one of my subfolders had a project.properties with android.library=false and another didn't have one at all.

Also, in case anyone is interested it appears .jar files in the root of Plugins/Android will be staged under the StagingArea/plugins directory, whereas subfolders identified by android.library=true in the project.properties files will be staged under StagingArea/android-libraries.

avatar image
0

Answer by psycocrusher · Nov 21, 2014 at 06:47 PM

You drop them in Asset/Plugins/Android in the same place the AndroidManifest is.

But i got a Plugin from Prime31 and they place it in:

Asset/Plugins/Android/google-play-services_lib/libs/google-play-services.jar

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Bunny83 · Nov 21, 2014 at 03:48 PM

I'm sure I've read it in the manual (though i can't find it anymore) that subfolders aren't supported for the Assets/Plugins/Android/ folder. So you should place your .jar file directly into that folder.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image swquinn · Nov 21, 2014 at 03:52 PM 0
Share

Thanks @Bunny83! Always to the rescue. That is what I'm lead to believe, based on my personal experiences. It appears that Android$$anonymous$$anifest.xml files may be read from subfolders, but I need to test a bit with it. You don't happen to know of any example of the "preferred Android setup", with jars, resources, etc. do you?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

29 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Calling static jar function from Unity3D 0 Answers

Unity3D:Field text or type signature not found when i use GetStatic to reach a string inside a Jar android plugin 0 Answers

Location of PlaybackEngines/AndroidPlayer/bin on a Mac to find classes.jar ? 1 Answer

Unity3D:Field text or type signature not found when i use GetStatic to reach a string inside a Jar android plugin 0 Answers

Android Studio .JAR Export instructions sought 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges