简体   繁体   中英

Adding RecyclerView and Material Design dependencies to new projects in android studio permanently

I wanna add recyclerview and material design dependencies once for all the time, means I don't wanna add them again and again for every new project.

I just wanna add these dependencies permanently or by default any idea? how to do it?

Modify build.gradle.ftl at

<android studio installation directory>/plugins/android/lib/templates/gradle-projects/NewAndroidModule/root/build.gradle.ftl

add Material Design and recyclerView dependencies to the bottom of dependencies block.

ex:

<#import "./shared_macros.ftl" as shared>
<#import "root://activities/common/kotlin_macros.ftl" as kt>
<#if isInstantApp>
apply plugin: 'com.android.feature'
<#else>
  <#if isLibraryProject>
apply plugin: 'com.android.library'
  <#elseif isDynamicFeature>
apply plugin: 'com.android.dynamic-feature'
  <#else>
apply plugin: 'com.android.application'
  </#if>
</#if>
<@kt.addKotlinPlugins />

<@shared.androidConfig hasApplicationId=isApplicationProject applicationId=packageName isBaseFeature=isBaseFeature hasTests=true canHaveCpp=true canUseProguard=isApplicationProject||isBaseFeature||(isLibraryProject&&!isInstantApp)/>

dependencies {
    ${getConfigurationName("compile")} fileTree(dir: 'libs', include: ['*.jar'])
    <#if !improvedTestDeps>
    ${getConfigurationName("androidTestCompile")}('com.android.support.test.espresso:espresso-core:+', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    </#if>
    <@kt.addKotlinDependencies />
<#if isInstantApp||isDynamicFeature>
  <#if isBaseFeature>
    <#if monolithicModuleName?has_content>
    application project(':${monolithicModuleName}')
    <#else>
    // TODO: Add dependency to the main application.
    // application project(':app')
    </#if>
  <#else>
    implementation project(':${baseFeatureName}')
  </#if>
<#else>
  <@shared.watchProjectDependencies/>
</#if>

    implementation 'com.google.android.material:material:1.1.0-alpha09'
    implementation 'androidx.recyclerview:recyclerview:1.1.0-beta03'
}

Save the file.

After modifying the file when you create a new android module or a new phone and tablet project, material design and recyclerview dependencies will be automatically added to your module's gradle file.


Reference: https://stackoverflow.com/a/37603533/7356355

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM