2016-05-30 64 views
1

我的應用發佈了很長時間。現在我正在進行更新,當我將我的谷歌播放服務更新到9.0.1時,我的應用在每次啓動時都會繼續顯示ANR狀態,並向我展示完整的空白屏幕。 我所做的只是添加了更新所需的新依賴項。 這裏是build.gradle文件應用程序:更新至Google Play服務9.0.1後的每次發佈ANR Android

apply plugin: 'com.android.application'android { 
compileSdkVersion 23 
buildToolsVersion "23.0.2" 
defaultConfig { 
    applicationId 'xxxxxxxxxxxxxxxxxxxxxx' 
    minSdkVersion 14 
    targetSdkVersion 23 
    versionCode 1 
    versionName "5.2" 
    ndk { 
     moduleName "Constants" 
    } 
    sourceSets.main { 
     jni.srcDirs = [] 
     jniLibs.srcDir "src/main/libs" 
    } 
} 
buildTypes { 
    release { 
     minifyEnabled true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
}}dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:appcompat-v7:23.4.0' 
compile 'com.android.support:design:23.4.0' 
compile 'com.mcxiaoke.volley:library:1.0.18' 
compile 'com.android.support:cardview-v7:23.4.0' 
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' 
compile 'com.android.support:support-v4:23.4.0' 
compile 'com.google.android.gms:play-services-gcm:9.0.1' 
compile 'com.google.android.gms:play-services-ads:9.0.1' 
compile 'com.devbrackets.android:exomedia:2.5.6' 
compile 'com.google.android.gms:play-services-analytics:9.0.1'}apply plugin: 'com.google.gms.google-services' 

這裏是應用層面build.gradle

buildscript { 
repositories { 
    jcenter() 
} 
dependencies { 
    classpath 'com.android.tools.build:gradle:2.1.0' 
    classpath 'com.google.gms:google-services:3.0.0' 
}}allprojects { 
repositories { 
    jcenter() 
} 
}task clean(type: Delete) { 
delete rootProject.buildDir 
} 

和日誌中顯示沒有錯誤。任何人都可以幫助我解決這個問題嗎? Thankyou。

回答

0

好了,我在我的本地代碼中導致ANR狀態的錯誤。

0

由於日誌顯示沒有錯誤,ANR可能是由主線程中的長操作或稱爲UI線程導致的。由於UI線程被阻止,您的應用程序無法處理其他用戶交互。您可以做的解決方案是在工作線程中執行繁重的操作以釋放UI線程。

Threads提到:

當線程被阻塞,沒有事件可以被分派,包括拉伸的事件。從用戶的角度來看,應用程序似乎掛起。更糟糕的是,如果UI線程被阻塞超過幾秒(目前約5秒),用戶將看到臭名昭着的「應用程序無響應」(ANR)對話框。

此外,

這是您的應用程序的UI,你不會阻塞UI線程響應是至關重要的。如果您有要執行的操作不是即時的,則應確保在單獨的線程(「後臺」或「工作者」線程)中執行操作。

文檔中進一步討論了幾種從其他線程訪問UI線程的方法,Android已經提供了這些線程來解決ANR問題。

+0

那麼它變成我的NDK代碼中的錯誤..它沒有顯示我在我的LogCat中,但調試後我發現它。但仍然感謝您的詳細解答。 – awaistoor

相關問題