There is a standard way to build Unity applications for Android - to put all jars, manifests and resources in Assets/Plugins/Android forlder.
But we want to componentize or project and to put all staff, related to the certain component, to the folder such as Assets/Packages/Component1/Android
Is there a way to do this with the latest Unity version?
Unity recognizes Plugins folders wherever they are. So, if this is what you want, you can put your stuff into Assets/Packages/Component1/Plugins/Android and put all of those libs there.
Example hierarchy may be.
Assets/Packages/Component1/Scripts - all of the c# scripts here
Assets/Packages/Component1/Plugins/Android - android libs here
Assets/Packages/Component1/Plugins/iOS - ios libs here
etc...
Related
Hey I'm pretty new to android studio, and relatively new to android development and it recently occurred to me that I'm not sure whether to put libraries in the libs folder or set them up as as an external library - what's the difference?
Most of what I've found online explains how to include jar files in the libs folder and then compile in the app gradle. This is what I've tended to do, but I've seen projects that work differently and I'm wondering what the protocol is for this.
Also how do you make an external library? Do you just place the jar file in it?
Thanks!
There is no way to create an external library directly in Android Studio. You add a library to your libs folder or add a dependency to your build.gradle, then you reimport the project, and it appears as an external library.
In other words, there is no difference - it's the same thing.
Has anyone found a good way to utilize Android .aar libraries within Unity3D, other than unzipping them?
Snippets from the Unity 4.2 Release Notes:
Android: Added support for Android Library Projects (no compilation
support, so the libraries have to be pre-compiled).
Android: Remove Eclipse project support in favor of Android project support.
Android: Support for Android SDK rev22.
The Unity documentation clarifies
Pre-compiled means all .java files must have been compiled into jar files located in either the bin/ or the libs/ folder of the project.
I'm familiar with using the jar + res/ solution; but I am specifically trying to identify the best way of incorporating the precompiled aar. Is there something better than unzipping it?
With Unity 5, just place .aar files in the project. (They don't even need to be in /Plugins/Android anymore, just check the inspector and make sure they are turned on for Android platform).
I am trying to use Roboguice in my app, but no matter how i try to add the jars they don't seem to be added to the apk doesn't include the roboguice/guice jars. What do I do? using eclipse 3.5 and adt .9.9
where did you put the jars?
I usually put 3rd party jars in the lib folder at the root of your Project folder (same level as src, assets etc) and they seem to get picked up when building the apk. Make sure in Eclipse you are referring to the jar from the lib folder as well!
Oh Android. How I love your verbiage.
I have a workspace with a few projects in it. App1 and App2 are Android applications. Common is an Android library project. App1 and App2 depend upon Common (linked via the Android tab).
Common has some external dependencies, namely httpmime & apache-mime4j, which exist as jar files.
For some reason, it appears that I need to add my mime jars to the build path of App1 and App2 for compilation to succeed. This seems really dumb. In normal Java, I would add Common to the build path of App1 and App2 and things would work. Is this expected that I have to add my jars to every Android application?
-Andy
Note: If I don't configure the build path as described above, I get "The type org.apache.james.mime4j.message.SingleBody cannot be resolved. It is indirectly referenced from required .class files | DataCallUtil.java | /App1/Common/util | line 364"
I think omermuhammed and Amit didn't get the fact that Visser is talking about a Android Library Project.
For those project, I don't think it is possible to create a jar. ( jar has nothing to do with all the Android resources thing ).
From my experience with Android Library Project, this kind of project are just, basically, the sources and the ressources packaged, and ready to be included in another project.
But the settings are not part of the package, so you have to include the libs for each application.
In my experience, this setting is not something that changes often, so it is not so bad.
Android Library Project are still way from being perfect, but still a huge improvement from what was there before ( ie nothing ).
To augment omermuhammed's reply, if the common project is not one that is being changed frequently, creating a jar and using it in the other projects is a good solution.
To create a jar right-click the project on Eclipse -> Export -> Java -> JAR file, then select the folders you want to include in the JAR, in your case I guess this includes the folders gen and libs (libs being the folder with the httpmime & apache-mime4j JARS), but probably neither res nor the root directory of your project (with files such as AndroidManifest.xml that will cause problems with the same file in the dependent projects).
Try compiling the Common project into a jar and adding it as an external jar to your App1 or App2 projects.
I asked this question on the android-developers group but didn't get any response, so I thought I'd try here.
The ADT eclipse plugin seems to have a pretty rigid idea of how an Android project should be structured - per http://developer.android.com/guide/developing/eclipse-adt.html, it needs to have the AndroidManifest.xml file at the root level of the project, plus res, assets, gen and src folders at the top level, and so on.
I'm wondering if it's possible to get the plugin to be a little more flexible with the layout it recognizes. In particular, I've been using a build plugin for the (scala-based) simple-build-tool, which expects projects to be laid out in a more Maven-like fashion, like so:
src/
main/
AndroidManifest.xml
assets/
res/
scala/
java/
test/
resources
<files to include in test jar here>
scala/
<test Scala sources>
java/
<test Java sources>
(see the simple-build-tool docs).
This is a layout I'm used to from maven-based java development. When I load a project like it up in ADT, though, I get a lot of complaints about a missing AndroidManifest.xml, a missing res directory, and so on. These things are all present, they just aren't where ADT expects them to be.
I don't necessarily need to use ADT to build my project, but I'd like to use it (and Eclipse) for editing. Can anybody tell me whether it's possible to make it more flexible in the directories it uses to find various Android-related resources?
Also, can anyone tell me whether the ADT plugin is open-source? I can't seem to find a link to its source code anywhere.
(As a note, I've also been trying to wrangle sbt to just do things in a way that ADT likes, and it's probably possible to do but it seems very tedious.)
Here's is where you can find the ADT source for r3 0.94, couldn't find the latest though
I do not believe you can change the Android project structure and have ADT understand it. It would be "very tedious" to do that even with the Ant-based command-line builds -- you'd have to make your own copy of the various Android Ant tasks, modify them to suit (and hope the underlying build tools allow what you want), then maintain them forever in the face of Android SDK updates.
Your structure is actually fairly close to the Android expectation, if you consider main/ to be the Android project. If you can convince sbt to allow src/ instead of java/ there, and if sbt won't complain about the resulting bin/ and gen/ you will wind up with in main/ after a compile, you might get it to work.
As far as I can tell, ADT requires those folder names, but there is a workaround: you can create "linked folders" in Eclipse. These are similar to symbolic links in Unix, but are stored in the Eclipse .project file instead of the filesystem, so they are only visible to Eclipse.
You can create one by right clicking in Eclipse the root of the project, and then selecting "Create New Folder". Click on "Advanced" and select the option to create a linked folder. Then type in where you want it to link to. You can use PROJECT_LOC at the begining to specify the project directory, so for your example you would type PROJECT_LOC/src/main/res as the folder to link to, and use the automatically generated name of "res" for the created folder.