问:
Unable to delete record in CodeIgniter
home.php
This is my controller, I am getting right URL through Id but unable to delete record.

```<code><?php
class home extends CI_Controller
{
    function __construct(){
        parent::__construct();
        $this->load->model('select');
        $this->load->helper(array('form','url','html'));
        $this->load->library(array('form_validation','session'));
    }

  public function index(){
     //load the database
     //$this->load->database();
     //load the model
     $this->load->model('select');
     //load the method of model
     $data['h']=$this->select->select();
     //return the data in view
     $this->load->view('fetch_view', $data);
  }

  function records(){
      $ytl['dta']=$this->users->datas();
       //$this->load->view('info',$ytl);
       //echo "```controller";print_r($ytl);
  }

  function primezone(){
       $ytl['dta']=$this->users->datas();
    echo "```controller";print_r($ytl);
  }

  function form($id=null){
    //die($id);
    if($this->input->post())
    {
        //echo"```";print_r( $this->input->post());die;
        $this->form_validation->set_rules('fname','First Name','required|min_length[5]');
        $this->form_validation->set_rules('lname','Last Name','required|callback_check_picture[lname]');
        //$this->form_validation->set_rules('email','Email','required');
        $this->form_validation->set_rules('mobile','Mobile Number','required|callback_valid_phone_number[mobile]');
        $this->form_validation->set_error_delimiters('
', '
');
        if($this->form_validation->run()==True)
        {
            $data=[
            'fname'=>$this->input->post('fname'),
            'lname'=>$this->input->post('lname'),
            'email'=>$this->input->post('email'),
            'mobile'=>$this->input->post('mobile'),
            'message'=>$this->input->post('message'),
            ];
            if(empty($id))
            {
              $ytl=$this->select->insertdata($data);

            } else {
                $ytl=$this->select->updatedata($data,$id);
            }
          if($ytl){
              $this->session->set_flashdata('message', 'Successfully Added.');
          redirect('home');
          }
        } else {
                //$this->load->view('form');
        }
    }
    $ytl['dta']=$this->select->getDataById($id);
    //echo "```";print_r($ytl);die;
    $this->load->view('form',$ytl);
  }

  public function check_picture($a){
    if(!is_numeric($a))
    {
       return true;
    }else{
       $this->form_validation->set_message('check_picture', 'Please enter only char value');
       return False;
    }
  }

  function valid_phone_number($value){
  $value = strlen($value);
   //echo $value;die;
    if ($value == 10) {
        return true;
    } else {
        $this->form_validation->set_message('valid_phone_number', 'Mobile number not in range'); //{10}
        return false;
    }
  }

  public function delete(){
    $this->load->model('select');
    $id=$this->input->get('id');
       //echo $id;
     if($this->select->deleteuser($id))
     {
         $data['h']=$this->select->select();
         $this->load->view('fetch_view', $data);
     }
  }
}
?>
</code>```

fetch_view.php
This is my view, I am getting right URL through Id but unable to delete record.

```<code><!DOCTYPE html>
<html>
<head>

  <link href="<?php echo base_url().'assets/bootstrap.min.css'; ?>" rel="stylesheet" type='text/css'>
  <!-- jQuery library -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <!-- Latest compiled JavaScript -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.13/datatables.min.css"/>
  <script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.13/datatables.min.js"></script>
  <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/dataTables.bootstrap.min.css" />
  <script type="text/javascript" src="https://cdn.datatables.net/1.10.13/js/dataTables.bootstrap.min.js"></script>

  <style>
     .error{color:red}
   </style>
</head>
    <body>
      <h1>User List</h1>
      <?php if($this->session->flashdata('message')){?>
      <div class="alert alert-success alert-dismissable">
        <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
        <strong>Success!</strong> <?= $this->session->flashdata('message') ?>
      </div>
      <?php } ?>

    <table border="1" class="table table-bordered table-striped table-hover" id="">
      <tbody>
        <thead>
          <tr>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Email</th>
            <th>Mobile Number</th>
            <th>Message</th>
            <th>Update</th>
            <th>Delete</th>
          </tr>
        </thead>
      </tbody>
      <?php
          foreach ($h->result() as $row)
        { ?>
        <tr>
          <td><?php echo $row->fname; ?></td>
          <td><?php echo $row->lname; ?></td>
          <td><?php echo $row->email; ?></td>
          <td><?php echo $row->mobile; ?></td>
          <td><?php echo $row->message; ?></td>
          <td><a href="<?= site_url('home/form').'/'.$row->id ?>">Edit</a></td>
          <td><a href="<?php echo site_url('home/delete').'/'.$row->id; ?>">Delete</a></td>
        </tr>
      <?php } ?>
    </table>
  </form>
</body>
</html>
</code>```

select.php
This is my Model, I am getting right URL through Id but unable to delete record.

```<code><?php
class select extends CI_model
{
    function __construct(){
      // Call the Model constructor
      parent::__construct();
      $this->load->database();
    }

    function insertdata($data){
      if(!empty($data['id'])){
          $this->db->where('id', $data['id'])->update('student', $data);
          return $data['id'];
      } else {
          unset($data['id']);
          $this->db->insert('student',  $data);
          return $this->db->insert_id();
      }
    }

    public function select(){
       //data is retrive from this query
        $query = $this->db->get('student');
        return $query;
        //return $query->row();
    }

    function getDataById($id)
    {
      $this->db->select('*');
      $this->db->where('id',$id);
      $this->db->from('student');
      $query = $this->db->get()->row_array();
           return $query;
    }

    function updatedata($data, $id)
    {
      //print_r($data);die;
      $this->db->where('id', $id);
      return $this->db->update('student' ,$data);
    }

