Android開發周邊

rockcy1992 7年前發布 | 6K 次閱讀 安卓開發 Android開發 移動開發

dryrun

通過 dryrun 可以簡單的通過一個github中的地址,就直接將項目運行到手機上。

2. 檢索引用

alfi

可以快速檢索需要引用庫的 jcenter 與 maven central 的引用代碼。

3. 快速反編譯

反編譯

很便捷的反編譯工具,可對dex文件直接反編譯打開: jadx-gui classes.dex 。

4. 圖片壓縮

除了在CI系統上保持對資源變化的持續監控(對大多數的Android應用而言,資源往往是Apk大小的主要根源之一),

II. gradle小技巧

  • 通過 --offline ,離線編譯,免去檢測的網絡耗時
  • 通過 gradle --stop ,停止所有的gradle編譯,包括IDE中的
  • 需要配置分離api、impl包可以參考 gradle-sample

引用關系

可以通過 ./gradlew dependencies 來查看最終的依賴關系。

如針對項目中的app module進行查看其引用關系: ./gradlew :app:dependencies 。

需要特別注意的是

都是對相通庫同類型的引用,如都是 testCompile ,或都是 compile ,那么Gradle會自動選擇最高版本的:

compile'cn.dreamtobe.filedownloader:filedownloader-okhttp3-connection:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.liulishuo.filedownloader:library:1.4.1'

對相同庫不同類型的引用時,此時會發生沖突:

compile'cn.dreamtobe.filedownloader:filedownloader-okhttp3-connection:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
testCompile 'com.liulishuo.filedownloader:library:1.4.1'

這個時候我們就要根據需要exclude掉沖突的版本,如我們只需要引用 okhttp 3.6.0 版本與 filedownloader 1.4.1 :

compile('cn.dreamtobe.filedownloader:filedownloader-okhttp3-connection:1.0.0') {
    exclude group: 'cn.dreamtobe.filedownloader', module: 'library'
    exclude module: 'okhttp'
}
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.liulishuo.filedownloader:library:1.4.1'

testCompile 'com.liulishuo.filedownloader:library:1.4.1'
testCompile 'com.squareup.okhttp3:okhttp:3.6.0'

III. 編程工具

1. 耗時日志

hugo

hugo

輕松給方法添加耗時日志:

@DebugLog
publicStringgetName(String first, String last){/* ... */}

輸出日志:

V/Example: --> getName(first="Jake", last="Wharton")
V/Example: <-- getName [16ms] = "Jake Wharton"

Pury

Pury

統計事件之間的耗時:

App Start --> 0ms
  Splash Screen --> 5ms
    Splash Load Data --> 37ms
    Splash Load Data <-- 1042ms, execution = 1005ms
  Splash Screen <-- 1042ms, execution = 1037ms
  Main Activity Launch --> 1043ms
    onCreate() --> 1077ms
    onCreate() <-- 1100ms, execution = 23ms
    onStart() --> 1101ms
    onStart() <-- 1131ms, execution = 30ms
  Main Activity Launch <-- 1182ms, execution = 139ms
App Start <-- 1182ms

2. 日志著色

pidcat

3. 項目License配置

基于Android Studio的Copyright功能

第一步. 在Copyright Profiles中添加license

Android開發周邊

第二步. 在Copyright中配置項目默認的license

至此,默認創建的文件就頂部就會申明license,并且可以對文件一件添加license

當然如果需要特殊配置針對不同語言文件license格式等配置,可以在Formatting下面進一步配置。

4. 查看依賴庫方法數

Methods Count

5. UI生成器

除了上面兩個,也可以使用Android Studio自帶的:

6. 包大小跟蹤與對比

包大小跟蹤

APK patch size estimator

谷歌官方提供的Google Play差分包大小,也可以做簡單的文件大小變更大小對比,可以集成到CI中持續跟蹤包大小變化,也可以簡單的對比兩個包的大小:

New APK size on disk: 18,271,850 bytes [17.4MB]

Estimated download size for new installs:
   Full new APK (gzipped) size: 16,339,603 bytes [15.6MB]

Estimated download size for updates from the old APK, using Bsdiff:
   Bsdiff patch (gzipped) size: 2,989,691 bytes [2.85MB]

Estimated download size for updates from the old APK,
 using File-by-File:
   File-by-File patch (gzipped) size: 1,912,751 bytes [1.82MB]

 

來自:https://blog.dreamtobe.cn/android-toolset/

 

 本文由用戶 rockcy1992 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!