Android开发周边

rockcy1992 8年前
   <p><a href="/misc/goto?guid=4958966068485916030" rel="nofollow,noindex">dryrun</a></p>    <p>通过 dryrun 可以简单的通过一个github中的地址,就直接将项目运行到手机上。</p>    <h3>2. 检索引用</h3>    <p><a href="/misc/goto?guid=4958961794120015128" rel="nofollow,noindex">alfi</a></p>    <p>可以快速检索需要引用库的 jcenter 与 maven central 的引用代码。</p>    <h3>3. 快速反编译</h3>    <p><a href="/misc/goto?guid=4959741814728288000" rel="nofollow,noindex">反编译</a></p>    <p>很便捷的反编译工具,可对dex文件直接反编译打开: jadx-gui classes.dex 。</p>    <h3>4. 图片压缩</h3>    <p>除了在CI系统上保持对资源变化的持续监控(对大多数的Android应用而言,资源往往是Apk大小的主要根源之一),</p>    <ul>     <li><a href="/misc/goto?guid=4958839376838658884" rel="nofollow,noindex">Pngyu</a></li>     <li><a href="/misc/goto?guid=4958962522585251597" rel="nofollow,noindex">ImageOptim</a></li>    </ul>    <h2>II. gradle小技巧</h2>    <ul>     <li>通过 --offline ,离线编译,免去检测的网络耗时</li>     <li>通过 gradle --stop ,停止所有的gradle编译,包括IDE中的</li>     <li>需要配置分离api、impl包可以参考 <a href="/misc/goto?guid=4959741814884008006" rel="nofollow,noindex">gradle-sample</a></li>    </ul>    <h3>引用关系</h3>    <p>可以通过 ./gradlew dependencies 来查看最终的依赖关系。</p>    <p>如针对项目中的app module进行查看其引用关系: ./gradlew :app:dependencies 。</p>    <p style="text-align: center;"><img src="https://simg.open-open.com/show/1ef6f476c79848a70227260202d2699e.png"></p>    <p>需要特别注意的是</p>    <p>都是对相通库同类型的引用,如都是 testCompile ,或都是 compile ,那么Gradle会自动选择最高版本的:</p>    <pre>  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'  </pre>    <p style="text-align: center;"><img src="https://simg.open-open.com/show/f53179b7ac146769d0a970e5d1a3e4cc.png"></p>    <p>对相同库不同类型的引用时,此时会发生冲突:</p>    <pre>  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'  </pre>    <p style="text-align: center;"><img src="https://simg.open-open.com/show/2193ce2f8af5ca0577e911b3f3c89bab.png"></p>    <p>这个时候我们就要根据需要exclude掉冲突的版本,如我们只需要引用 okhttp 3.6.0 版本与 filedownloader 1.4.1 :</p>    <pre>  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'  </pre>    <h2>III. 编程工具</h2>    <h3>1. 耗时日志</h3>    <p>hugo</p>    <p><a href="/misc/goto?guid=4958866344171193400" rel="nofollow,noindex">hugo</a></p>    <p>轻松给方法添加耗时日志:</p>    <pre>  @DebugLog  publicStringgetName(String first, String last){/* ... */}  </pre>    <p>输出日志:</p>    <pre>  V/Example: --> getName(first="Jake", last="Wharton")  V/Example: <-- getName [16ms] = "Jake Wharton"  </pre>    <p>Pury</p>    <p><a href="/misc/goto?guid=4959741815010556712" rel="nofollow,noindex">Pury</a></p>    <p>统计事件之间的耗时:</p>    <pre>  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  </pre>    <h3>2. 日志着色</h3>    <p><a href="/misc/goto?guid=4959550704924680482" rel="nofollow,noindex">pidcat</a></p>    <p style="text-align: center;"><img src="https://simg.open-open.com/show/e45a8f5168306463e0642fc73d594e48.png"></p>    <h3>3. 项目License配置</h3>    <p>基于Android Studio的Copyright功能</p>    <p>第一步. 在Copyright Profiles中添加license</p>    <p style="text-align: center;"><img src="https://simg.open-open.com/show/72e237fb1a7dbc4e734326f95e5a4096.png" alt="Android开发周边" width="1032" height="359"></p>    <p>第二步. 在Copyright中配置项目默认的license</p>    <p style="text-align: center;"><img src="https://simg.open-open.com/show/c5b41b9fc18a093fc40dfd81bbfbb7d1.png"></p>    <p>至此,默认创建的文件就顶部就会申明license,并且可以对文件一件添加license</p>    <p style="text-align: center;"><img src="https://simg.open-open.com/show/9b1b4a8dd90e96223e712ed19574667b.png"></p>    <p>当然如果需要特殊配置针对不同语言文件license格式等配置,可以在Formatting下面进一步配置。</p>    <h3>4. 查看依赖库方法数</h3>    <p><a href="/misc/goto?guid=4958973753923044568" rel="nofollow,noindex">Methods Count</a></p>    <p style="text-align: center;"><img src="https://simg.open-open.com/show/a9361bfdb9eb7afd2bdae4f2ee084900.png"></p>    <h3>5. UI生成器</h3>    <ul>     <li><a href="/misc/goto?guid=4959555277910092632" rel="nofollow,noindex">Icon/styles genrator</a></li>     <li><a href="/misc/goto?guid=4958971640576509411" rel="nofollow,noindex">Material design icons</a></li>    </ul>    <p>除了上面两个,也可以使用Android Studio自带的:</p>    <p style="text-align: center;"><img src="https://simg.open-open.com/show/a7d1511d3703967fd4f434cb286ad982.png"></p>    <h3>6. 包大小跟踪与对比</h3>    <p>包大小跟踪</p>    <p><a href="/misc/goto?guid=4959672736872161420" rel="nofollow,noindex">APK patch size estimator</a></p>    <p>谷歌官方提供的Google Play差分包大小,也可以做简单的文件大小变更大小对比,可以集成到CI中持续跟踪包大小变化,也可以简单的对比两个包的大小:</p>    <pre>  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]  </pre>    <p> </p>    <p>来自:https://blog.dreamtobe.cn/android-toolset/</p>    <p> </p>