    public function deleteuser($id)
    {
      //echo $id;
      //die;
      // $this->load->database();
      $this->db->where('id', $id);
      $this->db->delete('student');
      return true;
    }

}
?>
</code>```

I know that I have to paste only specific code but I am pasting full code.

答:
You called in the url delete($id) function but not pass the id in the controller .Change your delete function.</p>

```<code>public function delete($id='')
{
     $this->load->model('select');
     if(!empty($id))
     {
        $data['deldata']=$this->select->deleteuser($id);
        $data['h']=$this->select->select();
        $this->load->view('fetch_view', $data);
     }
}
</code>```

Title: Unable to delete record in CodeIgniter

Body:
home.php
This is my controller, I am getting right URL through Id but unable to delete record.

<?php
class home extends CI_Controller
{
    function __construct(){
        parent::__construct();
        $this->load->model('select');
        $this->load->helper(array('form','url','html'));
        $this->load->library(array('form_validation','session'));
    }

  public function index(){
     //load the database
     //$this->load->database();
     //load the model
     $this->load->model('select');
     //load the method of model
     $data['h']=$this->select->select();
     //return the data in view
     $this->load->view('fetch_view', $data);
  }

  function records(){
      $ytl['dta']=$this->users->datas();
       //$this->load->view('info',$ytl);
       //echo "
controller";print_r($ytl);
  }

  function primezone(){
       $ytl['dta']=$this->users->datas();
    echo "
controller";print_r($ytl);
  }

  function form($id=null){
    //die($id);
    if($this->input->post())
    {
        //echo"
";print_r( $this->input->post());die;
        $this->form_validation->set_rules('fname','First Name','required|min_length[5]');
        $this->form_validation->set_rules('lname','Last Name','required|callback_check_picture[lname]');
        //$this->form_validation->set_rules('email','Email','required');
        $this->form_validation->set_rules('mobile','Mobile Number','required|callback_valid_phone_number[mobile]');
        $this->form_validation->set_error_delimiters('
', '
');
        if($this->form_validation->run()==True)
        {
            $data=[
            'fname'=>$this->input->post('fname'),
            'lname'=>$this->input->post('lname'),
            'email'=>$this->input->post('email'),
            'mobile'=>$this->input->post('mobile'),
            'message'=>$this->input->post('message'),
            ];
            if(empty($id))
            {
              $ytl=$this->select->insertdata($data);

            } else {
                $ytl=$this->select->updatedata($data,$id);
            }
          if($ytl){
              $this->session->set_flashdata('message', 'Successfully Added.');
          redirect('home');
          }
        } else {
                //$this->load->view('form');
        }
    }
    $ytl['dta']=$this->select->getDataById($id);
    //echo "
";print_r($ytl);die;
    $this->load->view('form',$ytl);
  }

  public function check_picture($a){
    if(!is_numeric($a))
    {
       return true;
    }else{
       $this->form_validation->set_message('check_picture', 'Please enter only char value');
       return False;
    }
  }

  function valid_phone_number($value){
  $value = strlen($value);
   //echo $value;die;
    if ($value == 10) {
        return true;
    } else {
        $this->form_validation->set_message('valid_phone_number', 'Mobile number not in range'); //{10}
        return false;
    }
  }

  public function delete(){
    $this->load->model('select');
    $id=$this->input->get('id');
       //echo $id;
     if($this->select->deleteuser($id))
     {
         $data['h']=$this->select->select();
         $this->load->view('fetch_view', $data);
     }
  }
}
?>

fetch_view.php
This is my view, I am getting right URL through Id but unable to delete record.

<!DOCTYPE html>

  <link href="<?php echo base_url().'assets/bootstrap.min.css'; ?>" rel="stylesheet" type='text/css'>

  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.13/datatables.min.css"/>

  <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/dataTables.bootstrap.min.css" />

User List

      <?php if($this->session->flashdata('message')){?>

        ×
        Success! <?= $this->session->flashdata('message') ?>

      <?php } ?>

            First Name
            Last Name
            Email
            Mobile Number
            Message
            Update
            Delete

      <?php
          foreach ($h->result() as $row)
        { ?>

          <?php echo $row->fname; ?>
          <?php echo $row->lname; ?>
          <?php echo $row->email; ?>
          <?php echo $row->mobile; ?>
          <?php echo $row->message; ?>
          <a href="<?= site_url('home/form').'/'.$row->id ?>">Edit
          <a href="<?php echo site_url('home/delete').'/'.$row->id; ?>">Delete

      <?php } ?>

  </form>

select.php
This is my Model, I am getting right URL through Id but unable to delete record.

<?php
class select extends CI_model
{
    function __construct(){
      // Call the Model constructor
      parent::__construct();
      $this->load->database();
    }

    function insertdata($data){
      if(!empty($data['id'])){
          $this->db->where('id', $data['id'])->update('student', $data);
          return $data['id'];
      } else {
          unset($data['id']);
          $this->db->insert('student',  $data);
          return $this->db->insert_id();
      }
    }

    public function select(){
       //data is retrive from this query
        $query = $this->db->get('student');
        return $query;
        //return $query->row();
    }

    function getDataById($id)
    {
      $this->db->select('*');
      $this->db->where('id',$id);
      $this->db->from('student');
      $query = $this->db->get()->row_array();
           return $query;
    }

    function updatedata($data, $id)
    {
      //print_r($data);die;
      $this->db->where('id', $id);
      return $this->db->update('student' ,$data);
    }

    public function deleteuser($id)
    {
      //echo $id;
      //die;
      // $this->load->database();
      $this->db->where('id', $id);
      $this->db->delete('student');
      return true;
    }

}
?>

I know that I have to paste only specific code but I am pasting full code.

Body:
You called in the url delete($id) function but not pass the id in the controller .Change your delete function.

public function delete($id='')
{
     $this->load->model('select');
     if(!empty($id))
     {
        $data['deldata']=$this->select->deleteuser($id);
        $data['h']=$this->select->select();
        $this->load->view('fetch_view', $data);
     }
}


来源: stackexchange

问:
"Error: ' ' is not a valid resource name character" after updating to Android Gradle 3.0.0
After updating to Android gradle plugin 3.0.0 and gradle 4.1, I can't compile my code. The project runs just fine in 2.3.3.

Here is the error when I run gradle with --stacktrace:

Error:com.android.builder.symbols.ResourceDirectoryParseException:
  Failed to parse XML resource file
  '/Users/felipea/Documents/next-components/nextcomponents/build/intermediates/bundles/debug/res/values/values.xml'
  Error:java.lang.IllegalArgumentException: Error: ' ' is not a valid
  resource name character Error:Error: ' ' is not a valid resource name
  character

But I did not found a space character in my values.xml:

```<code>    <?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="months_of_year">
        <item>JANEIRO</item>
        <item>FEVEREIRO</item>
        <item>MARÇO</item>
        <item>ABRIL</item>
        <item>MAIO</item>
        <item>JUNHO</item>
        <item>JULHO</item>
        <item>AGOSTO</item>
        <item>SETEMBRO</item>
        <item>OUTUBRO</item>
        <item>NOVEMBRO</item>
        <item>DEZEMBRO</item>
    </string-array>
    <attr format="boolean" name="autoSpace"/>
    <attr format="reference" name="calendarDaysOfWeekListStyle"/>
    <attr format="reference" name="calendarItemStyle"/>
    <attr format="color" name="calendarSelectedDayColor"/>
    <attr format="reference" name="calendarStyle"/>
    <attr format="reference" name="calendarTextHeaderStyle"/>
    <attr format="color" name="calendarUnselectedDayColor"/>
    <attr format="integer" name="circumference"/>
    <attr format="integer" name="dividerColor"/>
    <attr format="boolean" name="hasImageInfo"/>
    <attr format="reference" name="imageInfoDrawable"/>
    <attr format="reference" name="tollBarCheckIcon"/>
    <attr format="reference" name="tollBarCloseIcon"/>
    <color name="color_edittext_error">#ff3333</color>
    <color name="green_light">#01ff5f</color>
    <color name="next_black_1">#000000</color>
    <color name="next_black_1_10">#1A000000</color>
    <color name="next_black_2">#1e1e1e</color>
    <color name="next_black_3">#202020</color>
    <color name="next_black_4">#333333</color>
    <color name="next_gray_1">#585858</color>
    <color name="next_gray_2">#808285</color>
    <color name="next_gray_3">#B8B8B8</color>
    <color name="next_gray_4">#E9E9E9</color>
    <color name="next_gray_5">#EFEFEF</color>
    <color name="next_gray_6">#F5F5F5</color>
    <color name="next_green">#01ff5f</color>
    <color name="next_green_1">#00581B</color>
    <color name="next_green_2">#01B240</color>
    <color name="next_green_3">#01DF53</color>
    <color name="next_green_4">#01F85C</color>
    <color name="next_green_5">#01FF5F</color>
    <color name="next_green_6">#00FFA2</color>
    <color name="next_grey">#E9E9E9</color>
    <color name="next_red_1">#FE7059</color>
    <color name="next_transparent">#FFFFFFFF</color>
    <color name="next_white_1">#ffffff</color>
    <color name="next_yellow_1">#CCB80C</color>
    <color name="next_yellow_2">#FFE60F</color>
    <declare-styleable name="AnimatedIcon"><attr format="boolean" name="isDark"/><attr format="color" name="iconStrokeColor"/><attr format="dimension" name="iconStrokeWidth"/></declare-styleable>
    <declare-styleable name="MaskableLayout"><attr format="reference" name="mask"/><attr name="porterduffxfermode">
            <enum name="ADD" value="0"/>
            <enum name="CLEAR" value="1"/>
            <enum name="DARKEN " value="2"/>
            <enum name="DST" value="3"/>
            <enum name="DST_ATOP" value="4"/>
            <enum name="DST_IN" value="5"/>
            <enum name="DST_OUT" value="6"/>
            <enum name="DST_OVER" value="7"/>
            <enum name="LIGHTEN" value="8"/>
            <enum name="MULTIPLY" value="9"/>
            <enum name="OVERLAY" value="10"/>
            <enum name="SCREEN" value="11"/>
            <enum name="SRC" value="12"/>
            <enum name="SRC_ATOP" value="13"/>
            <enum name="SRC_IN" value="14"/>
            <enum name="SRC_OUT" value="15"/>
            <enum name="SRC_OVER" value="16"/>
            <enum name="XOR" value="17"/>
        </attr><attr format="boolean" name="anti_aliasing"/></declare-styleable>
    <declare-styleable name="NextBaseEditText"><attr format="boolean" name="upper_case"/><attr format="boolean" name="block_special_char"/><attr format="boolean" name="allow_email_char"/><attr format="boolean" name="block_numbers"/><attr name="android:text"/><attr format="boolean" name="error_enabled"/><attr name="android:hint"/><attr name="android:textSize"/><attr name="android:maxLines"/><attr format="string" name="fontType"/><attr name="android:maxLength"/><attr name="android:textColor"/><attr format="reference" name="textColorHint"/><attr format="reference" name="til_style"/><attr name="android:textAllCaps"/><attr format="boolean" name="optional"/></declare-styleable>
    <declare-styleable name="NextCalendarView"><attr format="color" name="textColor"/><attr format="color" name="textSelectedColor"/><attr format="color" name="selectedColor"/></declare-styleable>
    <declare-styleable name="NextCheckBox"><attr format="string" name="key"/><attr name="android:text"/><attr format="color" name="squareStrokeColor"/><attr name="android:textColor"/></declare-styleable>
    <declare-styleable name="NextCheckablePageIndicator"><attr format="color" name="strokeLineColor"/><attr format="color" name="checkedStrokeLineColor"/><attr format="color" name="checkImageColor"/><attr format="color" name="dotColor"/></declare-styleable>
    <declare-styleable name="NextDatePickerButton"><attr format="enum" name="calendar_tipe">
            <enum name="android" value="0"/>
            <enum name="next" value="1"/>
        </attr><attr format="string" name="date_patern"/><attr format="enum" name="calendar_swipe_orientation">
            <enum name="horizontal" value="0"/>
            <enum name="vertical" value="1"/>
        </attr><attr format="string" name="calendar_title"/></declare-styleable>
    <declare-styleable name="NextFlowView"><attr format="dimension" name="flowStrokeWidth"/></declare-styleable>
    <declare-styleable name="NextForm"><attr format="boolean" name="validateOnStart"/><attr format="boolean" name="editable"/><attr format="boolean" name="multilevelData"/><attr format="string" name="titleHeader"/><attr format="color" name="titleHeaderColor"/><attr name="android:paddingLeft"/><attr name="android:paddingRight"/><attr name="android:paddingBottom"/><attr name="android:paddingTop"/></declare-styleable>
    <declare-styleable name="NextFormExpandableSubForm"><attr name="android:text"/><attr format="boolean" name="expanded"/><attr format="boolean" name="subFormBottomLineVisible"/></declare-styleable>
    <declare-styleable name="NextFormItemContainer"><attr format="boolean" name="disableable"/><attr format="boolean" name="required"/><attr format="string" name="invalidMessage"/><attr format="string" name="emptyMessage"/><attr format="string" name="placeholder"/><attr format="string" name="fieldName"/><attr format="color" name="placeholderColor"/><attr format="float" name="placeholderAlpha"/><attr format="boolean" name="bottomLineVisible"/><attr format="color" name="bottomLineColor"/><attr name="android:enabled"/><attr name="autoSpace"/><attr name="hasImageInfo"/><attr name="imageInfoDrawable"/></declare-styleable>
    <declare-styleable name="NextFormSubFormList"><attr format="reference" name="subFormLayout"/></declare-styleable>
    <declare-styleable name="NextPicker"><attr format="color|reference" name="solidColor"/><attr format="reference" name="selectionBackground"/><attr format="reference" name="selectionDivider"/><attr format="dimension" name="selectionDividerHeight"/><attr format="dimension" name="selectionDividersDistance"/><attr format="dimension" name="internalMinHeight"/><attr format="dimension" name="internalMaxHeight"/><attr format="dimension" name="internalMinWidth"/><attr format="dimension" name="internalMaxWidth"/><attr format="reference" name="internalLayout"/><attr format="reference" name="virtualButtonPressedDrawable"/><attr format="reference" name="NextPickerStyle"/></declare-styleable>
    <declare-styleable name="NextPickerButton"><attr format="string" name="blankText"/><attr name="android:textColor"/><attr format="reference" name="pickerDrawable"/><attr format="color" name="pickerDrawableColor"/></declare-styleable>
    <declare-styleable name="NextRadioButton"><attr name="android:checked"/><attr format="string" name="value"/><attr name="android:text"/><attr name="android:textColor"/><attr format="color" name="circleStrokeColor"/><attr format="string" name="textTop"/><attr format="string" name="textBottom"/><attr name="android:orientation"/><attr format="boolean" name="multiCheck"/></declare-styleable>
    <declare-styleable name="NextSmileView"><attr format="color" name="smileStrokeColor"/></declare-styleable>
    <declare-styleable name="NextSquaredGraphView"><attr format="dimension" name="strokeWidth"/><attr format="dimension" name="cornerRadius"/><attr format="color" name="backStrokeColor"/></declare-styleable>
    <declare-styleable name="NextSwitchButton"><attr format="string" name="keySwitcher"/><attr name="android:text"/><attr name="android:textColor"/><attr name="hasImageInfo"/><attr name="imageInfoDrawable"/><attr name="autoSpace"/></declare-styleable>
    <declare-styleable name="NextTextView"><attr format="enum" name="NextFontType">
            <enum name="newjune_medium" value="1"/>
            <enum name="newjune_semibold" value="2"/>
            <enum name="newjune_book" value="3"/>
        </attr></declare-styleable>
    <declare-styleable name="NextTitleSession"><attr name="android:text"/><attr name="android:textColor"/></declare-styleable>
    <dimen name="default_padding">30dp</dimen>
    <dimen name="horizontal_indicator_corner">8dp</dimen>
    <dimen name="next_animated_icon_height">24dp</dimen>
    <dimen name="next_animated_icon_width">24dp</dimen>
    <dimen name="next_checkbox_icon_apply_size">24dp</dimen>
    <dimen name="next_checkbox_square_border_size">48dp</dimen>
    <dimen name="next_checkbox_square_container_size">48dp</dimen>
    <dimen name="next_edittext_font_size">15sp</dimen>
    <dimen name="next_expandable_title_text_size">10sp</dimen>
    <dimen name="next_form_header_height">154dp</dimen>
    <dimen name="next_form_header_padding_top">36dp</dimen>
    <dimen name="next_form_header_text_title_size">15sp</dimen>
    <dimen name="next_item_auto_margin_bottom">20dp</dimen>
    <dimen name="next_item_container_error_message_font_size">10sp</dimen>
    <dimen name="next_item_container_placeholder_font_size">10sp</dimen>
    <dimen name="next_page_indicator_dot">5dp</dimen>
    <dimen name="next_page_indicator_dot_margin">4dp</dimen>
    <dimen name="next_picker_button_text_size">15sp</dimen>
    <dimen name="next_radio_button_circle_container_size">70dp</dimen>
    <dimen name="next_radio_button_circle_margin">10dp</dimen>
    <dimen name="next_radio_button_green_circle_size">30dp</dimen>
    <dimen name="next_radio_button_grey_circle_size">52dp</dimen>
    <dimen name="next_radio_button_text_font_size">15sp</dimen>
    <dimen name="next_radio_button_text_footer_font_size">10sp</dimen>
    <dimen name="next_radio_button_text_header_font_size">10sp</dimen>
    <dimen name="next_radio_button_text_margin">12dp</dimen>
    <dimen name="next_radio_button_vertical_width">135dp</dimen>
    <dimen name="next_switch_button_layout_height">54dp</dimen>
    <dimen name="next_switch_button_text_margin">10dp</dimen>
    <dimen name="next_switch_button_text_size">15sp</dimen>
    <dimen name="next_switch_button_view_size">48dp</dimen>
    <dimen name="next_title_session_text_size">10sp</dimen>
    <dimen name="period_picker_corner">26dp</dimen>
    <dimen name="period_picker_corner_horizontal_margin">0dp</dimen>
    <dimen name="period_picker_horizontal_margin">0dp</dimen>
    <dimen name="period_picker_vertical_margin">10dp</dimen>
    <item name="np__decrement" type="id"/>
    <item name="np__increment" type="id"/>
    <string name="add">+ Adicionar</string>
    <string name="agendar">AGENDAR</string>
    <string name="app_name">NextComponents</string>
    <string name="date_patern_expanded_br">dd/MM/yyyy</string>
    <string name="date_patern_short_br">dd/MM/yy</string>
    <string name="datepickerdialog_calendar">Calendário</string>
    <string name="default_blank_message">deve ser preenchido</string>
    <string name="default_invalid_message">Inválido</string>
    <string name="friday_prefix">S</string>
    <string name="monday_prefix">S</string>
    <string name="optional">Opcional</string>
    <string name="picker_default_text">Selecione</string>
    <string name="receipts_period">%1$s até %2$s</string>
    <string name="receipts_period_end_date_invalid">A data final deve ser menor que a data atual</string>
    <string name="receipts_period_period_title">PERÍODO</string>
    <string name="receipts_period_start_date_invalid">A data inicial deve ser menor que a data atual</string>
    <string name="remove">- Remover</string>
    <string name="saturday_prefix">S</string>
    <string name="sunday_prefix">D</string>
    <string name="tag_ico">ico</string>
    <string name="text_date_end">Data final</string>
    <string name="text_date_start">Data inicial</string>
    <string name="text_title_calendar">Calendário</string>
    <string name="thursday_prefix">Q</string>
    <string name="title_header_example">New June Book 15 pt\nLorem Ipsum dolor sit\namet, consectetur.</string>
    <string name="tuesday_prefix">T</string>
    <string name="wednesday_prefix">Q</string>

