Search Unity

Does Unity support using aar package as Android plugin library?

Discussion in 'Android' started by wenzhi, Oct 8, 2014.

  1. JeffersonTD

    JeffersonTD

    Joined:
    Feb 5, 2013
    Posts:
    268
    Could someone still elaborate a bit further how to make an .aar package work with Unity 4.x? Sure, the .aar can be opened as a zip file and extracted to the project (thus revealing the .jar inside), but that doesn't still get rid of the problem. I'm trying to use the Facebook SDK, and it's still giving me "java.lang.ClassNotFoundException: Didn't find class "com.facebook.FacebookContentProvider" due to the .aar packages.
     
  2. wtowns

    wtowns

    Joined:
    Feb 11, 2014
    Posts:
    4
    As far as I know, AAR support was added for 5.0, so isn't available in 4.x. Your best bet is to extract the aar into the project; if you're still getting ClassNotFoundExceptions then ensure that the .jar files are getting included in the build (by putting it in Assets/Plugins/Android or similar).
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    .aar libraries are supported since Unity 5.0, you just place them under Plugins/Android and Unity will detect them and treat them as Android plugins.
     
  4. JeffersonTD

    JeffersonTD

    Joined:
    Feb 5, 2013
    Posts:
    268
    It didn't help that I put them there. What's so special about the .aar packages? As the support for them was added to Unity 5.x, wouldn't it be pretty simple to add it to 4.x too?

    I hesitantly now upgraded to Unity 5.x even for a project that I wouldn't have wanted to upgrade from 4.x, and now I have to face the other pains of upgrading.
     
  5. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I think upgrading is the best option, as 4.x versions are now unsupported... (or soon going to?)

    There's nothing special about .aar packages - they are zip files with a particular internal structure that can contain both code and other things (resources). The whole point about Unity's support is probably how they added them to the android build process.

    Internally, when you build your game for Android, Unity will launch a bunch of tools from the android SDK that gather all libraries used and package them into the final game package. This code for doing this was not there for 4.x versions.

    It would be possible to add that to 4.x but as i mentioned i don't think they put up any efforts to adding features to those versions.

    BTW it may be possible to add .aar libraries if you build your project as a "Google android project". This means you don't get an .apk out of Unity; instead, you get a project that you can open using Eclipse or Android Studio. You can add .aar libraries at that stage, but it makes the whole process more cumbersome, so again, i think upgrading is the best option :)
     
    Yury-Habets likes this.
  6. JeffersonTD

    JeffersonTD

    Joined:
    Feb 5, 2013
    Posts:
    268
    Thanks for the comment. In general, yeah, I'm going to be using Unity 5.x, but at first I only want to get rid of my old Unity4.x project that's already been released for iOS (it's only Unity4.x as it's a hobbyist project that's been waiting its release for far too long). I checked how it would work upgrading to Unity 5, but it caused a bunch of problems including what seemed to involve a lot of manual work related to TextMesh Pro, so I really really would rather not go for that.

    In fact, I'm not any more convinced that this is about the .aar files at all. A Facebook support discussion regarding this exact same issue concluded that it's about the .aar files, but even though I did have some .aar files maybe as a remnant of another Facebook sdk package, the actual version I'm using doesn't have any .aar files! Yet for some reason it's still giving that com.facebook.FacebookContentProvider issue. I'm pretty clueless as to why. :(
     
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    You can PM and maybe i can help you out with this issue.
     
    JeffersonTD likes this.
  8. holysexy

    holysexy

    Joined:
    Dec 7, 2012
    Posts:
    2
    Hey all!

    I created a notification with Android Studio it works well at the moment but when i try to use NotificationCompatBuilder (for older api levels) it gives me error "ClassNotFoundException" android.support.v4.app.NotificationCompatBuilder which is from support-v4-25.1.0.aar file i think i need to add this manually ?

    When i get this file from sdk folder and paste it to Assets/Plugins/Android still same error am i doing something wrong here or ?

    Thanks in advance.
     
  9. holysexy

    holysexy

    Joined:
    Dec 7, 2012
    Posts:
    2
    OKAY LOL,

    Error was ClassNotFoundException android.support.v4.app but when i add support-compat-25.1.0.aar to Plugins/Android Folder the problem solved... so i find out i only need the compat.aar lol