Gradle

有時候遇到 failed to crunch file (PNG) ,其實並不是PNG的問題,而是windows中路徑長度的問題,建議放在短一點的路徑中,就可以解決了,這算是一個window上的BUG(提示文字錯誤)

From what I understood, Failed to crunch file means studio can't process the file. This error usually occurs when you hit Maximum File Path Length Limitation(240 characters) of Windows OS.

I would suggest moving your project into upper directory (like D:\barcode-reader).

how to create Gradle Wrapper

聽起來就是自己可能軟體會因為版本,造成build有問題,所以如果能夠讓build 環境定義好在project內,那麼就不會有這樣的問題發生(不同版本),於是就有Gradle Wrapper這種東西產生,這邊告訴你怎麼產生

https://www.mkyong.com/gradle/how-to-use-gradle-wrapper/

Android Studio automatically creates a Gradle wrapper in the root of your project, which is how it invokes Gradle. The wrapper is basically a script that calls through to the actual Gradle binary and allows you to keep Gradle up to date, which makes using version control easier. To run a Gradle command, you can simply use the gradlew script found in the root of your project (or gradlew.bat on Windows) followed by the name of the task you want to run. For instance, to build a debug version of your Android application, you can run ./gradlew assembleDebug from the root of your repository. In a default project setup, the resulting apk can then be found in app/build/outputs/apk/app-debug.apk. On a nix machine, you can also just run find . -name '.apk' to find it, if it's not there.

1. build.gradle

通常會定義一些task,被寫在這個檔案中

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

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

這邊定義了他的task

2.Run Task , gradle build.gradle

執行後會再local產生

  |--- wrapper
      |--- gradle-wrapper.jar
      |--- gradle-wrapper.properties
|-gradlew
|-gradlew.bat

bat就是為了讓windows上能執行 gradle-wrapper.jar的批次

gradlew命令

gradlew clean gradlew build gradlew assembleDebug

results matching ""

    No results matching ""