</resources>
</code>```

EDIT: My gradle files

gradle-wrapper.properties

```<code>distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
</code>```

top-level build.gradle - project build gradle

```<code>buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
</code>```

app build.gradle - my lib demo app

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.myappid"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 2
        versionName "1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':nextcomponents')

    compile 'com.android.support:appcompat-v7:27.0.1'
    compile 'com.wdullaer:materialdatetimepicker:2.1.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    testCompile 'junit:junit:4.12'
}
</code>```

components build.gradle - my lib

```<code>apply plugin: 'com.android.library'

android {
    compileSdkVersion 27
    buildToolsVersion '26.0.2'

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 2
        versionName "1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile "com.android.support:appcompat-v7:27.0.1"
    compile "com.google.code.gson:gson:2.8.0"
    compile "com.android.support:design:27.0.1"
    compile 'com.intellij:annotations:12.0@jar'
    compile('org.apache.commons:commons-lang3:3.1') {
        transitive = true
    }
    compile 'com.airbnb.android:lottie:1.5.3'
    compile 'com.github.rubensousa:gravitysnaphelper:1.1'
    compile 'com.facebook.keyframes:keyframes:1.0'
}
</code>```

答:
Your DARKEN enum has a space in it:

```<code><enum name="DARKEN " value="2"/>
</code>```

I found this by running your question thru egrep:

```<code>egrep 'name="[^"]* [^"]*"'
</code>```

This seems to be a problem in a library you're using: https://github.com/christophesmet/android_maskable_layout/blob/43b109a/library/src/main/res/values/attrs_maskable_framelayout.xml

ContentLicense: CC BY-SA 3.0

Body:
After updating to Android gradle plugin 3.0.0 and gradle 4.1, I can't compile my code. The project runs just fine in 2.3.3.

Here is the error when I run gradle with --stacktrace:

Error:com.android.builder.symbols.ResourceDirectoryParseException:
  Failed to parse XML resource file
  '/Users/felipea/Documents/next-components/nextcomponents/build/intermediates/bundles/debug/res/values/values.xml'
  Error:java.lang.IllegalArgumentException: Error: ' ' is not a valid
  resource name character Error:Error: ' ' is not a valid resource name
  character

But I did not found a space character in my values.xml:

    <?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="months_of_year">
        <item>JANEIRO</item>
        <item>FEVEREIRO</item>
        <item>MARÇO</item>
        <item>ABRIL</item>
        <item>MAIO</item>
        <item>JUNHO</item>
        <item>JULHO</item>
        <item>AGOSTO</item>
        <item>SETEMBRO</item>
        <item>OUTUBRO</item>
        <item>NOVEMBRO</item>
        <item>DEZEMBRO</item>
    </string-array>
    <attr format="boolean" name="autoSpace"/>
    <attr format="reference" name="calendarDaysOfWeekListStyle"/>
    <attr format="reference" name="calendarItemStyle"/>
    <attr format="color" name="calendarSelectedDayColor"/>
    <attr format="reference" name="calendarStyle"/>
    <attr format="reference" name="calendarTextHeaderStyle"/>
    <attr format="color" name="calendarUnselectedDayColor"/>
    <attr format="integer" name="circumference"/>
    <attr format="integer" name="dividerColor"/>
    <attr format="boolean" name="hasImageInfo"/>
    <attr format="reference" name="imageInfoDrawable"/>
    <attr format="reference" name="tollBarCheckIcon"/>
    <attr format="reference" name="tollBarCloseIcon"/>
    <color name="color_edittext_error">#ff3333</color>
    <color name="green_light">#01ff5f</color>
    <color name="next_black_1">#000000</color>
    <color name="next_black_1_10">#1A000000</color>
    <color name="next_black_2">#1e1e1e</color>
    <color name="next_black_3">#202020</color>
    <color name="next_black_4">#333333</color>
    <color name="next_gray_1">#585858</color>
    <color name="next_gray_2">#808285</color>
    <color name="next_gray_3">#B8B8B8</color>
    <color name="next_gray_4">#E9E9E9</color>
    <color name="next_gray_5">#EFEFEF</color>
    <color name="next_gray_6">#F5F5F5</color>
    <color name="next_green">#01ff5f</color>
    <color name="next_green_1">#00581B</color>
    <color name="next_green_2">#01B240</color>
    <color name="next_green_3">#01DF53</color>
    <color name="next_green_4">#01F85C</color>
    <color name="next_green_5">#01FF5F</color>
    <color name="next_green_6">#00FFA2</color>
    <color name="next_grey">#E9E9E9</color>
    <color name="next_red_1">#FE7059</color>
    <color name="next_transparent">#FFFFFFFF</color>
    <color name="next_white_1">#ffffff</color>
    <color name="next_yellow_1">#CCB80C</color>
    <color name="next_yellow_2">#FFE60F</color>
    <declare-styleable name="AnimatedIcon"><attr format="boolean" name="isDark"/><attr format="color" name="iconStrokeColor"/><attr format="dimension" name="iconStrokeWidth"/></declare-styleable>
    <declare-styleable name="MaskableLayout"><attr format="reference" name="mask"/><attr name="porterduffxfermode">
            <enum name="ADD" value="0"/>
            <enum name="CLEAR" value="1"/>
            <enum name="DARKEN " value="2"/>
            <enum name="DST" value="3"/>
            <enum name="DST_ATOP" value="4"/>
            <enum name="DST_IN" value="5"/>
            <enum name="DST_OUT" value="6"/>
            <enum name="DST_OVER" value="7"/>
            <enum name="LIGHTEN" value="8"/>
            <enum name="MULTIPLY" value="9"/>
            <enum name="OVERLAY" value="10"/>
            <enum name="SCREEN" value="11"/>
            <enum name="SRC" value="12"/>
            <enum name="SRC_ATOP" value="13"/>
            <enum name="SRC_IN" value="14"/>
            <enum name="SRC_OUT" value="15"/>
            <enum name="SRC_OVER" value="16"/>
            <enum name="XOR" value="17"/>
        </attr><attr format="boolean" name="anti_aliasing"/></declare-styleable>
    <declare-styleable name="NextBaseEditText"><attr format="boolean" name="upper_case"/><attr format="boolean" name="block_special_char"/><attr format="boolean" name="allow_email_char"/><attr format="boolean" name="block_numbers"/><attr name="android:text"/><attr format="boolean" name="error_enabled"/><attr name="android:hint"/><attr name="android:textSize"/><attr name="android:maxLines"/><attr format="string" name="fontType"/><attr name="android:maxLength"/><attr name="android:textColor"/><attr format="reference" name="textColorHint"/><attr format="reference" name="til_style"/><attr name="android:textAllCaps"/><attr format="boolean" name="optional"/></declare-styleable>
    <declare-styleable name="NextCalendarView"><attr format="color" name="textColor"/><attr format="color" name="textSelectedColor"/><attr format="color" name="selectedColor"/></declare-styleable>
    <declare-styleable name="NextCheckBox"><attr format="string" name="key"/><attr name="android:text"/><attr format="color" name="squareStrokeColor"/><attr name="android:textColor"/></declare-styleable>
    <declare-styleable name="NextCheckablePageIndicator"><attr format="color" name="strokeLineColor"/><attr format="color" name="checkedStrokeLineColor"/><attr format="color" name="checkImageColor"/><attr format="color" name="dotColor"/></declare-styleable>
    <declare-styleable name="NextDatePickerButton"><attr format="enum" name="calendar_tipe">
            <enum name="android" value="0"/>
            <enum name="next" value="1"/>
        </attr><attr format="string" name="date_patern"/><attr format="enum" name="calendar_swipe_orientation">
            <enum name="horizontal" value="0"/>
            <enum name="vertical" value="1"/>
        </attr><attr format="string" name="calendar_title"/></declare-styleable>
    <declare-styleable name="NextFlowView"><attr format="dimension" name="flowStrokeWidth"/></declare-styleable>
    <declare-styleable name="NextForm"><attr format="boolean" name="validateOnStart"/><attr format="boolean" name="editable"/><attr format="boolean" name="multilevelData"/><attr format="string" name="titleHeader"/><attr format="color" name="titleHeaderColor"/><attr name="android:paddingLeft"/><attr name="android:paddingRight"/><attr name="android:paddingBottom"/><attr name="android:paddingTop"/></declare-styleable>
    <declare-styleable name="NextFormExpandableSubForm"><attr name="android:text"/><attr format="boolean" name="expanded"/><attr format="boolean" name="subFormBottomLineVisible"/></declare-styleable>
    <declare-styleable name="NextFormItemContainer"><attr format="boolean" name="disableable"/><attr format="boolean" name="required"/><attr format="string" name="invalidMessage"/><attr format="string" name="emptyMessage"/><attr format="string" name="placeholder"/><attr format="string" name="fieldName"/><attr format="color" name="placeholderColor"/><attr format="float" name="placeholderAlpha"/><attr format="boolean" name="bottomLineVisible"/><attr format="color" name="bottomLineColor"/><attr name="android:enabled"/><attr name="autoSpace"/><attr name="hasImageInfo"/><attr name="imageInfoDrawable"/></declare-styleable>
    <declare-styleable name="NextFormSubFormList"><attr format="reference" name="subFormLayout"/></declare-styleable>
    <declare-styleable name="NextPicker"><attr format="color|reference" name="solidColor"/><attr format="reference" name="selectionBackground"/><attr format="reference" name="selectionDivider"/><attr format="dimension" name="selectionDividerHeight"/><attr format="dimension" name="selectionDividersDistance"/><attr format="dimension" name="internalMinHeight"/><attr format="dimension" name="internalMaxHeight"/><attr format="dimension" name="internalMinWidth"/><attr format="dimension" name="internalMaxWidth"/><attr format="reference" name="internalLayout"/><attr format="reference" name="virtualButtonPressedDrawable"/><attr format="reference" name="NextPickerStyle"/></declare-styleable>
    <declare-styleable name="NextPickerButton"><attr format="string" name="blankText"/><attr name="android:textColor"/><attr format="reference" name="pickerDrawable"/><attr format="color" name="pickerDrawableColor"/></declare-styleable>
    <declare-styleable name="NextRadioButton"><attr name="android:checked"/><attr format="string" name="value"/><attr name="android:text"/><attr name="android:textColor"/><attr format="color" name="circleStrokeColor"/><attr format="string" name="textTop"/><attr format="string" name="textBottom"/><attr name="android:orientation"/><attr format="boolean" name="multiCheck"/></declare-styleable>
    <declare-styleable name="NextSmileView"><attr format="color" name="smileStrokeColor"/></declare-styleable>
    <declare-styleable name="NextSquaredGraphView"><attr format="dimension" name="strokeWidth"/><attr format="dimension" name="cornerRadius"/><attr format="color" name="backStrokeColor"/></declare-styleable>
    <declare-styleable name="NextSwitchButton"><attr format="string" name="keySwitcher"/><attr name="android:text"/><attr name="android:textColor"/><attr name="hasImageInfo"/><attr name="imageInfoDrawable"/><attr name="autoSpace"/></declare-styleable>
    <declare-styleable name="NextTextView"><attr format="enum" name="NextFontType">
            <enum name="newjune_medium" value="1"/>
            <enum name="newjune_semibold" value="2"/>
            <enum name="newjune_book" value="3"/>
        </attr></declare-styleable>
    <declare-styleable name="NextTitleSession"><attr name="android:text"/><attr name="android:textColor"/></declare-styleable>
    <dimen name="default_padding">30dp</dimen>
    <dimen name="horizontal_indicator_corner">8dp</dimen>
    <dimen name="next_animated_icon_height">24dp</dimen>
    <dimen name="next_animated_icon_width">24dp</dimen>
    <dimen name="next_checkbox_icon_apply_size">24dp</dimen>
    <dimen name="next_checkbox_square_border_size">48dp</dimen>
    <dimen name="next_checkbox_square_container_size">48dp</dimen>
    <dimen name="next_edittext_font_size">15sp</dimen>
    <dimen name="next_expandable_title_text_size">10sp</dimen>
    <dimen name="next_form_header_height">154dp</dimen>
    <dimen name="next_form_header_padding_top">36dp</dimen>
    <dimen name="next_form_header_text_title_size">15sp</dimen>
    <dimen name="next_item_auto_margin_bottom">20dp</dimen>
    <dimen name="next_item_container_error_message_font_size">10sp</dimen>
    <dimen name="next_item_container_placeholder_font_size">10sp</dimen>
    <dimen name="next_page_indicator_dot">5dp</dimen>
    <dimen name="next_page_indicator_dot_margin">4dp</dimen>
    <dimen name="next_picker_button_text_size">15sp</dimen>
    <dimen name="next_radio_button_circle_container_size">70dp</dimen>
    <dimen name="next_radio_button_circle_margin">10dp</dimen>
    <dimen name="next_radio_button_green_circle_size">30dp</dimen>
    <dimen name="next_radio_button_grey_circle_size">52dp</dimen>
    <dimen name="next_radio_button_text_font_size">15sp</dimen>
    <dimen name="next_radio_button_text_footer_font_size">10sp</dimen>
    <dimen name="next_radio_button_text_header_font_size">10sp</dimen>
    <dimen name="next_radio_button_text_margin">12dp</dimen>
    <dimen name="next_radio_button_vertical_width">135dp</dimen>
    <dimen name="next_switch_button_layout_height">54dp</dimen>
    <dimen name="next_switch_button_text_margin">10dp</dimen>
    <dimen name="next_switch_button_text_size">15sp</dimen>
    <dimen name="next_switch_button_view_size">48dp</dimen>
    <dimen name="next_title_session_text_size">10sp</dimen>
    <dimen name="period_picker_corner">26dp</dimen>
    <dimen name="period_picker_corner_horizontal_margin">0dp</dimen>
    <dimen name="period_picker_horizontal_margin">0dp</dimen>
    <dimen name="period_picker_vertical_margin">10dp</dimen>
    <item name="np__decrement" type="id"/>
    <item name="np__increment" type="id"/>
    <string name="add">+ Adicionar</string>
    <string name="agendar">AGENDAR</string>
    <string name="app_name">NextComponents</string>
    <string name="date_patern_expanded_br">dd/MM/yyyy</string>
    <string name="date_patern_short_br">dd/MM/yy</string>
    <string name="datepickerdialog_calendar">Calendário</string>
    <string name="default_blank_message">deve ser preenchido</string>
    <string name="default_invalid_message">Inválido</string>
    <string name="friday_prefix">S</string>
    <string name="monday_prefix">S</string>
    <string name="optional">Opcional</string>
    <string name="picker_default_text">Selecione</string>
    <string name="receipts_period">%1$s até %2$s</string>
    <string name="receipts_period_end_date_invalid">A data final deve ser menor que a data atual</string>
    <string name="receipts_period_period_title">PERÍODO</string>
    <string name="receipts_period_start_date_invalid">A data inicial deve ser menor que a data atual</string>
    <string name="remove">- Remover</string>
    <string name="saturday_prefix">S</string>
    <string name="sunday_prefix">D</string>
    <string name="tag_ico">ico</string>
    <string name="text_date_end">Data final</string>
    <string name="text_date_start">Data inicial</string>
    <string name="text_title_calendar">Calendário</string>
    <string name="thursday_prefix">Q</string>
    <string name="title_header_example">New June Book 15 pt\nLorem Ipsum dolor sit\namet, consectetur.</string>
    <string name="tuesday_prefix">T</string>
    <string name="wednesday_prefix">Q</string>

