Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by theblitz · Feb 27, 2017 at 02:21 PM · androidlibraries

Gradle file for Unity

I saw mentioned in another post that from the newest versions of Unity you can define your own gradle file. I need this in order to include support libraries and compat libraries.

I created a file called dfwvr.gradle in the Plugins/Android directory but it doesn't seem to help. Renaming it to build.gradle made no difference. I took the basic one from the one supplied.

 buildscript {
  repositories {
     jcenter()
  }

  dependencies {
     classpath 'com.android.tools.build:gradle:2.1.0'
  }
 }

  allprojects {
  repositories {
     flatDir {
       dirs 'libs'
     }
  }
 }

 apply plugin: 'com.android.application'

 dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile "com.android.support:appcompat-v7:24.2.1"
  compile "com.android.support:support-v4:24.2.1"

 **DEPS**}

   android {
    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'

 defaultConfig {
     targetSdkVersion **TARGETSDKVERSION**
 }

 lintOptions {
     abortOnError false
 }
 **SIGN**
 buildTypes {
     debug {
         jniDebuggable true
     }
     release {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
         **SIGNCONFIG**
     }
 }

  }

I followed what it says here but it doesn't work: http://answers.unity3d.com/questions/1308071/use-android-plugin-with-android-support-library-de.html

@liortal

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image liortal · Feb 27, 2017 at 07:35 PM 0
Share

what Unity version are you using? custom gradle support was added in some 5.5.x patch (cant recall the exact version)

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by liortal · Feb 27, 2017 at 08:12 PM

You should name your custom gradle build file Assets/Plugins/Android/mainTemplate.gradle as documented here: https://docs.unity3d.com/Manual/android-gradle-overview.html

The easiest way to check if your custom Gradle build file is being picked up or not, is by exporting a project (check the "Export Project" checkbox).

After the build completes, you can see if the build.gradle file in the output folder matches the one you used or not.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image xysverma · Jun 02, 2017 at 04:58 AM 0
Share

Its documented at https://docs.unity3d.com/$$anonymous$$anual/android-gradle-overview.html but not well documented

avatar image liortal xysverma · Jun 04, 2017 at 08:47 PM 0
Share

thanks. updated my answer with that link

avatar image mini-lucy · Sep 27, 2017 at 09:15 AM 0
Share

I follow the guide doc that you attached, https://docs.unity3d.com/$$anonymous$$anual/android-gradle-overview.html

$$anonymous$$ade a file mainTemplate.gradle and put it in the project like below. "Assets/Plugins/Android/Android$$anonymous$$anifest.xml"

But still, when I export the Gradle project it didn't overwrite build.gradle.

Has anyone same problem like me?

avatar image xysverma mini-lucy · Sep 27, 2017 at 11:56 AM 0
Share

Never had this issue. Unity has a default mainTemplate.gradle file in unity installation folder. Try using it as a base because you might have some error which might be causing it.

Secondly "Assets/Plugins/Android/Android$$anonymous$$anifest.xml" is not the path. Custom gradle path is supposed to be "Assets/Plugins/Android/mainTemplate.gradle"

avatar image
0

Answer by NOGOODGAMES · Aug 06, 2020 at 11:17 PM

@theblitz make sure that your custom Gradle is checked in player settings. Check custom Gradle. You should be good to go. If the .Gradle file seems to be reverting after build I am also experiencing the same issue ;)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Error when using a NDK built Library which depend on another one in a Unity project 0 Answers

Which C# libraries are compatible with Unity Android or iOS 1 Answer

Importing Multiple Unity Project as a library inside Android Project 2 Answers

Runtime Library supports Oculus Go 0 Answers

Adding features, eg online multiplayer android/ios 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges