2015-09-14 13 views
106

私はなぜ私はbuild.gradleファイルにコメントを記述するための構文が何であるかを、このプロジェクトためbuild.gradleファイルにコメントを書くための構文は何ですか?

をこのライブラリを選んだんでしたにコメントを書きたい場合はどう

このbuild.gradleファイル

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 21 
    buildToolsVersion "21.1.2" 

    defaultConfig { 
     applicationId "package.myapp" 
     minSdkVersion 19 
     targetSdkVersion 21 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.nineoldandroids:library:2.4.0' 
} 
を見下ろします?

答えて

168

簡単:

// Single line comment 

/* 
Multi 
line 
comment 
*/ 
15

例えば//または/* */

を使用します。

 // Top-level build file where you can add configuration options common to all sub-projects/modules. 

    buildscript { 
     repositories { 
      jcenter() 
     } 
     dependencies { 
      classpath 'com.android.tools.build:gradle:1.2.3' 

      // NOTE: Do not place your application dependencies here; they belong 
      // in the individual module build.gradle files 
     } 
    } 

/** 
* Returns the credential username used by Namirial Maven repository 
* Set this value in your ~/.gradle/gradle.properties with CREDENTIALS_USERNAME key 
* @return 
*/ 
def getCredentialsMavenUsername() { 
    return hasProperty('CREDENTIALS_USERNAME') ? CREDENTIALS_USERNAME : "" 
} 
+0

まあ非常に奇妙だったこと、私はそれを再起動するまで、私のAndroid Studioは、コメント行を認識していませんでした。面白いことに、Web上には何の答えもありません。 – Machado

関連する問題