</resources>

EDIT: My gradle files

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

top-level build.gradle - project build gradle

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app build.gradle - my lib demo app

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.myappid"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 2
        versionName "1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':nextcomponents')

    compile 'com.android.support:appcompat-v7:27.0.1'
    compile 'com.wdullaer:materialdatetimepicker:2.1.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    testCompile 'junit:junit:4.12'
}

components build.gradle - my lib

apply plugin: 'com.android.library'

android {
    compileSdkVersion 27
    buildToolsVersion '26.0.2'

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 2
        versionName "1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile "com.android.support:appcompat-v7:27.0.1"
    compile "com.google.code.gson:gson:2.8.0"
    compile "com.android.support:design:27.0.1"
    compile 'com.intellij:annotations:12.0@jar'
    compile('org.apache.commons:commons-lang3:3.1') {
        transitive = true
    }
    compile 'com.airbnb.android:lottie:1.5.3'
    compile 'com.github.rubensousa:gravitysnaphelper:1.1'
    compile 'com.facebook.keyframes:keyframes:1.0'
}

Body:
Your DARKEN enum has a space in it:

<enum name="DARKEN " value="2"/>

I found this by running your question thru egrep:

egrep 'name="[^"]* [^"]*"'

This seems to be a problem in a library you're using: https://github.com/christophesmet/android_maskable_layout/blob/43b109a/library/src/main/res/values/attrs_maskable_framelayout.xml


问:
perl command line substitute of strings
perl has convenient command line syntax for substitution of files

```<code>perl -pe 's/key/replace/g' file
</code>```

I am wondering what is the one liner syntax for substitution of string?

```<code>perl -pe 's/key/replace/g' string
</code>```

doesn't work. It will complain

Can't open ppp: No such file or directory.

答:
You can use echo (or your operating system's equivalent) to send your string into your command-line Perl program.

```<code>$ echo hello | perl -pe 's/hello/goodbye/'
goodbye
</code>```

Title: perl command line substitute of strings

Body:
perl has convenient command line syntax for substitution of files

perl -pe 's/key/replace/g' file

I am wondering what is the one liner syntax for substitution of string?

perl -pe 's/key/replace/g' string

doesn't work. It will complain

Can't open ppp: No such file or directory.

Body:
You can use echo (or your operating system's equivalent) to send your string into your command-line Perl program.

$ echo hello | perl -pe 's/hello/goodbye/'
goodbye


问:
LNK1104 error when building Rhapsody 7.6.1 component
i'm using the Rhapsody 7.6.1 For C++ with the visual Studio 2010
already installed and set as described on this page: http://www-01.ibm.com/support/docview.wss?uid=swg21511885

when trying to build my component i face these two errors:

enter image description here

can you help me please ?

答:
To close this question for those who are following it, after few days of searching and working on this issue, i've noticed that the cause was a damaged ".exe" file whose role is to parse my project's Objects folder and create a text file "objs_files.lst" containing the name of all the generated object files of that folder:

/******objs_files.lst ******/

obj\Launcher.obj

obj\LauncherSimulationWin32.obj

obj\DistantFServer.obj

obj\HardwareDriversFactory.obj

...etc

/*********************************/

this file was not created since my "objectfilegenerator.exe" is damaged, so i've created a small c++ .exe to do that job ==> as a result both errors are solved.


问:
Error while building APK Android Studio 2.2.3
I am trying to generate a signed APK to test my app on a physical device. The app was working functionally before I tried to add the Google AdMob banner ad to my app. I keep getting this error:

```<code>Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzkf;
</code>```

Here is my build.gradle:

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.coolappsforall.fartboard"
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 2
        versionName "1.0.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false;
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services-ads:11.6.0'
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'

    })
    compile 'com.android.support:appcompat-v7:25.1.1'
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'
}
</code>```

Not exactly sure what is causing the problem, if anyone knows, or if you need anything else, please let me know.

Thank you very much for your time and assistance in this matter.

答:
```<code>// add line  multiDexEnabled true in defaultConfig

     defaultConfig {
            applicationId "com.coolappsforall.fartboard"
            minSdkVersion 14
            targetSdkVersion 25
            versionCode 2
            versionName "1.0.1"
    multiDexEnabled true
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }

//add below lines after closed bracts

dexOptions {
        javaMaxHeapSize "4g"
    }
</code>```

// change compilesdk version

compileSdkVersion 23

and

```<code>compile 'com.google.android.gms:play-services-ads:9.6.1'
compile 'com.google.android.gms:play-services-appindexing:9.6.1'
</code>```

Body:
I am trying to generate a signed APK to test my app on a physical device. The app was working functionally before I tried to add the Google AdMob banner ad to my app. I keep getting this error:

Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzkf;

Here is my build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.coolappsforall.fartboard"
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 2
        versionName "1.0.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false;
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services-ads:11.6.0'
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'

    })
    compile 'com.android.support:appcompat-v7:25.1.1'
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'
}

Not exactly sure what is causing the problem, if anyone knows, or if you need anything else, please let me know.

Thank you very much for your time and assistance in this matter.

Body:
// add line  multiDexEnabled true in defaultConfig

     defaultConfig {
            applicationId "com.coolappsforall.fartboard"
            minSdkVersion 14
            targetSdkVersion 25
            versionCode 2
            versionName "1.0.1"
    multiDexEnabled true
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }

//add below lines after closed bracts

dexOptions {
        javaMaxHeapSize "4g"
    }

// change compilesdk version

compileSdkVersion 23

and

compile 'com.google.android.gms:play-services-ads:9.6.1'
compile 'com.google.android.gms:play-services-appindexing:9.6.1'


问:
Display Column names against its corresponding values after using union all in mysql
I have a requirment where i am using union to merge multiple columns to a single column. But i also want to display corresponding column names of merged column values in new column as shown in Required table image.

I have tried the below query to merge column names

```<code>select 2am
  from hourchart
 union all
select 4am
  from hourchart
 union all
select 6am
  from hourchart;
</code>```

Please help!
Thanks in advance

Please help!
Thanks in advance

答:
You need to add the value to the selects:

```<code>select '2am' as columnname, `2am` as value from hourchart
union all
select '4am', `4am` from hourchart
union all
select '6am', `6am` from hourchart;
</code>```

Body:
I have a requirment where i am using union to merge multiple columns to a single column. But i also want to display corresponding column names of merged column values in new column as shown in Required table image.

I have tried the below query to merge column names

select 2am
  from hourchart
 union all
select 4am
  from hourchart
 union all
select 6am
  from hourchart;

Please help!
Thanks in advance

Please help!
Thanks in advance

Body:
You need to add the value to the selects:

select '2am' as columnname, `2am` as value from hourchart
union all
select '4am', `4am` from hourchart
union all
select '6am', `6am` from hourchart;


问:
PagingAndSortingRepository cannot be resolved
I'm try to use PagingAndSortingRepository from Spring Data:

```<code>import org.springframework.data.jpa.repository.JpaRepository;

public interface StudentRepository extends JpaRepository<Student, Integer> {}
</code>```

But I receive this error:

org.springframework.data.repository.PagingAndSortingRepository
can't be resolved

What wrong with my code and how can I fix it?

答:
I resolved this including spring-data-commons that included PagingAndSortingRepository

```<code><!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-commons -->
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-commons</artifactId>
    <version>2.0.1.RELEASE</version>
</dependency>
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I'm try to use PagingAndSortingRepository from Spring Data:

import org.springframework.data.jpa.repository.JpaRepository;

public interface StudentRepository extends JpaRepository<Student, Integer> {}

But I receive this error:

org.springframework.data.repository.PagingAndSortingRepository
can't be resolved

What wrong with my code and how can I fix it?

Body:
I resolved this including spring-data-commons that included PagingAndSortingRepository

<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-commons -->
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-commons</artifactId>
    <version>2.0.1.RELEASE</version>
</dependency>


问:
How can i open a new tab using protractor and Chrome browser
Here is a code (new tab doesn't open):

//open new tab in Chrome

```<code>browser.actions().sendKeys(protractor.Key.CONTROL +'t').perform();
</code>```

If we used code with 'a' - everything is fine:

//select all on the page

```<code>browser.actions().sendKeys(protractor.Key.CONTROL +'a').perform();
</code>```

protractor v.1.3.1

Chrome v.37

ChromeDriver v.2.10

WebDriver v.2.43

答:
If you really don't want to add an element to your DOM, then you can try this:

```<code>let url = https://google.com;
return browser.executeScript("return window.open(arguments[0], '_blank')", url);
//opens google.com in a new tab (works fine with Chrome. P.S. have only tested
// Chrome with Protractor).
</code>```

I had tried the above statement with a browser.wait(), see if you really need the wait as browser.executeScript() returns a promise itself, can just utilize the promise's success.

Also, I have observed that although it seems that the focus of the browser has changed to the newly opened tab, I was unable to access the elements of the new tab. To do that:

```<code>browser.getAllWindowHandles().then((handles) => {
    browser.switchTo().window(handles[1]);    // pass the index, here assuming that
                                              // there are only two tabs in the browser
})
</code>```

To know more about window.open(), you can visit this.

Body:
Here is a code (new tab doesn't open):

//open new tab in Chrome

browser.actions().sendKeys(protractor.Key.CONTROL +'t').perform();

If we used code with 'a' - everything is fine:

//select all on the page

browser.actions().sendKeys(protractor.Key.CONTROL +'a').perform();

protractor v.1.3.1

Chrome v.37

ChromeDriver v.2.10

WebDriver v.2.43

Body:
If you really don't want to add an element to your DOM, then you can try this:

let url = https://google.com;
return browser.executeScript("return window.open(arguments[0], '_blank')", url);
//opens google.com in a new tab (works fine with Chrome. P.S. have only tested
// Chrome with Protractor).

I had tried the above statement with a browser.wait(), see if you really need the wait as browser.executeScript() returns a promise itself, can just utilize the promise's success.

Also, I have observed that although it seems that the focus of the browser has changed to the newly opened tab, I was unable to access the elements of the new tab. To do that:

browser.getAllWindowHandles().then((handles) => {
    browser.switchTo().window(handles[1]);    // pass the index, here assuming that
                                              // there are only two tabs in the browser
})

To know more about window.open(), you can visit this.


问:
Format a date (string) with XSLT
There are a lot of questions/answers on this particular subject, but none seem to address the specific issue I have. I'm also a complete noob, so there's that ;-). I have the following XML being sent from an application to a piece of middleware. In that middleware, I'm capturing the XML and pulling out data. My last remaining challenge is to re-format a piece of string data that represents a date, that sits inside the <now></now> tags.

```<code><?xml version="1.0" encoding="UTF-8"?>
    <Body>
        <send_message xmlns="urn:xyztech:agent">
            <user>
                <now>2017-11-15T13:38:11+00:00</now>
                <company>xyz.demo</company>
            </user>
        </send_message>
    </Body>
</code>```

I'm using Apigee for the middleware, and need an XSL script to manipulate the date (to make it a bit cleaner - something like 15/11/2017 or 15.11.2017, and I don't want the time). I've tried several examples that I've seen, but none seem to work for me. Unfortunately, being the noob, I'm not really able to debug the errors that occur with those examples (e.g. failing to find the function from the namespace reference), and I'd really appreciate some assistance/guidance.

It would be pretty slick if I could use the XPath that I already have in the XSL that extracts the data:

```<code><Variable name="now" type="date">
    <XPath>//Envelope/Body/send_message/user/now</XPath>
</Variable>
</code>```

I've seen a solution for that, but I have a feeling that Apigee doesn't support XPath 2.0, so format-date($d,"[D]-[M]-[Y]") doesn't apper to be a viable option, either. Any/all help gratefully received...

答:
How about this:

```<code><xsl:variable name="onlydate" select="substring-before('2017-11-15T13:38:11+00:00', 'T')"/>
<xsl:variable name="tokens" select="tokenize($onlydate, '-')"/>
<xsl:value-of select="concat($tokens[3], '.', $tokens[2], '.', $tokens[1])"/>
</code>```

This worked for me and i got the output '15.11.2017'.

Substring-before returns you the string before your specified string
occours.

Tokenize splits the argument into an array on the given
character.

Title: Format a date (string) with XSLT

Body:
There are a lot of questions/answers on this particular subject, but none seem to address the specific issue I have. I'm also a complete noob, so there's that ;-). I have the following XML being sent from an application to a piece of middleware. In that middleware, I'm capturing the XML and pulling out data. My last remaining challenge is to re-format a piece of string data that represents a date, that sits inside the <now></now> tags.

<?xml version="1.0" encoding="UTF-8"?>

        <send_message xmlns="urn:xyztech:agent">
            <user>
                <now>2017-11-15T13:38:11+00:00</now>
                <company>xyz.demo</company>
            </user>
        </send_message>

I'm using Apigee for the middleware, and need an XSL script to manipulate the date (to make it a bit cleaner - something like 15/11/2017 or 15.11.2017, and I don't want the time). I've tried several examples that I've seen, but none seem to work for me. Unfortunately, being the noob, I'm not really able to debug the errors that occur with those examples (e.g. failing to find the function from the namespace reference), and I'd really appreciate some assistance/guidance.

It would be pretty slick if I could use the XPath that I already have in the XSL that extracts the data:

<Variable name="now" type="date">
    <XPath>//Envelope/Body/send_message/user/now</XPath>
</Variable>

I've seen a solution for that, but I have a feeling that Apigee doesn't support XPath 2.0, so format-date($d,"[D]-[M]-[Y]") doesn't apper to be a viable option, either. Any/all help gratefully received...

Body:
How about this:

<xsl:variable name="onlydate" select="substring-before('2017-11-15T13:38:11+00:00', 'T')"/>
<xsl:variable name="tokens" select="tokenize($onlydate, '-')"/>
<xsl:value-of select="concat($tokens[3], '.', $tokens[2], '.', $tokens[1])"/>

This worked for me and i got the output '15.11.2017'.

Substring-before returns you the string before your specified string
occours.

Tokenize splits the argument into an array on the given
character.


问:
apk running on AVD but not on phone
My compileSdkVersion is 26

minSdkVersion is 15

and TargetSdkVersion is 26

App runs fine on AVD of API level 22 but when installed on phone and opened it shows "Unfortunately APP has stopped". My phone is running in jellybean.

答: If your access any permission in your application. You should ask permission in runtime as well as in manifest file</p>

Title: apk running on AVD but not on phone


问:
Remove a specific item from a list using LINQ
I have a list containing some objects and want to use LINQ to remove a specific item but am not sure how to do that.</p>

```<code>foreach (var someobject in objectList)
{
    if (someobject.Number == 1) // There will only one item where Number == 1.
    {
        list.remove(someobject)
    }
}
</code>```

答:
You CAN use a foreach loop to remove an item from a list. The important thing is to use break to stop the loop once you have removed the item. If the loop continues after an item is removed from the list, an exception will be thrown.

```<code>foreach (var someobject in objectList)
{
    if (someobject.Number == 1) // There will only one item where Number == 1
    {
        objectList.remove(someobject);
        break;
    }
}
</code>```

However, this will ONLY work if there's only one object you want to remove, as in your case.

Body:
I have a list containing some objects and want to use LINQ to remove a specific item but am not sure how to do that.

foreach (var someobject in objectList)
{
    if (someobject.Number == 1) // There will only one item where Number == 1.
    {
        list.remove(someobject)
    }
}

Body:
You CAN use a foreach loop to remove an item from a list. The important thing is to use break to stop the loop once you have removed the item. If the loop continues after an item is removed from the list, an exception will be thrown.

foreach (var someobject in objectList)
{
    if (someobject.Number == 1) // There will only one item where Number == 1
    {
        objectList.remove(someobject);
        break;
    }
}

However, this will ONLY work if there's only one object you want to remove, as in your case.


问:
Change the character encode in PostgreSQL C language function
I am using PostgreSQL 9.5 64bit version on windows server.
The character encoding of the database is set to UTF8.

I'd like to create a function that manipulates multibyte strings.
(e.g. cleansing, replace etc.)

I copied C language logic for manipulating characters from a other system,
The logic assumes that the character code is sjis.

I do not want to change C language logic, so I want to convert from UTF8 to sjis in C language function of Postgresql.
Like the convert_to function. (However, since the convert_to function returns bytea type, I want to obtain it with TEXT type.)

Please tell me how to convert from UTF 8 to sjis in C language.

Create Function Script:

CREATE FUNCTION CLEANSING_STRING(character varying)
RETURNS character varying AS
'$libdir/MyFunc/CLEANSING_STRING.dll', 'CLEANSING_STRING'
LANGUAGE c VOLATILE STRICT;
```

<p>C Source:</p>

```#include <stdio.h>
#include <string.h>
#include <postgres.h>
#include <port.h>
#include <fmgr.h>
#include <stdlib.h>
#include <builtins.h>

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

extern PGDLLEXPORT Datum CLEANSING_STRING(PG_FUNCTION_ARGS);

PG_FUNCTION_INFO_V1(CLEANSING_STRING);
Datum CLEANSING_STRING(PG_FUNCTION_ARGS)
{

    // Get Arg
    text *arg1 = (text *)PG_GETARG_TEXT_P(0);

    // Text to Char[]
    char *arg;
    arg = text_to_cstring(arg1);

    // UTF8 to Sjis
    //Char *sjisChar[] = foo(arg);  // something like that..

    // Copied from other system.(Assumes that the character code is sjis.)
    cleansingString(sjisChar);
    replaceStrimg(sjisChar);

    // Sjis to UTF8
    //arg = bar(sjisChar);  // something like that..

    //Char[] to Text and Return
    PG_RETURN_TEXT_P(cstring_to_text(arg));
}
```

答:
Succeeded in the way I was taught by question comments.

#include <mb/pg_wchar.h> //Add to include.

...

Datum CLEANSING_STRING(PG_FUNCTION_ARGS)
{

    // Get Arg
    text *arg1 = (text *)PG_GETARG_TEXT_P(0);

    // Text to Char[]
    char *arg;
    arg = text_to_cstring(arg1);

    // UTF8 to Sjis
    Char *sjisChar[] = pg_server_to_any(arg, strlen(arg), PG_SJIS);

    // Copied from other system.(Assumes that the character code is sjis.)
    cleansingString(sjisChar);
    replaceStrimg(sjisChar);

    // Sjis to UTF8
    arg =  pg_any_to_server(sjisChar, strlen(sjisChar), PG_SJIS); //It converts from SJIS to server (UTF 8), the third argument sets the encoding of the conversion source.

    //Char[] to Text and Return
    PG_RETURN_TEXT_P(cstring_to_text(arg));
}
```

Body:
I am using PostgreSQL 9.5 64bit version on windows server.
The character encoding of the database is set to UTF8.

I'd like to create a function that manipulates multibyte strings.
(e.g. cleansing, replace etc.)

I copied C language logic for manipulating characters from a other system,
The logic assumes that the character code is sjis.

I do not want to change C language logic, so I want to convert from UTF8 to sjis in C language function of Postgresql.
Like the convert_to function. (However, since the convert_to function returns bytea type, I want to obtain it with TEXT type.)

Please tell me how to convert from UTF 8 to sjis in C language.

Create Function Script:

CREATE FUNCTION CLEANSING_STRING(character varying)
RETURNS character varying AS
'$libdir/MyFunc/CLEANSING_STRING.dll', 'CLEANSING_STRING'
LANGUAGE c VOLATILE STRICT;

C Source:

#include <stdio.h>
#include <string.h>
#include <postgres.h>
#include <port.h>
#include <fmgr.h>
#include <stdlib.h>
#include <builtins.h>

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

extern PGDLLEXPORT Datum CLEANSING_STRING(PG_FUNCTION_ARGS);

PG_FUNCTION_INFO_V1(CLEANSING_STRING);
Datum CLEANSING_STRING(PG_FUNCTION_ARGS)
{

    // Get Arg
    text *arg1 = (text *)PG_GETARG_TEXT_P(0);

    // Text to Char[]
    char *arg;
    arg = text_to_cstring(arg1);

    // UTF8 to Sjis
    //Char *sjisChar[] = foo(arg);  // something like that..

    // Copied from other system.(Assumes that the character code is sjis.)
    cleansingString(sjisChar);
    replaceStrimg(sjisChar);

    // Sjis to UTF8
    //arg = bar(sjisChar);  // something like that..

    //Char[] to Text and Return
    PG_RETURN_TEXT_P(cstring_to_text(arg));
}


问:
AWS Organizations service for creating SAAS app?
I'm thinking of using AWS Organizations service to manage a SAAS app.

So, for every user registered in this potential startup I intend to create an account in my AWS Organization so I can track how much I need to charge each account.

For the record, The application consists of a few AWS lamda functions and a dynamoDB database.

Considering there is a limit on a number of accounts in an organization, I just wanted to know is AWS Organizations service a good fit for my use-case? The problem is that at the moment, I don't know how many accounts I would need.

If it's not a good fit, is there any alternative you would recommend?

答:
In my opinion, creating separate accounts for lots of users / departments (more than say a dozen) is not good practice for budgeting and cost control.

Instead Amazon recommends using Cost Allocation Tags. You will have much better fine grained control over where your costs are.

Note: I do recommend using multiple accounts such as production, development, etc. This is more of a security / separation of responsibility than cost control.

Here is a link to help see if this will fit your objectives:

Using Cost Allocation Tags

Using Cost Allocation Tags

A tag is a label that you or AWS assigns to an AWS resource. Each tag
  consists of a key and a value. A key can have more than one value. You
  can use tags to organize your resources, and cost allocation tags to
  track your AWS costs on a detailed level. After you activate cost
  allocation tags, AWS uses the cost allocation tags to organize your
  resource costs on your cost allocation report, to make it easier for
  you to categorize and track your AWS costs. AWS provides two types of
  cost allocation tags, an AWS-generated tag and user-defined tags. AWS
  defines, creates, and applies the AWS-generated tag for you, and you
  define, create, and apply user-defined tags. You must activate both
  types of tags separately before they can appear in Cost Explorer or on
  a cost allocation report.


问:
Updated Wordpress - Media Library Blank - MediaElementPlayer is not defined
I updatet a wordpress multisite installation to the newest version 4.9. After the update, the media gallery in the backend is not showing any images. Its blank. The images are still in the uploads folder and i deactivated all plugins.

When i open the media gallery i get the following errors inside the console:

```<code>ReferenceError: MediaElementPlayer is not defined
TypeError: $(...).not(...).filter(...).mediaelementplayer is not a function
</code>```

答:
Which language have you activated?
I had the same problem, but in my case there where also the error:

TypeError: Language code must have format 2-3 letters and. optionally,
  hyphen, underscore followed by 2 more letters

In my case, the language "de_DE_formal" (Deutsch (Sie)) was activated.
After I set the language to the "de_DE" (Deutsch) the error was gone.

Body:
I updatet a wordpress multisite installation to the newest version 4.9. After the update, the media gallery in the backend is not showing any images. Its blank. The images are still in the uploads folder and i deactivated all plugins.

When i open the media gallery i get the following errors inside the console:

ReferenceError: MediaElementPlayer is not defined
TypeError: $(...).not(...).filter(...).mediaelementplayer is not a function


