1

私は数年前に私が開発したAndroidアプリを持っています。それはまだPlayストアにあり、私はEclipseと古いAndroid開発ツール(私はAndroidスタジオを使用したことがない)で小さなバグを修正して更新しています。AsyncTaskクラッシュを修正できません:PendingIntentまたはSSL接続またはその他の原因?

私の最初の起動時のアプリケーションは、サーバーからデータをダウンロードし、内部データベースに保存します(私はAyncTaskを使用しました。ソースコードはhttps://pastebin.com/cKqXNYxmです)。すべての携帯電話でうまくいきます。

一部の携帯電話ではダウンロードが失敗し、ユーザーはアプリを使用できません。 私はこれらの電話機の1つを取得し、何が起こるかを見るためにLogCatに接続しました。ここでは、ログは次のとおりです。

04-04 21:07:50.238: I/CastMediaRouteProvider(2082): in onDiscoveryRequestChanged: request=DiscoveryRequest{ selector=MediaRouteSelector{ controlCategories=[android.media.intent.category.LIVE_VIDEO, android.media.intent.category.REMOTE_PLAYBACK, com.google.android.gms.cast.CATEGORY_CAST/08FF1091, com.google.android.gms.cast.CATEGORY_CAST/4574A331] }, activeScan=false, isValid=true } 
04-04 21:07:50.251: W/CastMediaRouteProvider(2082): Not a Cast compatible category: android.media.intent.category.LIVE_VIDEO 
04-04 21:07:50.251: I/CastMediaRouteProvider(2082): Logging initial network connection state. 
04-04 21:07:50.347: I/CastMediaRouteProvider(2082): Network connectivity changed 
04-04 21:07:50.372: I/DeviceScanner(2082): [MDNS] Filter criteria: 08FF1091,CC1AD845,4574A331 
04-04 21:07:50.372: I/DeviceScanner(2082): [MDNS] updateScannerState: No filter criteria was added. 
04-04 21:07:50.372: I/DeviceScanner(2082): [MDNS] updateScannerState: No filter criteria was removed. 
04-04 21:07:50.479: W/MdnsClient_Cast(2082): #acquireLock. Multicast lock not held. Acquiring. Subtypes:"4574A331,CC1AD845,08FF1091" 
04-04 21:07:50.501: I/DeviceScanner(2082): [CastNearby] Filter criteria: 08FF1091,CC1AD845,4574A331 
04-04 21:07:50.501: I/DeviceScanner(2082): [CastNearby] updateScannerState: No filter criteria was added. 
04-04 21:07:50.501: I/DeviceScanner(2082): [CastNearby] updateScannerState: No filter criteria was removed. 
04-04 21:08:08.860: W/IcingInternalCorpora(2082): getNumBytesRead when not calculated. 
04-04 21:08:09.020: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:08:09.063: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:08:09.085: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:08:09.100: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:08:09.135: W/IcingInternalCorpora(2082): getNumBytesRead when not calculated. 
04-04 21:08:09.265: I/art(1879): Background sticky concurrent mark sweep GC freed 49907(2MB) AllocSpace objects, 18(288KB) LOS objects, 11% free, 22MB/26MB, paused 7.887ms total 67.577ms 
04-04 21:08:10.048: I/Icing(2082): Indexing 26F5DFBF7CB0FE13B1ED2D2D8BA3F397144A57D1 from com.google.android.gms 
04-04 21:08:10.078: W/Icing(2082): CLD2 bad utf8 
04-04 21:08:10.114: I/Icing(2082): Indexing done 26F5DFBF7CB0FE13B1ED2D2D8BA3F397144A57D1 
04-04 21:08:10.546: I/WearableService(1879): Wear is not allowed to run on this device. Not starting Wear service. 
04-04 21:08:10.547: D/WearableService(1879): callingUid 10020, callindPid: 1879 
04-04 21:08:23.830: I/CastMediaRouteProvider(2082): in onDiscoveryRequestChanged: request=null 
04-04 21:08:23.840: W/MdnsClient_Cast(2082): Multicast lock held. Releasing. Subtypes:"4574A331,CC1AD845,08FF1091" 
04-04 21:08:23.872: W/MdnsClient(2082): unicast receiver thread is already dead. 
04-04 21:09:06.643: W/IcingInternalCorpora(2082): getNumBytesRead when not calculated. 
04-04 21:09:06.814: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:09:06.848: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:09:06.881: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:09:06.898: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:09:06.958: W/IcingInternalCorpora(2082): getNumBytesRead when not calculated. 
04-04 21:09:07.841: I/Icing(2082): Indexing 26F5DFBF7CB0FE13B1ED2D2D8BA3F397144A57D1 from com.google.android.gms 
04-04 21:09:07.864: W/Icing(2082): CLD2 bad utf8 
04-04 21:09:07.876: I/Icing(2082): Indexing done 26F5DFBF7CB0FE13B1ED2D2D8BA3F397144A57D1 
04-04 21:09:43.012: W/GCoreFlp(1879): No location to return for getLastLocation() 
04-04 21:09:51.519: W/IcingInternalCorpora(2082): getNumBytesRead when not calculated. 
04-04 21:09:51.629: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:09:51.674: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:09:51.712: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:09:51.767: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:09:51.826: W/IcingInternalCorpora(2082): getNumBytesRead when not calculated. 
04-04 21:09:52.662: I/Icing(2082): Indexing 26F5DFBF7CB0FE13B1ED2D2D8BA3F397144A57D1 from com.google.android.gms 
04-04 21:09:52.682: W/Icing(2082): CLD2 bad utf8 
04-04 21:09:52.699: I/Icing(2082): Indexing done 26F5DFBF7CB0FE13B1ED2D2D8BA3F397144A57D1 
04-04 21:11:36.806: D/BluetoothAdapter(1879): 341170672: getState() : mService = null. Returning STATE_OFF 
04-04 21:13:50.296: V/NativeCrypto(1879): Read error: ssl=0xb84d38c0: I/O error during system call, Connection reset by peer 
04-04 21:13:50.315: V/NativeCrypto(1879): SSL shutdown failed: ssl=0xb84d38c0: I/O error during system call, Broken pipe 
04-04 21:13:50.333: W/GCM(1879): Lowering wifi heartbeat interval 1 notch to 230000, good=0 bad=2 
04-04 21:18:17.073: D/BluetoothAdapter(1879): 341170672: getState() : mService = null. Returning STATE_OFF 
04-04 21:18:20.076: D/BluetoothAdapter(1879): 341170672: getState() : mService = null. Returning STATE_OFF 
04-04 21:18:20.528: I/Authzen(2082): [DeviceStateSyncManager] Device state fast sync is disabled 
04-04 21:18:20.581: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:18:20.582: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:18:20.582: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:18:20.582: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:18:20.582: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:18:20.583: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:18:20.583: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:18:20.583: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:18:20.583: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:18:20.586: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:27:48.016: D/BluetoothAdapter(1879): 341170672: getState() : mService = null. Returning STATE_OFF 
04-04 21:29:01.013: D/BluetoothAdapter(1879): 341170672: getState() : mService = null. Returning STATE_OFF 
04-04 21:29:03.196: I/Authzen(2082): [DeviceStateSyncManager] Device state fast sync is disabled 
04-04 21:29:03.233: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:29:03.233: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:29:03.233: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:29:03.234: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:29:03.234: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:29:03.234: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:29:03.235: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:29:03.235: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:29:03.235: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:29:03.236: I/DeviceCache(2082): Unable to convert the the network interface's MAC Address to string. MAC address cannot be null. 
04-04 21:29:04.014: D/BluetoothAdapter(1879): 341170672: getState() : mService = null. Returning STATE_OFF 
04-04 21:29:10.297: W/GeofencerStateMachine(1879): Ignoring removeGeofence because network location is disabled. 
04-04 21:29:11.075: E/WorkSourceUtil(2082): Could not find package: it.myapp.app 
04-04 21:29:11.076: I/Icing(2082): doRemovePackageData it.myapp.app 
04-04 21:29:11.133: I/LocationSettingsChecker(2082): Removing dialog suppression flag for package it.myapp.app 
04-04 21:29:11.138: D/Wear_Controller(2082): Received broadcast action=android.intent.action.PACKAGE_REMOVED and uri=it.myapp.app 
04-04 21:29:11.295: E/NetworkScheduler.SR(1879): Invalid parameter app 
04-04 21:29:11.296: E/NetworkScheduler.SR(1879): Invalid package name : Perhaps you didn't include a PendingIntent in the extras? 
04-04 21:29:11.461: W/IcingInternalCorpora(2082): getNumBytesRead when not calculated. 
04-04 21:29:11.467: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:29:11.475: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:29:12.207: I/WearableService(1879): Wear is not allowed to run on this device. Not starting Wear service. 
04-04 21:29:12.207: D/WearableService(1879): callingUid 10020, callindPid: 1879 
04-04 21:29:12.482: I/Icing(2082): Indexing 11154CFA753891357620E30C887251401ECA34E6 from com.google.android.gms 
04-04 21:29:12.517: I/Icing(2082): Indexing done 11154CFA753891357620E30C887251401ECA34E6 
04-04 21:29:18.135: W/PlatformStatsUtil(2082): Could not retrieve Usage & Diagnostics setting. Giving up. 
04-04 21:29:22.585: E/NetworkScheduler.SR(1879): Invalid parameter app 
04-04 21:29:22.585: E/NetworkScheduler.SR(1879): Invalid package name : Perhaps you didn't include a PendingIntent in the extras? 
04-04 21:29:22.605: I/iu.Environment(2082): update battery state; isPlugged? true* 
04-04 21:29:22.660: I/iu.FingerprintManager(2082): Start processing all media 
04-04 21:29:22.870: I/iu.FingerprintManager(2082): Start processing media store URI: content://media/external/images/media 
04-04 21:29:22.980: I/iu.UploadsManager(2082): num queued entries: 0 
04-04 21:29:23.041: I/iu.UploadsManager(2082): num updated entries: 0 
04-04 21:29:23.086: W/SQLiteConnectionPool(2082): A SQLiteConnection object for database '/data/data/com.google.android.gms/databases/auto_complete_suggestions.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed. 
04-04 21:29:23.091: W/SQLiteConnectionPool(2082): A SQLiteConnection object for database '/data/data/com.google.android.gms/databases/help_responses.db.18' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed. 
04-04 21:29:23.094: W/SQLiteConnectionPool(2082): A SQLiteConnection object for database '/data/data/com.google.android.gms/databases/metrics.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed. 
04-04 21:29:23.107: I/iu.SyncManager(2082): NEXT; no task 
04-04 21:29:23.171: W/PlatformStatsUtil(2082): Could not retrieve Usage & Diagnostics setting. Giving up. 
04-04 21:29:23.208: I/iu.FingerprintManager(2082): Start processing media store URI: content://media/external/video/media 
04-04 21:29:23.214: I/iu.FingerprintManager(2082): Start processing media store URI: content://media/phoneStorage/images/media 
04-04 21:29:23.216: I/iu.FingerprintManager(2082): Start processing media store URI: content://media/phoneStorage/video/media 
04-04 21:29:23.237: I/iu.FingerprintManager(2082): Finished generating fingerprints; 0,577 seconds 
04-04 21:29:23.238: I/iu.FingerprintManager(2082): numSeen=1872 numGenerated=3 numDeleted=11 numFailed=0 
04-04 21:29:33.041: W/PlatformStatsUtil(2082): Could not retrieve Usage & Diagnostics setting. Giving up. 
04-04 21:29:35.099: D/Wear_Controller(2082): Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=it.myapp.app 
04-04 21:29:35.251: I/WearableService(1879): Wear is not allowed to run on this device. Not starting Wear service. 
04-04 21:29:35.254: D/WearableService(1879): callingUid 10020, callindPid: 1879 
04-04 21:29:35.279: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:29:35.295: I/Icing(2082): Usage reports 0 indexed 0 rejected 0 imm upload false 
04-04 21:29:35.320: W/IcingInternalCorpora(2082): getNumBytesRead when not calculated. 
04-04 21:29:36.306: I/Icing(2082): Indexing 11154CFA753891357620E30C887251401ECA34E6 from com.google.android.gms 
04-04 21:29:36.402: I/Icing(2082): Indexing done 11154CFA753891357620E30C887251401ECA34E6 
04-04 21:29:40.870: W/PlatformStatsUtil(2082): Could not retrieve Usage & Diagnostics setting. Giving up. 

私は、問題は、これらのメッセージかもしれないと思う:

04-04 21:29:11.295: E/NetworkScheduler.SR(1879): Invalid parameter app 
04-04 21:29:11.296: E/NetworkScheduler.SR(1879): Invalid package name : Perhaps you didn't include a PendingIntent in the extras? 

...または多分SSL接続に関連したものになることができます:

04-04 21:13:50.296: V/NativeCrypto(1879): Read error: ssl=0xb84d38c0: I/O error during system call, Connection reset by peer 
04-04 21:13:50.315: V/NativeCrypto(1879): SSL shutdown failed: ssl=0xb84d38c0: I/O error during system call, Broken pipe 

私ができます何が問題になるのか理解していない。私はいくつかのデバイスを試してみましたが、ここでの結果である:

それは、次の携帯電話上で動作します:

  • 華為:6.0
  • サムスンA5:6.0.1
  • ワンプラス2:6.0.1
  • AsusのZenphone:6.1
  • ワンプラス:3 7.0
  • HTCワン:7.0

それは、次の電話の仕事(それはAsynTaskの実行中にクラッシュする)doens't:

  • サムスンS3ネオ4.4.2
  • Asusの5.0.2
  • サムスンS2 5.1.1
  • サムスンをネオ5.1.1

トラブルシューティングのためによく知っているもう1つのことは、約2か月前に私のホスト上でSSL証明書を有効にしたところです。

私はすでにこの問題について同様の質問を探していますが、何も助けてくれませんでした。 ほとんどの携帯電話でアプリは問題なく動作するため、Androidの古いバージョンではそのLogCatでクラッシュする理由がわかりません。何か案が?

+0

HttpsURLConnectionを使用していますか? – Ricardo

+0

私が付けたペーストビンに見られるように、私は 'DefaultHttpClient'を使います。どのように 'HttpsURLConnection'に切り替えることができますか?とにかくそれはなぜほとんどの携帯電話で動作しますか? – smartmouse

+0

私はHttpsURLConnectionを使用している電話機の中で、使用されているプロトコルのためにピアによって接続がリセットされるのと同様の問題がありました。ここを見てくださいhttp://stackoverflow.com/questions/26649389/how-to-disable-sslv3-in-android-for-httpsurlconnection – Ricardo

答えて

0

AsynTaskエラーの原因は、SSL接続でDefaultHttpClientを使用していることです。 Androidでは、APIレベル22以降、DefaultHttpClientを含むApacheモジュールは廃止されました。 doInBackgroundメソッドでコードを置き換えて問題を解決しました。前

@Override 
protected String doInBackground(String... urls) { 
    int timeout = 10; 
    int i, count = 0; 

    BasicHttpParams basicParams = new BasicHttpParams(); 
    HttpConnectionParams.setConnectionTimeout(basicParams, timeout * 1000); 
    HttpConnectionParams.setSoTimeout(basicParams, timeout * 1000); 
    DefaultHttpClient client = new DefaultHttpClient(basicParams); 

    StringBuilder stringBuilder = new StringBuilder(); 
    for (i = 0; i < urls.length; i++) { 
     HttpGet request = new HttpGet(urls[i]); 
     request.addHeader("Cache-Control", "no-cache"); 

     try { 
      HttpResponse response = client.execute(request); 
      HttpEntity entity = response.getEntity(); 
      InputStreamReader in = new InputStreamReader(entity.getContent()); 
      BufferedReader reader = new BufferedReader(in); 
      String line = ""; 

      while ((line = reader.readLine()) != null) { 
       stringBuilder.append(line); 

       count++; 
      } 
     } catch (Exception e) { 
      e.printStackTrace(); 
      return null; 
     } 
     publishProgress(count * 100/urls.length); 
    } 

    return stringBuilder.toString(); 
} 

後:このanswer

public static final int CONNECTON_TIMEOUT_MILLISECONDS = 60000; 

@Override 
protected String doInBackground(String... urls) { 
    int i, count = 0; 
    String urlsString = ""; 

    for (i = 0; i < urls.length; i++) { 
     try { 
      urlsString += executeGetHttpRequest(urls[i]); 
     } catch (IOException e) { 
      e.printStackTrace(); 
      return null; 
     }     
     count++; 

     publishProgress(count * 100/urls.length); 
    } 
    return urlsString; 
} 

public static String executeGetHttpRequest(final String path) throws ClientProtocolException, IOException { 
    String result = null; 
    HttpURLConnection urlConnection = null; 
    try { 
     URL url = new URL(path); 
     urlConnection = (HttpURLConnection) url.openConnection(); 
     urlConnection.setConnectTimeout(CONNECTON_TIMEOUT_MILLISECONDS); 
     urlConnection.setReadTimeout(CONNECTON_TIMEOUT_MILLISECONDS); 
     result = readStream(urlConnection.getInputStream()); 
    } finally { 
     if (urlConnection != null) { 
      urlConnection.disconnect(); 
     } 
    } 
    return result; 
} 

private static String readStream(InputStream is) throws IOException { 
    final BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); 
    StringBuilder total = new StringBuilder(); 
    String line; 
    while ((line = reader.readLine()) != null) { 
     total.append(line); 
    } 
    if (reader != null) { 
     reader.close(); 
    } 
    return total.toString(); 
} 

感謝。

上記のコードは、GETリクエストに関するものです。私はこのanswerのおかげでPOSTリクエストの場合にAsyncTaskの問題も解決しました。

関連する問題