Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Adding Android plugins files to custom package

Discussion in 'Package Manager' started by ZammyIsOnFire1, Jul 23, 2019.

  1. ZammyIsOnFire1

    ZammyIsOnFire1

    Joined:
    Sep 29, 2014
    Posts:
    19
    Hello

    I am trying to add sharing of a file to my custom package. Long story short I need a certain xml file to be inside res folder and I need something inside AndroidManifest.xml file.

    I have put my Plugins folder inside Runtime folder. The aar libraries are packaged correctly but things inside my manifest are not merged. It is just added to android-libraries folder (with my manifest copied as it is) rather than being merged. Xml file inside res folder is not in res folder but inside android-libraries.

    Where should I put my Plugins/Android folder so that it is merged correctly by Unity?
     
  2. ZammyIsOnFire1

    ZammyIsOnFire1

    Joined:
    Sep 29, 2014
    Posts:
    19
  3. manu73

    manu73

    Unity Technologies

    Joined:
    Aug 22, 2014
    Posts:
    68
    Hi @ZammyIsOnFire1 !

    I had to talk with platform team because your issue is a bit unrelated to package management.

    I just got this snippet of code:

    https://docs.unity3d.com/ScriptRefe...oject.OnPostGenerateGradleAndroidProject.html

    Code (CSharp):
    1.              
    2.         public void OnPostGenerateGradleAndroidProject(string projectPath)
    3.         {
    4.             var filesToCopy = GetFiles();
    5.             var directories = Directory.GetDirectories(projectPath);
    6.             foreach (var file in filesToCopy)
    7.             {
    8.                 // When exporting a gradle project projectPath points to the the parent folder of the project
    9.                 // instead of the actual project
    10.                 if (!Directory.Exists(Path.Combine(projectPath, "src")))
    11.                 {
    12.                     projectPath = Path.Combine(projectPath, PlayerSettings.productName);
    13.                 }
    14.              
    15.                 var fileInfo = new FileInfo(string.Format("{0}/src/main/res/{1}", projectPath, file.targetPath));
    16.                 if (fileInfo.Directory != null)
    17.                 {
    18.                     fileInfo.Directory.Create();
    19.                     File.WriteAllBytes(fileInfo.FullName, file.Content);
    20.                 }
    21.             }          
    22.         }
    23.  
    I hope it will help you.

    Regards,

    Manu
     
  4. ZammyIsOnFire1

    ZammyIsOnFire1

    Joined:
    Sep 29, 2014
    Posts:
    19
    Thank you for answering my query.

    So basically I should manually handle what goes into an Android package when working in a custom package?
     
  5. manu73

    manu73

    Unity Technologies

    Joined:
    Aug 22, 2014
    Posts:
    68
    @ZammyIsOnFire1

    AFAIK, after checking with platform team, this is the only way.

    Regards,

    Manu