问:
unexpected response code 401 for URL
```<code>package com.example.murarilal.volley;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;

public class MainActivity extends AppCompatActivity {
    RequestQueue queue;
    ListView listView;
    List<Hero> heroList;

    private String url="API_KEY";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
         queue= Volley.newRequestQueue(this);
        home();

        listView = (ListView) findViewById(R.id.listView);
        heroList = new ArrayList<>();

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                Intent intent=new Intent(getApplicationContext(),ArticleActivity.class);
                intent.putExtra("description",url);
                startActivity(intent);
            }
        });
    }

    public void home()
    {
        JsonObjectRequest request =new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {

                try {
                    JSONObject obj = new JSONObject(String.valueOf(response));

                    JSONArray array = obj.getJSONArray("articles");

                    for (int i = 0; i < array.length(); i++) {
                        Hero hero=new Hero( (String) array.getJSONObject(i).get("title"),(String) array.getJSONObject(i).get("urlToImage"));
                        heroList.add(hero);
                    }

                    ListViewAdapter adapter = new ListViewAdapter(heroList, getApplicationContext());
                    listView.setAdapter(adapter);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
                , new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });
        queue.add(request);
    }
}

package com.example.murarilal.volley;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class ArticleActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_article);
        String url="https://newsapi.org/v1/articles?source=techcrunch&apiKey=59b308aec9f242fe98b527ab9ba93199";

        WebView webView=(WebView)findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new WebViewClient());

        Intent intent=getIntent();
        webView.loadDataWithBaseURL(url,null,intent.getStringExtra("description"),"text/html","UTF-8");
        webView.loadUrl(url);
    }
}
</code>```

https://newsapi.org/v2/top-headlines?sources=techcrunch&apiKey=d6eaad863cc640a7a6864d18196bea9e

I'm trying to fetch data from the above url but it returns an unexpected 401 response code. I checked the url and it's perfectly valid but the my code gives this error. when the emulator starts it shows blank activity

this the log error

11-17 16:20:20.804 14350-14350/com.example.murarilal.volley
  W/System.err: com.android.volley.AuthFailureError 11-17 16:20:20.804
  14350-14350/com.example.murarilal.volley W/System.err:     at
  com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:141)
  11-17 16:20:20.804 14350-14350/com.example.murarilal.volley
  W/System.err:     at
  com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:105)

答:
Have you tried adding this line in your gradle file.

I've implemented your code, the data is being called properly.

 compile 'com.mcxiaoke.volley:library-aar:1.0.0'```

Title: unexpected response code 401 for URL

Body:
package com.example.murarilal.volley;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;

public class MainActivity extends AppCompatActivity {
    RequestQueue queue;
    ListView listView;
    List<Hero> heroList;

    private String url="API_KEY";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
         queue= Volley.newRequestQueue(this);
        home();

        listView = (ListView) findViewById(R.id.listView);
        heroList = new ArrayList<>();

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                Intent intent=new Intent(getApplicationContext(),ArticleActivity.class);
                intent.putExtra("description",url);
                startActivity(intent);
            }
        });
    }

    public void home()
    {
        JsonObjectRequest request =new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {

                try {
                    JSONObject obj = new JSONObject(String.valueOf(response));

                    JSONArray array = obj.getJSONArray("articles");

                    for (int i = 0; i < array.length(); i++) {
                        Hero hero=new Hero( (String) array.getJSONObject(i).get("title"),(String) array.getJSONObject(i).get("urlToImage"));
                        heroList.add(hero);
                    }

                    ListViewAdapter adapter = new ListViewAdapter(heroList, getApplicationContext());
                    listView.setAdapter(adapter);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
                , new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });
        queue.add(request);
    }
}

package com.example.murarilal.volley;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class ArticleActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_article);
        String url="https://newsapi.org/v1/articles?source=techcrunch&apiKey=59b308aec9f242fe98b527ab9ba93199";

        WebView webView=(WebView)findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new WebViewClient());

        Intent intent=getIntent();
        webView.loadDataWithBaseURL(url,null,intent.getStringExtra("description"),"text/html","UTF-8");
        webView.loadUrl(url);
    }
}

https://newsapi.org/v2/top-headlines?sources=techcrunch&apiKey=d6eaad863cc640a7a6864d18196bea9e

I'm trying to fetch data from the above url but it returns an unexpected 401 response code. I checked the url and it's perfectly valid but the my code gives this error. when the emulator starts it shows blank activity

this the log error

11-17 16:20:20.804 14350-14350/com.example.murarilal.volley
  W/System.err: com.android.volley.AuthFailureError 11-17 16:20:20.804
  14350-14350/com.example.murarilal.volley W/System.err:     at
  com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:141)
  11-17 16:20:20.804 14350-14350/com.example.murarilal.volley
  W/System.err:     at
  com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:105)


问:
C malloc + free keeps increasing memory usage
I have a C application which processes large amount of data (100+ KB).
I am using malloc() to allocate the memory needed.

```<code>(char*)malloc(argLen + 18 + 2)
</code>```

And after the execution, I use free to release the allocated memory.

I understand that the free'd memory is not returned to the OS due to some reasons. My question is when I run the program again, instead of reusing the allocated memory, it just keeps on increasing the memory usage of my application.

Edit:
I am sorry for the confusion. The process is a WebSocket service. And it will not terminate unless the it is intentionally stopped. Does this mean that the process will keep on increasing its memory usage and will not let go of the allocated memory unless I restart it manually?

答:
I understand that the free'd memory is not returned to the OS due to some reasons.

What happens to the memory after calling free is implementation dependent. You tell the operating system that you're done with it. It may or may not release it. One reason for not releasing it is that it can be costly to allocate memory, and if the program asks for more memory the OS can just give back the same memory again.

My question is when I run the program again, instead of reusing the allocated memory, it just keeps on increasing the memory usage of my application.

Nope. As soon as your program terminates all of its allocated memory will be released. Or at least it should. Nevertheless, one could say that "it is not of your business".

I made a simple C program. It doesn't have any error checks, but you can use it to observe the behavior of your program while running it. The code for filling the array with random values and the code for printing it is solely there to make sure that nothing gets optimized away.

```<code>#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
    int *ptr;
    int size;
    char c='a';
    srand(time(NULL));

    while(c!='q')
    {
        printf("a - allocate memory\n");
        printf("f - free memory\n");
        printf("p - print array\n");
        printf("q - quit\n");
        printf("Choose: ");
        scanf(" %c", &c);
        if(c=='q')
            break;
        else if(c=='a') {
            printf("Size : ");
            scanf(" %d", &size);
            ptr=malloc(size * sizeof(*ptr));
            for(int i=0; i<size; i++)
                ptr[i]=rand();
        }
        else if (c=='f')
            free(ptr);
        else if(c=='p') {
            for(int i=0; i<size; i++)
                printf("%d", ptr[i]);
        }
    }
}
</code>```

While using it I was watching the process with top -p<PID> and it looked like this:

```<code>  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
28601 klutt     20   0    4172    692    616 S   0.0  0.0   0:00.00 a.out
</code>```

When I allocated and freed memory it sometimes showed and sometimes not. It made a difference more frequently if I specified a large size. And yes, I know you specified Windows and I used a Linux command, but I'm pretty sure you can find equivalent tools for analyzing a process in Windows.

Body:
I have a C application which processes large amount of data (100+ KB).
I am using malloc() to allocate the memory needed.

(char*)malloc(argLen + 18 + 2)

And after the execution, I use free to release the allocated memory.

I understand that the free'd memory is not returned to the OS due to some reasons. My question is when I run the program again, instead of reusing the allocated memory, it just keeps on increasing the memory usage of my application.

Edit:
I am sorry for the confusion. The process is a WebSocket service. And it will not terminate unless the it is intentionally stopped. Does this mean that the process will keep on increasing its memory usage and will not let go of the allocated memory unless I restart it manually?

Body:
I understand that the free'd memory is not returned to the OS due to some reasons.

What happens to the memory after calling free is implementation dependent. You tell the operating system that you're done with it. It may or may not release it. One reason for not releasing it is that it can be costly to allocate memory, and if the program asks for more memory the OS can just give back the same memory again.

My question is when I run the program again, instead of reusing the allocated memory, it just keeps on increasing the memory usage of my application.

Nope. As soon as your program terminates all of its allocated memory will be released. Or at least it should. Nevertheless, one could say that "it is not of your business".

I made a simple C program. It doesn't have any error checks, but you can use it to observe the behavior of your program while running it. The code for filling the array with random values and the code for printing it is solely there to make sure that nothing gets optimized away.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
    int *ptr;
    int size;
    char c='a';
    srand(time(NULL));

    while(c!='q')
    {
        printf("a - allocate memory\n");
        printf("f - free memory\n");
        printf("p - print array\n");
        printf("q - quit\n");
        printf("Choose: ");
        scanf(" %c", &c);
        if(c=='q')
            break;
        else if(c=='a') {
            printf("Size : ");
            scanf(" %d", &size);
            ptr=malloc(size * sizeof(*ptr));
            for(int i=0; i<size; i++)
                ptr[i]=rand();
        }
        else if (c=='f')
            free(ptr);
        else if(c=='p') {
            for(int i=0; i<size; i++)
                printf("%d", ptr[i]);
        }
    }
}

While using it I was watching the process with top -p<PID> and it looked like this:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
28601 klutt     20   0    4172    692    616 S   0.0  0.0   0:00.00 a.out

When I allocated and freed memory it sometimes showed and sometimes not. It made a difference more frequently if I specified a large size. And yes, I know you specified Windows and I used a Linux command, but I'm pretty sure you can find equivalent tools for analyzing a process in Windows.