论坛App_Code DataAccessHelper(2)

本文介绍了一个名为SQLString.cs的类,用于将文本转换为适用于SQL语句的字符串,通过使用静态方法GetQuotedString实现文本转换。

SQLString.cs

 

 

using System;

namespace MyBBS.DataAccessHelper
{
 /// <summary>
 /// SQLString 的摘要说明。
 /// </summary>
 public class SqlStringFormat
 {
  /// <summary>
  /// 公有静态方法,将文本转换成适合在Sql语句里使用的字符串。
  /// </summary>
  /// <returns>转换后文本</returns> 
  public static String GetQuotedString(String pStr)
  {
   return ("'" + pStr.Replace("'","''") + "'");
  }
 }
}

 

/* ESP HTTP Client Example This example code is in the Public Domain (or CC0 licensed, at your option.) Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include <string.h> #include <sys/param.h> #include <stdlib.h> #include <ctype.h> #include "esp_log.h" #include "nvs_flash.h" #include "esp_event.h" #include "esp_netif.h" #include "protocol_examples_common.h" #include "protocol_examples_utils.h" #include "esp_tls.h" #if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE #include "esp_crt_bundle.h" #endif #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_system.h" #include "esp_http_client.h" #define MAX_HTTP_RECV_BUFFER 512 #define MAX_HTTP_OUTPUT_BUFFER 2048 static const char *TAG = "HTTP_CLIENT"; /* Root cert for howsmyssl.com, taken from howsmyssl_com_root_cert.pem The PEM file was extracted from the output of this command: openssl s_client -showcerts -connect www.howsmyssl.com:443 </dev/null The CA root cert is the last cert given in the chain of certs. To embed it in the app binary, the PEM file is named in the component.mk COMPONENT_EMBED_TXTFILES variable. */ extern const char howsmyssl_com_root_cert_pem_start[] asm("_binary_howsmyssl_com_root_cert_pem_start"); extern const char howsmyssl_com_root_cert_pem_end[] asm("_binary_howsmyssl_com_root_cert_pem_end"); esp_err_t _http_event_handler(esp_http_client_event_t *evt) { static char *output_buffer; // Buffer to store response of http request from event handler static int output_len; // Stores number of bytes read switch(evt->event_id) { case HTTP_EVENT_ERROR: ESP_LOGD(TAG, "HTTP_EVENT_ERROR"); break; case HTTP_EVENT_ON_CONNECTED: ESP_LOGD(TAG, "HTTP_EVENT_ON_CONNECTED"); break; case HTTP_EVENT_HEADER_SENT: ESP_LOGD(TAG, "HTTP_EVENT_HEADER_SENT"); break; case HTTP_EVENT_ON_HEADER: ESP_LOGD(TAG, "HTTP_EVENT_ON_HEADER, key=%s, value=%s", evt->header_key, evt->header_value); break; case HTTP_EVENT_ON_DATA: ESP_LOGD(TAG, "HTTP_EVENT_ON_DATA, len=%d", evt->data_len); // Clean the buffer in case of a new request if (output_len == 0 && evt->user_data) { // we are just starting to copy the output data into the use memset(evt->user_data, 0, MAX_HTTP_OUTPUT_BUFFER); } /* * Check for chunked encoding is added as the URL for chunked encoding used in this example returns binary data. * However, event handler can also be used in case chunked encoding is used. */ if (!esp_http_client_is_chunked_response(evt->client)) { // If user_data buffer is configured, copy the response into the buffer int copy_len = 0; if (evt->user_data) { // The last byte in evt->user_data is kept for the NULL character in case of out-of-bound access. copy_len = MIN(evt->data_len, (MAX_HTTP_OUTPUT_BUFFER - output_len)); if (copy_len) { memcpy(evt->user_data + output_len, evt->data, copy_len); } } else { int content_len = esp_http_client_get_content_length(evt->client); if (output_buffer == NULL) { // We initialize output_buffer with 0 because it is used by strlen() and similar functions therefore should be null terminated. output_buffer = (char *) calloc(content_len + 1, sizeof(char)); output_len = 0; if (output_buffer == NULL) { ESP_LOGE(TAG, "Failed to allocate memory for output buffer"); return ESP_FAIL; } } copy_len = MIN(evt->data_len, (content_len - output_len)); if (copy_len) { memcpy(output_buffer + output_len, evt->data, copy_len); } } output_len += copy_len; } break; case HTTP_EVENT_ON_FINISH: ESP_LOGD(TAG, "HTTP_EVENT_ON_FINISH"); if (output_buffer != NULL) { #if CONFIG_EXAMPLE_ENABLE_RESPONSE_BUFFER_DUMP ESP_LOG_BUFFER_HEX(TAG, output_buffer, output_len); #endif free(output_buffer); output_buffer = NULL; } output_len = 0; break; case HTTP_EVENT_DISCONNECTED: ESP_LOGI(TAG, "HTTP_EVENT_DISCONNECTED"); int mbedtls_err = 0; esp_err_t err = esp_tls_get_and_clear_last_error((esp_tls_error_handle_t)evt->data, &mbedtls_err, NULL); if (err != 0) { ESP_LOGI(TAG, "Last esp error code: 0x%x", err); ESP_LOGI(TAG, "Last mbedtls failure: 0x%x", mbedtls_err); } if (output_buffer != NULL) { free(output_buffer); output_buffer = NULL; } output_len = 0; break; case HTTP_EVENT_REDIRECT: ESP_LOGD(TAG, "HTTP_EVENT_REDIRECT"); esp_http_client_set_header(evt->client, "From", "user@example.com"); esp_http_client_set_header(evt->client, "Accept", "text/html"); esp_http_client_set_redirection(evt->client); break; } return ESP_OK; } static void http_rest_with_url(void) { // Declare local_response_buffer with size (MAX_HTTP_OUTPUT_BUFFER + 1) to prevent out of bound access when // it is used by functions like strlen(). The buffer should only be used upto size MAX_HTTP_OUTPUT_BUFFER char local_response_buffer[MAX_HTTP_OUTPUT_BUFFER + 1] = {0}; /** * NOTE: All the configuration parameters for http_client must be specified either in URL or as host and path parameters. * If host and path parameters are not set, query parameter will be ignored. In such cases, * query parameter should be specified in URL. * * If URL as well as host and path parameters are specified, values of host and path will be considered. */ esp_http_client_config_t config = { .host = CONFIG_EXAMPLE_HTTP_ENDPOINT, .path = "/get", .query = "esp", .event_handler = _http_event_handler, .user_data = local_response_buffer, // Pass address of local buffer to get response .disable_auto_redirect = true, }; ESP_LOGI(TAG, "HTTP request with url =>"); esp_http_client_handle_t client = esp_http_client_init(&config); // GET esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP GET Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP GET request failed: %s", esp_err_to_name(err)); } ESP_LOG_BUFFER_HEX(TAG, local_response_buffer, strlen(local_response_buffer)); // POST const char *post_data = "{\"field1\":\"value1\"}"; esp_http_client_set_url(client, "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/post"); esp_http_client_set_method(client, HTTP_METHOD_POST); esp_http_client_set_header(client, "Content-Type", "application/json"); esp_http_client_set_post_field(client, post_data, strlen(post_data)); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP POST Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP POST request failed: %s", esp_err_to_name(err)); } //PUT esp_http_client_set_url(client, "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/put"); esp_http_client_set_method(client, HTTP_METHOD_PUT); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP PUT Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP PUT request failed: %s", esp_err_to_name(err)); } //PATCH esp_http_client_set_url(client, "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/patch"); esp_http_client_set_method(client, HTTP_METHOD_PATCH); esp_http_client_set_post_field(client, NULL, 0); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP PATCH Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP PATCH request failed: %s", esp_err_to_name(err)); } //DELETE esp_http_client_set_url(client, "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/delete"); esp_http_client_set_method(client, HTTP_METHOD_DELETE); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP DELETE Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP DELETE request failed: %s", esp_err_to_name(err)); } //HEAD esp_http_client_set_url(client, "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/get"); esp_http_client_set_method(client, HTTP_METHOD_HEAD); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP HEAD Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP HEAD request failed: %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } static void http_rest_with_hostname_path(void) { esp_http_client_config_t config = { .host = CONFIG_EXAMPLE_HTTP_ENDPOINT, .path = "/get", .transport_type = HTTP_TRANSPORT_OVER_TCP, .event_handler = _http_event_handler, }; ESP_LOGI(TAG, "HTTP request with hostname and path =>"); esp_http_client_handle_t client = esp_http_client_init(&config); // GET esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP GET Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP GET request failed: %s", esp_err_to_name(err)); } // POST const char *post_data = "field1=value1&field2=value2"; esp_http_client_set_url(client, "/post"); esp_http_client_set_method(client, HTTP_METHOD_POST); esp_http_client_set_post_field(client, post_data, strlen(post_data)); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP POST Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP POST request failed: %s", esp_err_to_name(err)); } //PUT esp_http_client_set_url(client, "/put"); esp_http_client_set_method(client, HTTP_METHOD_PUT); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP PUT Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP PUT request failed: %s", esp_err_to_name(err)); } //PATCH esp_http_client_set_url(client, "/patch"); esp_http_client_set_method(client, HTTP_METHOD_PATCH); esp_http_client_set_post_field(client, NULL, 0); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP PATCH Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP PATCH request failed: %s", esp_err_to_name(err)); } //DELETE esp_http_client_set_url(client, "/delete"); esp_http_client_set_method(client, HTTP_METHOD_DELETE); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP DELETE Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP DELETE request failed: %s", esp_err_to_name(err)); } //HEAD esp_http_client_set_url(client, "/get"); esp_http_client_set_method(client, HTTP_METHOD_HEAD); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP HEAD Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP HEAD request failed: %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } #if CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH static void http_auth_basic(void) { /** * Note: `max_authorization_retries` in esp_http_client_config_t * can be used to configure number of retry attempts to be performed * in case unauthorized status code is received. * * To disable authorization retries, set max_authorization_retries to -1. */ esp_http_client_config_t config = { .url = "http://user:passwd@"CONFIG_EXAMPLE_HTTP_ENDPOINT"/basic-auth/user/passwd", .event_handler = _http_event_handler, .auth_type = HTTP_AUTH_TYPE_BASIC, .max_authorization_retries = -1, }; ESP_LOGI(TAG, "HTTP Basic Auth request =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP Basic Auth Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } static void http_auth_basic_redirect(void) { esp_http_client_config_t config = { .url = "http://user:passwd@"CONFIG_EXAMPLE_HTTP_ENDPOINT"/basic-auth/user/passwd", .event_handler = _http_event_handler, }; ESP_LOGI(TAG, "HTTP Basic Auth redirect request =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP Basic Auth redirect Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } #endif #if CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH static void http_auth_digest_md5(void) { esp_http_client_config_t config = { .url = "http://user:passwd@"CONFIG_EXAMPLE_HTTP_ENDPOINT"/digest-auth/auth/user/passwd/MD5/never", .event_handler = _http_event_handler, }; ESP_LOGI(TAG, "HTTP MD5 Digest Auth request =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP MD5 Digest Auth Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error performing http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } static void http_auth_digest_sha256(void) { esp_http_client_config_t config = { .url = "http://user:passwd@"CONFIG_EXAMPLE_HTTP_ENDPOINT"/digest-auth/auth/user/passwd/SHA-256/never", .event_handler = _http_event_handler, .buffer_size_tx = 1024, // Increase buffer size as header size will increase as it contains SHA-256. }; ESP_LOGI(TAG, "HTTP SHA256 Digest Auth request =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP SHA256 Digest Auth Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error performing http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } #endif #if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE static void https_with_url(void) { esp_http_client_config_t config = { .url = "https://www.howsmyssl.com", .event_handler = _http_event_handler, .crt_bundle_attach = esp_crt_bundle_attach, }; ESP_LOGI(TAG, "HTTPS request with url =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTPS Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } #endif // CONFIG_MBEDTLS_CERTIFICATE_BUNDLE static void https_with_hostname_path(void) { esp_http_client_config_t config = { .host = "www.howsmyssl.com", .path = "/", .transport_type = HTTP_TRANSPORT_OVER_SSL, .event_handler = _http_event_handler, .cert_pem = howsmyssl_com_root_cert_pem_start, }; ESP_LOGI(TAG, "HTTPS request with hostname and path =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTPS Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } static void http_encoded_query(void) { esp_http_client_config_t config = { .host = CONFIG_EXAMPLE_HTTP_ENDPOINT, .path = "/get", .event_handler = _http_event_handler, }; ESP_LOGI(TAG, "HTTP GET request with encoded query =>"); static const char query_val[] = "ABC xyz!012@#%&"; char query_val_enc[64] = {0}; uint32_t enc_len = example_uri_encode(query_val_enc, query_val, strlen(query_val)); if (enc_len > 0) { ESP_LOG_BUFFER_HEXDUMP(TAG, query_val_enc, enc_len, ESP_LOG_DEBUG); config.query = query_val_enc; } esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP GET Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP GET request failed: %s", esp_err_to_name(err)); } } static void http_relative_redirect(void) { esp_http_client_config_t config = { .url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/relative-redirect/3", .event_handler = _http_event_handler, }; ESP_LOGI(TAG, "HTTP Relative path redirect request =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP Relative path redirect Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } static void http_absolute_redirect(void) { esp_http_client_config_t config = { .url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/absolute-redirect/3", .event_handler = _http_event_handler, }; ESP_LOGI(TAG, "HTTP Absolute path redirect request =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP Absolute path redirect Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } static void http_absolute_redirect_manual(void) { esp_http_client_config_t config = { .url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/absolute-redirect/3", .event_handler = _http_event_handler, .disable_auto_redirect = true, }; ESP_LOGI(TAG, "HTTP Absolute path redirect (manual) request =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP Absolute path redirect (manual) Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } static void http_redirect_to_https(void) { esp_http_client_config_t config = { .url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/redirect-to?url=https://www.howsmyssl.com", .event_handler = _http_event_handler, .cert_pem = howsmyssl_com_root_cert_pem_start, }; ESP_LOGI(TAG, "HTTP redirect to HTTPS request =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP redirect to HTTPS Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } static void http_download_chunk(void) { esp_http_client_config_t config = { .url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/stream-bytes/8912", .event_handler = _http_event_handler, }; ESP_LOGI(TAG, "HTTP chunk encoding request =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP chunk encoding Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } static void http_perform_as_stream_reader(void) { char *buffer = malloc(MAX_HTTP_RECV_BUFFER + 1); if (buffer == NULL) { ESP_LOGE(TAG, "Cannot malloc http receive buffer"); return; } esp_http_client_config_t config = { .url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/get", }; ESP_LOGI(TAG, "HTTP Stream reader request =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err; if ((err = esp_http_client_open(client, 0)) != ESP_OK) { ESP_LOGE(TAG, "Failed to open HTTP connection: %s", esp_err_to_name(err)); free(buffer); return; } int content_length = esp_http_client_fetch_headers(client); int total_read_len = 0, read_len; if (total_read_len < content_length && content_length <= MAX_HTTP_RECV_BUFFER) { read_len = esp_http_client_read(client, buffer, content_length); if (read_len <= 0) { ESP_LOGE(TAG, "Error read data"); } buffer[read_len] = 0; ESP_LOGD(TAG, "read_len = %d", read_len); } ESP_LOGI(TAG, "HTTP Stream reader Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); esp_http_client_close(client); esp_http_client_cleanup(client); free(buffer); } static void https_async(void) { esp_http_client_config_t config = { .url = "https://postman-echo.com/post", .event_handler = _http_event_handler, .crt_bundle_attach = esp_crt_bundle_attach, .is_async = true, .timeout_ms = 5000, }; ESP_LOGI(TAG, "HTTPS async requests =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err; const char *post_data = "Using a Palantír requires a person with great strength of will and wisdom. The Palantíri were meant to " "be used by the Dúnedain to communicate throughout the Realms in Exile. During the War of the Ring, " "the Palantíri were used by many individuals. Sauron used the Ithil-stone to take advantage of the users " "of the other two stones, the Orthanc-stone and Anor-stone, but was also susceptible to deception himself."; esp_http_client_set_method(client, HTTP_METHOD_POST); esp_http_client_set_post_field(client, post_data, strlen(post_data)); while (1) { err = esp_http_client_perform(client); if (err != ESP_ERR_HTTP_EAGAIN) { break; } } if (err == ESP_OK) { ESP_LOGI(TAG, "HTTPS Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); // Test HTTP_METHOD_HEAD with is_async enabled config.url = "https://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/get"; config.event_handler = _http_event_handler; config.crt_bundle_attach = esp_crt_bundle_attach; config.is_async = true; config.timeout_ms = 5000; client = esp_http_client_init(&config); esp_http_client_set_method(client, HTTP_METHOD_HEAD); while (1) { err = esp_http_client_perform(client); if (err != ESP_ERR_HTTP_EAGAIN) { break; } } if (err == ESP_OK) { ESP_LOGI(TAG, "HTTPS Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } static void https_with_invalid_url(void) { esp_http_client_config_t config = { .url = "https://not.existent.url", .event_handler = _http_event_handler, }; ESP_LOGI(TAG, "HTTPS request with invalid url =>"); esp_http_client_handle_t client = esp_http_client_init(&config); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTPS Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } /* * http_native_request() demonstrates use of low level APIs to connect to a server, * make a http request and read response. Event handler is not used in this case. * Note: This approach should only be used in case use of low level APIs is required. * The easiest way is to use esp_http_perform() */ static void http_native_request(void) { // Declare local_response_buffer with size (MAX_HTTP_OUTPUT_BUFFER + 1) to prevent out of bound access when // it is used by functions like strlen(). The buffer should only be used upto size MAX_HTTP_OUTPUT_BUFFER char output_buffer[MAX_HTTP_OUTPUT_BUFFER + 1] = {0}; // Buffer to store response of http request int content_length = 0; esp_http_client_config_t config = { .url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/get", }; ESP_LOGI(TAG, "HTTP native request =>"); esp_http_client_handle_t client = esp_http_client_init(&config); // GET Request esp_http_client_set_method(client, HTTP_METHOD_GET); esp_err_t err = esp_http_client_open(client, 0); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to open HTTP connection: %s", esp_err_to_name(err)); } else { content_length = esp_http_client_fetch_headers(client); if (content_length < 0) { ESP_LOGE(TAG, "HTTP client fetch headers failed"); } else { int data_read = esp_http_client_read_response(client, output_buffer, MAX_HTTP_OUTPUT_BUFFER); if (data_read >= 0) { ESP_LOGI(TAG, "HTTP GET Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); ESP_LOG_BUFFER_HEX(TAG, output_buffer, data_read); } else { ESP_LOGE(TAG, "Failed to read response"); } } } esp_http_client_close(client); // POST Request const char *post_data = "{\"field1\":\"value1\"}"; esp_http_client_set_url(client, "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/post"); esp_http_client_set_method(client, HTTP_METHOD_POST); esp_http_client_set_header(client, "Content-Type", "application/json"); err = esp_http_client_open(client, strlen(post_data)); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to open HTTP connection: %s", esp_err_to_name(err)); } else { int wlen = esp_http_client_write(client, post_data, strlen(post_data)); if (wlen < 0) { ESP_LOGE(TAG, "Write failed"); } content_length = esp_http_client_fetch_headers(client); if (content_length < 0) { ESP_LOGE(TAG, "HTTP client fetch headers failed"); } else { int data_read = esp_http_client_read_response(client, output_buffer, MAX_HTTP_OUTPUT_BUFFER); if (data_read >= 0) { ESP_LOGI(TAG, "HTTP POST Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); ESP_LOG_BUFFER_HEX(TAG, output_buffer, strlen(output_buffer)); } else { ESP_LOGE(TAG, "Failed to read response"); } } } esp_http_client_cleanup(client); } #if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE static void http_partial_download(void) { esp_http_client_config_t config = { .url = "https://dl.espressif.com/dl/esp-idf/ci/esp_http_client_demo.txt", .event_handler = _http_event_handler, .crt_bundle_attach = esp_crt_bundle_attach, }; ESP_LOGI(TAG, "HTTP partial download =>"); esp_http_client_handle_t client = esp_http_client_init(&config); // Download a file excluding first 10 bytes esp_http_client_set_header(client, "Range", "bytes=10-"); esp_err_t err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP request failed: %s", esp_err_to_name(err)); } // Download last 10 bytes of a file esp_http_client_set_header(client, "Range", "bytes=-10"); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP request failed: %s", esp_err_to_name(err)); } // Download 10 bytes from 11 to 20 esp_http_client_set_header(client, "Range", "bytes=11-20"); err = esp_http_client_perform(client); if (err == ESP_OK) { ESP_LOGI(TAG, "HTTP Status = %d, content_length = %"PRId64, esp_http_client_get_status_code(client), esp_http_client_get_content_length(client)); } else { ESP_LOGE(TAG, "HTTP request failed: %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); } #endif // CONFIG_MBEDTLS_CERTIFICATE_BUNDLE static void http_test_task(void *pvParameters) { http_rest_with_url(); http_rest_with_hostname_path(); #if CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH http_auth_basic(); http_auth_basic_redirect(); #endif #if CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH http_auth_digest_md5(); http_auth_digest_sha256(); #endif http_encoded_query(); http_relative_redirect(); http_absolute_redirect(); http_absolute_redirect_manual(); #if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE https_with_url(); #endif https_with_hostname_path(); http_redirect_to_https(); http_download_chunk(); http_perform_as_stream_reader(); https_async(); https_with_invalid_url(); http_native_request(); #if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE http_partial_download(); #endif ESP_LOGI(TAG, "Finish http example"); #if !CONFIG_IDF_TARGET_LINUX vTaskDelete(NULL); #endif } void app_main(void) { esp_err_t ret = nvs_flash_init(); if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { ESP_ERROR_CHECK(nvs_flash_erase()); ret = nvs_flash_init(); } ESP_ERROR_CHECK(ret); ESP_ERROR_CHECK(esp_netif_init()); ESP_ERROR_CHECK(esp_event_loop_create_default()); /* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig. * Read "Establishing Wi-Fi or Ethernet Connection" section in * examples/protocols/README.md for more information about this function. */ ESP_ERROR_CHECK(example_connect()); ESP_LOGI(TAG, "Connected to AP, begin http example"); #if CONFIG_IDF_TARGET_LINUX http_test_task(NULL); #else xTaskCreate(&http_test_task, "http_test_task", 8192, NULL, 5, NULL); #endif }解析该代码
11-01
2025-07-21 23:47:18.379 27369-27369 myapplication7 com.example.myapplication73 I Late-enabling -Xcheck:jni 2025-07-21 23:47:19.831 27369-27369 myapplication7 com.example.myapplication73 W Unexpected CPU variant for X86 using defaults: x86_64 2025-07-21 23:47:20.112 27369-27369 Compatibil...geReporter com.example.myapplication73 D Compat change id reported: 171979766; UID 10161; state: ENABLED 2025-07-21 23:47:20.383 27369-27369 GraphicsEnvironment com.example.myapplication73 V ANGLE Developer option for 'com.example.myapplication73' set to: 'default' 2025-07-21 23:47:20.385 27369-27369 GraphicsEnvironment com.example.myapplication73 V ANGLE GameManagerService for com.example.myapplication73: false 2025-07-21 23:47:20.386 27369-27369 GraphicsEnvironment com.example.myapplication73 V Neither updatable production driver nor prerelease driver is supported. 2025-07-21 23:47:20.404 27369-27369 NetworkSecurityConfig com.example.myapplication73 D No Network Security Config specified, using platform default 2025-07-21 23:47:20.407 27369-27369 NetworkSecurityConfig com.example.myapplication73 D No Network Security Config specified, using platform default 2025-07-21 23:47:20.519 27369-27369 PermissionCheck com.example.myapplication73 E The authManager is: null; the authCallback is: null; the mContext is: null 2025-07-21 23:47:20.525 27369-27369 BaiduApiAuth com.example.myapplication73 I BaiduApiAuth SDK Version:1.0.32 2025-07-21 23:47:20.804 27369-27412 CuidBuddyInfoManager com.example.myapplication73 W galaxy lib host missing meta-data,make sure you know the right way to integrate galaxy 2025-07-21 23:47:20.804 27369-27412 CuidBuddyInfoManager com.example.myapplication73 W galaxy lib host missing meta-data,make sure you know the right way to integrate galaxy 2025-07-21 23:47:20.804 27369-27412 CuidBuddyInfoManager com.example.myapplication73 W galaxy lib host missing meta-data,make sure you know the right way to integrate galaxy 2025-07-21 23:47:20.838 27369-27412 myapplication7 com.example.myapplication73 E No implementation found for java.lang.String com.baidu.mapsdkplatform.comjni.util.JNIMD5.encodeUrlParamsValue(java.lang.String) (tried Java_com_baidu_mapsdkplatform_comjni_util_JNIMD5_encodeUrlParamsValue and Java_com_baidu_mapsdkplatform_comjni_util_JNIMD5_encodeUrlParamsValue__Ljava_lang_String_2) 2025-07-21 23:47:20.842 27369-27369 PermissionCheck com.example.myapplication73 E The authManager is: null; the authCallback is: null; the mContext is: null 2025-07-21 23:47:21.031 27369-27369 PermissionCheck com.example.myapplication73 E permission check result is: 230 2025-07-21 23:47:21.045 27369-27369 rp_th com.example.myapplication73 W type=1400 audit(0.0:137): avc: denied { open } for path="/data/local.prop" dev="dm-30" ino=11 scontext=u:r:untrusted_app:s0:c161,c256,c512,c768 tcontext=u:object_r:system_data_file:s0 tclass=file permissive=0 app=com.example.myapplication73 2025-07-21 23:47:21.045 27369-27369 rp_th com.example.myapplication73 W type=1400 audit(0.0:138): avc: denied { open } for path="/data/local.prop" dev="dm-30" ino=11 scontext=u:r:untrusted_app:s0:c161,c256,c512,c768 tcontext=u:object_r:system_data_file:s0 tclass=file permissive=0 app=com.example.myapplication73 2025-07-21 23:47:21.045 27369-27369 rp_th com.example.myapplication73 W type=1400 audit(0.0:139): avc: denied { open } for path="/data/local.prop" dev="dm-30" ino=11 scontext=u:r:untrusted_app:s0:c161,c256,c512,c768 tcontext=u:object_r:system_data_file:s0 tclass=file permissive=0 app=com.example.myapplication73 2025-07-21 23:47:21.045 27369-27369 rp_th com.example.myapplication73 W type=1400 audit(0.0:140): avc: denied { open } for path="/data/local.prop" dev="dm-30" ino=11 scontext=u:r:untrusted_app:s0:c161,c256,c512,c768 tcontext=u:object_r:system_data_file:s0 tclass=file permissive=0 app=com.example.myapplication73 2025-07-21 23:47:21.045 27369-27369 rp_th com.example.myapplication73 W type=1400 audit(0.0:141): avc: denied { open } for path="/data/local.prop" dev="dm-30" ino=11 scontext=u:r:untrusted_app:s0:c161,c256,c512,c768 tcontext=u:object_r:system_data_file:s0 tclass=file permissive=0 app=com.example.myapplication73 2025-07-21 23:47:21.324 27369-27432 libEGL com.example.myapplication73 D loaded /vendor/lib64/egl/libEGL_emulation.so 2025-07-21 23:47:21.376 27369-27369 myapplication7 com.example.myapplication73 W CheckJNI: method to register "nativeSetLayerTag" not in the given class. This is slow, consider changing your RegisterNatives calls. 2025-07-21 23:47:21.382 27369-27432 libEGL com.example.myapplication73 D loaded /vendor/lib64/egl/libGLESv1_CM_emulation.so 2025-07-21 23:47:21.398 27369-27432 libEGL com.example.myapplication73 D loaded /vendor/lib64/egl/libGLESv2_emulation.so 2025-07-21 23:47:21.417 27369-27448 DEBUG com.example.myapplication73 D ThreadProc, CVSocketMan::SocketThreadProc start ... 2025-07-21 23:47:21.420 27369-27369 NetworkLogic com.example.myapplication73 D onNetWorkChanged-0, oldType = mobile 2025-07-21 23:47:21.421 27369-27369 PermissionCheck com.example.myapplication73 E permission check result is: 230 2025-07-21 23:47:21.422 27369-27449 NetworkLogic com.example.myapplication73 D NetworkDetect 2025-07-21 23:47:21.452 27369-27449 DEBUG com.example.myapplication73 D CNetworkDetectEngine::NetworkDetect Start 1 2025-07-21 23:47:21.560 27369-27369 HostConnection com.example.myapplication73 D HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_vulkan_async_qsri ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_1 2025-07-21 23:47:21.741 27369-27369 libc com.example.myapplication73 A Fatal signal 11 (SIGSEGV), code 128 (SI_KERNEL), fault addr 0x0 in tid 27369 (myapplication73), pid 27369 (myapplication73) 2025-07-21 23:47:31.531 27461-27461 DEBUG crash_dump64 A Cmdline: com.example.myapplication73 2025-07-21 23:47:31.531 27461-27461 DEBUG crash_dump64 A pid: 27369, tid: 27369, name: myapplication73 >>> com.example.myapplication73 <<< 2025-07-21 23:47:31.531 27461-27461 DEBUG crash_dump64 A #00 pc 00000000003f2574 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk!libBaiduMapSDK_map_v7_6_5.so (_baidu_framework::CBaseLayer::CBaseLayer()+148) (BuildId: 5b4e53b2e29c2ced49039bcca7318acbf2e1df4d) 2025-07-21 23:47:31.531 27461-27461 DEBUG crash_dump64 A #01 pc 00000000004a8ff9 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk!libBaiduMapSDK_map_v7_6_5.so (BuildId: 5b4e53b2e29c2ced49039bcca7318acbf2e1df4d) 2025-07-21 23:47:31.531 27461-27461 DEBUG crash_dump64 A #02 pc 00000000004a8e96 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk!libBaiduMapSDK_map_v7_6_5.so (BuildId: 5b4e53b2e29c2ced49039bcca7318acbf2e1df4d) 2025-07-21 23:47:31.531 27461-27461 DEBUG crash_dump64 A #03 pc 00000000003339f0 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk!libBaiduMapSDK_map_v7_6_5.so (_baidu_framework::CVComServer::ComCreateInstance(_baidu_vi::CVString const&, _baidu_vi::CVString const&, void**)+112) (BuildId: 5b4e53b2e29c2ced49039bcca7318acbf2e1df4d) 2025-07-21 23:47:31.531 27461-27461 DEBUG crash_dump64 A #04 pc 00000000003ad7b1 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk!libBaiduMapSDK_map_v7_6_5.so (BuildId: 5b4e53b2e29c2ced49039bcca7318acbf2e1df4d) 2025-07-21 23:47:31.531 27461-27461 DEBUG crash_dump64 A #05 pc 00000000003aeff2 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk!libBaiduMapSDK_map_v7_6_5.so (BuildId: 5b4e53b2e29c2ced49039bcca7318acbf2e1df4d) 2025-07-21 23:47:31.531 27461-27461 DEBUG crash_dump64 A #06 pc 00000000003a9830 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk!libBaiduMapSDK_map_v7_6_5.so (_baidu_framework::IVMapbaseFactory::CreateInstance(_baidu_vi::CVString const&, void**)+128) (BuildId: 5b4e53b2e29c2ced49039bcca7318acbf2e1df4d) 2025-07-21 23:47:31.531 27461-27461 DEBUG crash_dump64 A #07 pc 00000000003339f0 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk!libBaiduMapSDK_map_v7_6_5.so (_baidu_framework::CVComServer::ComCreateInstance(_baidu_vi::CVString const&, _baidu_vi::CVString const&, void**)+112) (BuildId: 5b4e53b2e29c2ced49039bcca7318acbf2e1df4d) 2025-07-21 23:47:31.531 27461-27461 DEBUG crash_dump64 A #08 pc 0000000000384374 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk!libBaiduMapSDK_map_v7_6_5.so (BuildId: 5b4e53b2e29c2ced49039bcca7318acbf2e1df4d) 2025-07-21 23:47:31.532 27461-27461 DEBUG crash_dump64 A #11 pc 00000000003ef410 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk (com.baidu.platform.comjni.map.basemap.NABaseMap.create+0) 2025-07-21 23:47:31.532 27461-27461 DEBUG crash_dump64 A #13 pc 00000000003eb9ae /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk (com.baidu.platform.comjni.map.basemap.AppBaseMap.Create+22) 2025-07-21 23:47:31.532 27461-27461 DEBUG crash_dump64 A #15 pc 00000000003d7a26 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk (com.baidu.platform.comapi.map.MapController.initBaseMap+18) 2025-07-21 23:47:31.532 27461-27461 DEBUG crash_dump64 A #17 pc 00000000003d79d8 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk (com.baidu.platform.comapi.map.MapController.initAppBaseMap+16) 2025-07-21 23:47:31.532 27461-27461 DEBUG crash_dump64 A #19 pc 000000000039ae4e /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk (com.baidu.mapsdkplatform.comapi.map.c.<init>+174) 2025-07-21 23:47:31.532 27461-27461 DEBUG crash_dump64 A #21 pc 0000000000357a12 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk (com.baidu.mapapi.map.BaiduMap.<init>+206) 2025-07-21 23:47:31.532 27461-27461 DEBUG crash_dump64 A #23 pc 0000000000365000 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk (com.baidu.mapapi.map.MapView.a+56) 2025-07-21 23:47:31.532 27461-27461 DEBUG crash_dump64 A #25 pc 0000000000364f12 /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk (com.baidu.mapapi.map.MapView.a+130) 2025-07-21 23:47:31.532 27461-27461 DEBUG crash_dump64 A #27 pc 0000000000364c9c /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk (com.baidu.mapapi.map.MapView.<init>+72) 2025-07-21 23:47:31.534 27461-27461 DEBUG crash_dump64 A #72 pc 000000000000065e /data/app/~~8M7mzY3zEClKcow5I-LMmg==/com.example.myapplication73-7xkmjIWXIo6DcpvJdKYlxw==/base.apk (com.example.myapplication73.BaiduMapDemoActivity.onCreate+10)这是什么原因
07-23
分析以下代码的报错信息:------------------------- PROCESS STARTED (7432) for package com.example.myapplication ---------------------------- 2025-07-09 13:27:09.041 7432-7432 e.myapplicatio com.example.myapplication W ClassLoaderContext classpath size mismatch. expected=0, found=1 (PCL[] | PCL[/data/data/com.example.myapplication/code_cache/.overlay/base.apk/classes3.dex*4250602868]) 2025-07-09 13:27:09.042 7432-7432 e.myapplicatio com.example.myapplication W Found duplicate classes, falling back to extracting from APK : /data/app/~~dh0o8WK_fXecSV_JJz78RQ==/com.example.myapplication-RE5zX8NpQzXhviy1xPMobA==/base.apk 2025-07-09 13:27:09.042 7432-7432 e.myapplicatio com.example.myapplication W NOTE: This wastes RAM and hurts startup performance. 2025-07-09 13:27:09.042 7432-7432 e.myapplicatio com.example.myapplication W Found duplicated class when checking oat files: 'Lcom/example/myapplication/ListActivity$1;' in /data/data/com.example.myapplication/code_cache/.overlay/base.apk/classes3.dex and /data/app/~~dh0o8WK_fXecSV_JJz78RQ==/com.example.myapplication-RE5zX8NpQzXhviy1xPMobA==/base.apk!classes3.dex 2025-07-09 13:27:09.172 7432-7432 NetworkSecurityConfig com.example.myapplication D No Network Security Config specified, using platform default 2025-07-09 13:27:09.173 7432-7432 NetworkSecurityConfig com.example.myapplication D No Network Security Config specified, using platform default 2025-07-09 13:27:09.201 7432-7456 libEGL com.example.myapplication D loaded /vendor/lib/egl/libEGL_emulation.so 2025-07-09 13:27:09.202 7432-7456 libEGL com.example.myapplication D loaded /vendor/lib/egl/libGLESv1_CM_emulation.so 2025-07-09 13:27:09.204 7432-7456 libEGL com.example.myapplication D loaded /vendor/lib/egl/libGLESv2_emulation.so 2025-07-09 13:27:09.246 7432-7432 AppCompatDelegate com.example.myapplication D Checking for metadata for AppLocalesMetadataHolderService : Service not found 2025-07-09 13:27:09.305 7432-7432 e.myapplicatio com.example.myapplication W Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed) 2025-07-09 13:27:09.305 7432-7432 e.myapplicatio com.example.myapplication W Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed) 2025-07-09 13:27:09.397 7432-7454 HostConnection com.example.myapplication D HostConnection::get() New Host Connection established 0xe9a68250, tid 7454 2025-07-09 13:27:09.403 7432-7454 HostConnection com.example.myapplication D HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data ANDROID_EMU_vulkan_async_qsri ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 2025-07-09 13:27:09.404 7432-7454 OpenGLRenderer com.example.myapplication W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2025-07-09 13:27:09.411 7432-7454 EGL_emulation com.example.myapplication D eglCreateContext: 0xe9a68170: maj 2 min 0 rcv 2 2025-07-09 13:27:09.414 7432-7454 EGL_emulation com.example.myapplication D eglMakeCurrent: 0xe9a68170: ver 2 0 (tinfo 0xe9db64d0) (first time) 2025-07-09 13:27:09.438 7432-7454 Gralloc4 com.example.myapplication I mapper 4.x is not supported 2025-07-09 13:27:09.439 7432-7454 HostConnection com.example.myapplication D createUnique: call 2025-07-09 13:27:09.439 7432-7454 HostConnection com.example.myapplication D HostConnection::get() New Host Connection established 0xe9a6acc0, tid 7454 2025-07-09 13:27:09.467 7432-7454 HostConnection com.example.myapplication D HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data ANDROID_EMU_vulkan_async_qsri ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 2025-07-09 13:27:10.478 7432-7432 AndroidRuntime com.example.myapplication D Shutting down VM 2025-07-09 13:27:10.479 7432-7432 AndroidRuntime com.example.myapplication E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 7432 android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running? at android.view.ViewRootImpl.setView(ViewRootImpl.java:1068) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:409) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:109) at android.app.Dialog.show(Dialog.java:340) at android.app.AlertDialog$Builder.show(AlertDialog.java:1131) at com.example.myapplication.MyBaseAdapter$1.onClick(MyBaseAdapter.java:55) at android.view.View.performClick(View.java:7448) at android.view.View.performClickInternal(View.java:7425) at android.view.View.access$3600(View.java:810) at android.view.View$PerformClick.run(View.java:28305) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 2025-07-09 13:27:10.509 7432-7432 Process com.example.myapplication I Sending signal. PID: 7432 SIG: 9 ---------------------------- PROCESS ENDED (7432) for package com.example.myapplication ----------------------------
07-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值