Search Unity

Creating plugin; extends UnityPlayerActivity

Discussion in 'Android' started by Roywise, Feb 19, 2019.

  1. Roywise

    Roywise

    Joined:
    Jun 1, 2017
    Posts:
    68
    So for the last two days I've been trying to create my own Android plugin to be able to listen for Intents using the onNewIntent(Intent intent) method.

    There's a whole lot of written and video tutorials on the internet so the progress has been fine. Most, or all, of these tutorials mention that your Android plugin will have to have the same package id as the unity package name and that is exactly the thing that is giving me headaches.

    Because we want to extend the UnityPlayerActivity class we have to add the Unity classes.jar file as a library to access that class in the plugin project but because Unity packages that same library when it creates an Android build we'll get a conflict; Multiple dex files define Lcom/company/product/BuildConfig.

    Multiple sources state that this should be fixed by adding the two line below in the build.gradle file;

    implementation fileTree(include: ['*.jar'], exclude: ['unity-classes-il2cpp-release.jar'], dir: 'libs')
    compileOnly files('libs/unity-classes-il2cpp-release.jar')

    Sadly this doesn't work at all, the same issue continues to plague me. Any pointers?



    I did manage to make a successful build with the functionalities that I need but that is without the plugin having the same package id as the Unity project and I have no idea what issues this might cause later down the line when we're expanding the plugin for more functionalities.
     
  2. Tomurtogu

    Tomurtogu

    Joined:
    Nov 30, 2012
    Posts:
    26
    Same issue here.
    Editing build.gradle didn't work for me either.
    Have you found a solution?
     
  3. Roywise

    Roywise

    Joined:
    Jun 1, 2017
    Posts:
    68
    I just used two different package id's and hope it won't break anything when we finally try to push it to the Android Play Store. This solution works fine for testing at this point.
     
  4. Tomurtogu

    Tomurtogu

    Joined:
    Nov 30, 2012
    Posts:
    26
    Thank you