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. Dismiss Notice

App - level Gradle for unity project

Discussion in 'Android' started by brooklynn, Apr 6, 2018.

  1. brooklynn

    brooklynn

    Joined:
    May 18, 2017
    Posts:
    2
    I am using Firebase Database with unity 5.6.1. I am building an android app with the (new)gradle method because I have way too many field references than allowed. The firebase instructions say the following:
    1. Project-level build.gradle (<project>/build.gradle):

      buildscript {
      dependencies {
      // Add this line
      classpath 'com.google.gms:google-services:3.2.0'
      }
      }
    2. App-level build.gradle (<project>/<app-module>/build.gradle):

      dependencies {
      // Add this line
      compile 'com.google.firebase:firebase-core:12.0.0'
      }
      ...
      // Add to the bottom of the file
      apply plugin: 'com.google.gms.google-services'

    Here, the project-level build.gradle means the mainTemplate.gradle file in Assets/Plugins/Android/mainTemplate.gradle. But where should I add the app-level gradle file. I tried to make a folder called 'app' in Assets/Plugins/Android and write the instructed statements. But, it doesn't seem to work. Please help. I do not know how to do this. I have been stuck at this for 3 days now. Thanks in advance.
     
  2. turbolek

    turbolek

    Joined:
    Dec 30, 2016
    Posts:
    10
    Did you ever managed to solve this?
     
  3. weiping-toh

    weiping-toh

    Joined:
    Sep 8, 2015
    Posts:
    186
    I assume that the module name is Firebase.
    So it should be:
    Assets/Plugins/Android/Firebase

    You probably should use the full module name as declared in the main gradle file.
     
  4. AppDevPareeta

    AppDevPareeta

    Joined:
    Jun 17, 2019
    Posts:
    2
    How do you make unity to export the project in a custom structure, like make it place all the libs, src folder in a new folder called app ?

    For now, i can do this only after exporting it i.e. can split the gradle file into project level and app level, reorganise the structure.
    But i want to know if there is a way that we can make unity do this ?
     
  5. weiping-toh

    weiping-toh

    Joined:
    Sep 8, 2015
    Posts:
    186
    I rather you not attempt to do this as the gradle scripts and methods generated by Unity have project paths built into them. Messing around with the folder structure would require you to rewrite the gradle scripts manually.
    As mentioned, the app mentioned by the Firebase documents usually refers to the Firebase module itself. So, just make a folder in the Plugins/Android named <insert Firebase Module name> and place the app-level build.gradle in there.