1. 程式人生 > >Android bug日誌/錯誤收集

Android bug日誌/錯誤收集

bug 收集

1. Fatal signal 11 (SIGSEGV), code 2, fault addr 0x7f674fb000 in tid -8665652 (

高併發下使用context 導致的 具體原因不明白
解決辦法 使用context的方法 加 synchronized
```
  public synchronized static byte[] drawable2Byte(Context context, int tile_2) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.tile_2);
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);

    byte data[] =baos.toByteArray();
    bitmap.recycle();
    try {
        if (baos != null)
            baos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return data;
}

```

2. Android 錯誤無法debug 執行

Cannot debug application xx.xxx.xxx.app on device huawei-huawei_g7_tl00.

This application does not have the debuggable attribute enabled in its manifest.

If you have manually set it in the manifest, then remove it and let the IDE automatically assign it.

If you are using Gradle, make sure that your current variant is debuggable.
這裡寫圖片描述

3. Instant Run requires ‘Tools | Android | Enable ADB integration’ to be enabled.

錯誤: Instant Run requires ‘Tools | Android | Enable ADB integration’ to be enabled.
這裡寫圖片描述

4. Android studio 無法更新程式碼 AssertionError: null

android studio 在更新SVN 出現
AssertionError: null
在檔案目錄下 更新程式碼出現
Error: Please execute the ‘Cleanup’ command.
只要在 Cleanup 下 就可以更新了

5. Android 錯誤Error:Execution failed for task ‘:app:preDexDebug’.

Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_60\bin\java.exe'' finished with non-zero exit value 1

原因

sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }}

這個問題有很多問題導致的 有可能重啟下studio 就好了

6. Process ‘command ‘G:\android-sdk-windows\build-tools\20.0.0\aapt.exe’’ finished with non-zero exit v

  1. 暫時發現targetSdkVersion 要和supoport 相同 就是supoport 版本 不能高於 targetSdkVersion
  2. 查詢是否有包衝突
  3. 在build.gradle 中 android 欄位裡新增
dexOptions {
    javaMaxHeapSize "4g"
    preDexLibraries = false
}
  • did you try to to “Build”-> “Clean Project” and then go to “Build” -> “Rebuild Project”

7.Android Studio升級3.1.2

org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/2.3.3/gradle-2.3.3.pom'. Received status code 405 from server: Method Not Allowed

刪除.gradle 資料夾

8. Recycyle 滑動到最後一項

 Called removeDetachedView with a view which is not flagged as tmp detached.ViewHolder{277104a position=3 id=-1, oldPos=-1, pLpos:-1} android.support.v7.widget.RecyclerView{6e4abbb VFED..... ......ID 0,0-1080,768 #7f09025f app:id/rc_chat}, adapter:[email protected], layout:[email protected], context:[email protected]

原因 使用

                mRcChat.scrollToPosition(mChatAdapter.getItemCount() - 1);

解決 替換成

                        mRcChat.smoothScrollToPosition(mChatAdapter.getItemCount() - 1);

9. Glide載入長圖時 圓角無效

原因

                        getRoundRequestOptions().transform(new RoundedCorners(radius)).centerCrop()

解決

  /**
     * @param url
     * @param imageView
     * @param radius    圓角  單位 px
     */
    public static void withRound2PX(String url, ImageView imageView, int radius) {
        if (checkFinish(imageView)) {
            return;
        }
        GlideApp.with(imageView)
                .load(url)
                .apply(
                        getRoundRequestOptions().transforms(new CenterCrop(),new RoundedCorners(radius))
                )
                .into(imageView);
    }

transforms 是可以設定 順序 順序 順序的
參考 https://blog.csdn.net/qq_19269585/article/details/80968147