我試圖讀取外殼的輸出數據使用新的字符串(字節)將不會在gradle這個
def cmd = "adb shell echo \$EXTERNAL_STORAGE"
def proc = cmd.execute()
println proc.in.text
工作,它竟然是在沒有任何的gradle而我在Groovy腳本只是試過代碼, 有效。
終於我發現問題應該是新的字符串(字節),下面的代碼在groovy腳本中工作,但不在gradle中。
byte[] bytes = [47, 115, 116, 111, 114, 97, 103, 101, 47, 101, 109, 117, 108, 97, 116, 101, 100, 47, 108, 101, 103, 97, 99, 121, 13, 10]
println new String(bytes)
任何人都可以告訴我發生了什麼事?真討厭......
-----------更新-------------------
我通過@試過代碼JBirdVegas,它似乎是由Android Studio 2.2.3版穩定引起的。我也試過
IntelliJ IDEA 2016.3.3
Build #IU-163.11103.6, built on January 17, 2017
Licensed to Benny Huo
Subscription is active until August 6, 2017
JRE: 1.8.0_112-release-408-b6 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
和以前一樣。
不像在命令行輸出,當你觸發這些IDE的gradle這個面板的gradle這個任務:
如果選擇UTF_8,US_ASCII或ISO_8859_1的字符集,你會看到什麼。
原來是我的Android Studio的問題。謝謝。 – Bennyhuo