2017-01-18 23 views
2

我已經測試我的應用程序在多個設備上應用崩潰共享時使用調試模式

測試時工作正常

果凍豆,奇巧,棒棒糖,棉花糖

直接從我的應用程序使用的調試和也從一個手機共享到另一個手機。

它以兩種方式工作絕對沒在所有手機(不包括一個)

我有一個奇巧(4.4.4)摩托3G手機中應用程序工作正常在其他設備,但當我分享這個應用程序並運行時,應用程序在打開之前崩潰

不知道該怎麼辦,因爲我不知道可能是因爲運行使用USB調試運行正常。

我的搖籃構建

android { 
    compileSdkVersion 24 
    buildToolsVersion "25.0.1" 

    defaultConfig { 
     applicationId "com.abc.xyz" 
     minSdkVersion 16 
     targetSdkVersion 24 

    } 
    buildTypes { 

     debug { 
      minifyEnabled true 
     } 
     release { 
      shrinkResources true 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 
        'proguard-rules.pro' 
     } 
    } 

} 
+0

發佈錯誤日誌... –

+0

@Divyesh嗨Divyesh但錯誤日誌從哪裏? – SamH67

+0

@Divyesh應用程序與USB調試運行良好,但共享時崩潰,所以我想我不知道在哪裏會產生錯誤,因爲我不知道apk錯誤日誌在移動.....和在第一個活動的onCreate我想我不會調用任何API也會產生一個錯誤,如果我在一個不同的網絡,其中的API是在應用程序中添加分析服務 – SamH67

回答

1

我也遇到過這個問題,我能找到的唯一工作解決方案是從android studio中的設置中禁用instant run。然後做一個乾淨的構建並生成一個新的app-debug.apk。分享這個apk與多個設備

+0

是的,這就是我想要的即時運行顯示後,我最近升級我的工作室........但仍崩潰報告是重要的實施...... – SamH67

+0

安裝apk,然後插入kitkat手機PC然後你可以得到logcat崩潰報告 – Nilabja

+0

好吧,它的工作,你知道我必須從我的gra除去調試{minifyEnable true},因爲有一些錯誤,當我使用即時運行,然後這個調試沒有造成任何問題.....不知道發生了什麼 – SamH67

0

這不是直接的解決方案玩具你的問題,但它會幫助你找到你的應用程序的任何崩潰的解決方案。

添加CustomExceptionHandler類將寫在應用

public class CustomExceptionHandler implements UncaughtExceptionHandler { 

private UncaughtExceptionHandler defaultUEH; 

private String localPath; 

private String url; 

/* 
* if any of the parameters is null, the respective functionality 
* will not be used 
*/ 
public CustomExceptionHandler(String localPath) { 
    this.localPath = localPath; 
    this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler(); 
} 

public void uncaughtException(Thread t, Throwable e) { 
    String timestamp = TimestampFormatter.getInstance().getTimestamp(); 
    final Writer result = new StringWriter(); 
    final PrintWriter printWriter = new PrintWriter(result); 
    e.printStackTrace(printWriter); 
    String stacktrace = result.toString(); 
    printWriter.close(); 
    String filename = timestamp + ".stacktrace"; 

    if (localPath != null) { 
     writeToFile(stacktrace, filename); 
    } 


    defaultUEH.uncaughtException(t, e); 
} 

private void writeToFile(String stacktrace, String filename) { 
    try { 
     BufferedWriter bos = new BufferedWriter(new FileWriter(
       localPath + "/" + filename)); 
     bos.write(stacktrace); 
     bos.flush(); 
     bos.close(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 

} 

登錄任何崩潰,並在mainActivity

if(!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) { 
Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(
     "/sdcard/<desired_local_path>")); 
} 

希望這將幫助你添加此代碼...!

+0

和我在哪裏可以看到這個應用程序日誌 - > sdcard/「,」http:// /upload.php「 – SamH67

+0

這將做什麼請詳細說明Thread.setDefaultUncaughtExceptionHandler(新的CustomExceptionHandler( 」/ sdcard/「,」http:// /upload.php「)); – SamH67

+0

這意味着,日誌文件生成並將其發送到php文件服務器 –

相關問題