问:
Swift 3- How to get button in UICollectionViewCell work
I am trying to implement an Edit button inside a cell.

Please refer to image:

What I done so far:

MainController:

```<code>class MainController: UICollectionViewController, UICollectionViewDelegateFlowLayout  {
  let imgCellId = "imgCellId"

  override func viewDidLoad() {
    collectionView?.backgroundColor = .white
    collectionView?.register(ImgItemCell.self, forCellWithReuseIdentifier: imgCellId)
  }

  override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: imgCellId, for: indexPath) as! ImgItemCell
      cell.editButton.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)

      return cell
  }

  func buttonPressed(){
    print("buttonPressed !")
  }

}
</code>```

ImgItemCell:

```<code>import Material

class ImgItemCell: UICollectionViewCell{

   override init(frame: CGRect){
       super.init(frame: frame)

       setupViews()
   }
   ...
   let editButton: RaisedButton = {
       let button = RaisedButton(title: "Edit", titleColor: .black) return button
   }()

  func setupViews(){
     ...
     addSubview(editButton)
     ...
  }

}
</code>```

Result: The button is not clickable. No log is printed when clicking on the button.

In android, I have done this by OnClickListener of button to perform action for each row. How can I do the same in Swift 3?

Solution: (it's working for me)

Hi all thank you for all suggestions, they’re more less the hint for me to come to the solution.

The root cause of my problem is view hierarchy (as @DatForis pointed out)

Explanation: I want a cell contains image and a layout of buttons so that I had view hierarchy as below

```<code>override func setupViews() {
    super.setupViews()

    addSubview(imgView)
    addSubview(buttonLayout)
    buttonLayout.addSubView(buttonList)
            buttonList.addSubview(editButton)
            buttonList.addSubview(shareButton)
  }
</code>```

this hierarchy somehow blocked the click event of button.

Therefore, I changed a bit in hierarchy

```<code>  override func setupViews() {
    super.setupViews()

    addSubview(imgView)
    addSubview(buttonLayout)
            buttonLayout.addSubview(editButton)
            buttonLayout.addSubview(shareButton)
   }
</code>```

and BAM ! it worked like a charm.

In fact, I need a proper explanation about why the hierarchy impact to children view.

By the way, I think most replies here are workable solution, but I selected @DonMag as final answer, because it’s clean and clear with a cool callback to Controller.

But again, my root problem is from view hierarchy.

答:
You might want to use a tag for a simpler approach, but I always implement a delegate pattern in the case of buttons inside cells

```<code>protocol MyCollectionViewCellDelegate: class {
    func button(wasPressedOnCell cell: MyCollectionViewCell)
}
class MyCollectionViewCell: UICollectionViewCell {
    weak var delegate: MyCollectionViewCellDelegate?
    var data: String = "DATA"
    @IBAction func buttonWasPressed(sender: UIButton){
        delegate?.button(wasPressedOnCell: self)
    }

}
class MainViewController: UIViewController, UICollectionViewDataSource {
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "reuse", for: indexPath) as! MyCollectionViewCell
        cell.delegate = self
        return cell
    }
}
extension MainViewController: MyCollectionViewCellDelegate{
    func button(wasPressedOnCell cell: MyCollectionViewCell) {
        //do what you want with the cell and data
    }
}
</code>```

Using this method will allow you to have multiple buttons inside a cell. Use a different delegate method for each button

Body:
I am trying to implement an Edit button inside a cell.

Please refer to image:

What I done so far:

MainController:

class MainController: UICollectionViewController, UICollectionViewDelegateFlowLayout  {
  let imgCellId = "imgCellId"

  override func viewDidLoad() {
    collectionView?.backgroundColor = .white
    collectionView?.register(ImgItemCell.self, forCellWithReuseIdentifier: imgCellId)
  }

  override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: imgCellId, for: indexPath) as! ImgItemCell
      cell.editButton.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)

      return cell
  }

  func buttonPressed(){
    print("buttonPressed !")
  }

}

ImgItemCell:

import Material

class ImgItemCell: UICollectionViewCell{

   override init(frame: CGRect){
       super.init(frame: frame)

       setupViews()
   }
   ...
   let editButton: RaisedButton = {
       let button = RaisedButton(title: "Edit", titleColor: .black) return button
   }()

  func setupViews(){
     ...
     addSubview(editButton)
     ...
  }

}

Result: The button is not clickable. No log is printed when clicking on the button.

In android, I have done this by OnClickListener of button to perform action for each row. How can I do the same in Swift 3?

Solution: (it's working for me)

Hi all thank you for all suggestions, they’re more less the hint for me to come to the solution.

The root cause of my problem is view hierarchy (as @DatForis pointed out)

Explanation: I want a cell contains image and a layout of buttons so that I had view hierarchy as below

override func setupViews() {
    super.setupViews()

    addSubview(imgView)
    addSubview(buttonLayout)
    buttonLayout.addSubView(buttonList)
            buttonList.addSubview(editButton)
            buttonList.addSubview(shareButton)
  }

this hierarchy somehow blocked the click event of button.

Therefore, I changed a bit in hierarchy

  override func setupViews() {
    super.setupViews()

    addSubview(imgView)
    addSubview(buttonLayout)
            buttonLayout.addSubview(editButton)
            buttonLayout.addSubview(shareButton)
   }

and BAM ! it worked like a charm.

In fact, I need a proper explanation about why the hierarchy impact to children view.

By the way, I think most replies here are workable solution, but I selected @DonMag as final answer, because it’s clean and clear with a cool callback to Controller.

But again, my root problem is from view hierarchy.

Body:
You might want to use a tag for a simpler approach, but I always implement a delegate pattern in the case of buttons inside cells

protocol MyCollectionViewCellDelegate: class {
    func button(wasPressedOnCell cell: MyCollectionViewCell)
}
class MyCollectionViewCell: UICollectionViewCell {
    weak var delegate: MyCollectionViewCellDelegate?
    var data: String = "DATA"
    @IBAction func buttonWasPressed(sender: UIButton){
        delegate?.button(wasPressedOnCell: self)
    }

}
class MainViewController: UIViewController, UICollectionViewDataSource {
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "reuse", for: indexPath) as! MyCollectionViewCell
        cell.delegate = self
        return cell
    }
}
extension MainViewController: MyCollectionViewCellDelegate{
    func button(wasPressedOnCell cell: MyCollectionViewCell) {
        //do what you want with the cell and data
    }
}

Using this method will allow you to have multiple buttons inside a cell. Use a different delegate method for each button


来源: stackexchange

问:
Twilio: Test message content without a physical phone
Disclaimer: I am completely new to Twilio.

I want to see if the content of the SMS is what I expect it to be, and if it doesn't return any error messages, without actually sending it to my phone.

It just seems very time consuming to send a message to my phone everytime I make a change to the code to check if it still works properly.

Also how can I use the test credentials to not get charged for sending message or receiving an automatic response. (I know it is explained on the Twilio site, but I found it confusing)

答:
Twilio developer evangelist here.

My recommendation is that if you want to ensure a message definitely appears as you expect on a phone, then you need to test with a phone.

If you are just testing that the text you are sending as a message is correct then I would stub out the Twilio methods in development to just log the message rather than contact the API.

Test credentials are useful for making sure you are making calls to the API successfully, however they will not send messages. There is no use of test credentials for receiving messages.

Let me know if that helps at all.

ContentLicense: CC BY-SA 3.0


问:
Finding intersection of two select query
I need to find intersection between the following queries in MYSQL

```<code>SELECT *
FROM project.backup_table
where project.backup_table.date <= (SELECT date FROM project.main_inout_table  ORDER BY date desc LIMIT 1)
    and project.backup_table.date >= (SELECT date FROM project.main_inout_table  ORDER BY date asc LIMIT 1)

SELECT *
FROM project.backup_table
WHERE concat(empid,date) not IN (SELECT concat(empid,date) FROM project.main_inout_table
</code>```

The tables are:

maintable

backuptable

My atttempt:

```<code>SELECT * FROM project.backup_table
where project.backup_table.date <= (SELECT date FROM project.main_inout_table
                                    ORDER BY date desc LIMIT 1) and project.backup_table.date >= (SELECT date FROM project.main_inout_table
                                                                      ORDER BY date asc LIMIT 1)  and exists (SELECT * FROM project.backup_table
                                                                        WHERE concat(empid,date) not IN (SELECT concat(empid,date)
                                                                         FROM project.main_inout_table));
</code>```

Problem: the details of tid 4 is present shouldn't it be filter out by second select query ?

答:
The intersection would be the rows that meet both conditions.  So, just bring the conditions together:

```<code>SELECT bt.*
FROM project.backup_table bt
WHERE bt.date <= (SELECT MAX(date) FROM project.main_inout_table mit) AND
      bt.date >= (SELECT MIN(date) FROM project.main_inout_table mit) AND
      NOT EXISTS (SELECT 1
                  FROM project.main_inout_table mit
                  WHERE mit.empid = bt.empid AND mit.date = bt.date
                 );
</code>```

Note the following changes:

The tables are given aliases, which are abbreviations for the table names.

The columns are all qualified with the table aliases.

The first two subqueries simply use MIN() and MAX().  These could be combined into one subquery or join, but this follows your original formulation.

The last subquery uses EXISTS rather than CONCAT().  Actually, this could also use IN with tuples (something that MySQL supports, but not all databases).

Body:
I need to find intersection between the following queries in MYSQL

SELECT *
FROM project.backup_table
where project.backup_table.date <= (SELECT date FROM project.main_inout_table  ORDER BY date desc LIMIT 1)
    and project.backup_table.date >= (SELECT date FROM project.main_inout_table  ORDER BY date asc LIMIT 1)

SELECT *
FROM project.backup_table
WHERE concat(empid,date) not IN (SELECT concat(empid,date) FROM project.main_inout_table

The tables are:

maintable

backuptable

My atttempt:

SELECT * FROM project.backup_table
where project.backup_table.date <= (SELECT date FROM project.main_inout_table
                                    ORDER BY date desc LIMIT 1) and project.backup_table.date >= (SELECT date FROM project.main_inout_table
                                                                      ORDER BY date asc LIMIT 1)  and exists (SELECT * FROM project.backup_table
                                                                        WHERE concat(empid,date) not IN (SELECT concat(empid,date)
                                                                         FROM project.main_inout_table));

Problem: the details of tid 4 is present shouldn't it be filter out by second select query ?

Body:
The intersection would be the rows that meet both conditions.  So, just bring the conditions together:

SELECT bt.*
FROM project.backup_table bt
WHERE bt.date <= (SELECT MAX(date) FROM project.main_inout_table mit) AND
      bt.date >= (SELECT MIN(date) FROM project.main_inout_table mit) AND
      NOT EXISTS (SELECT 1
                  FROM project.main_inout_table mit
                  WHERE mit.empid = bt.empid AND mit.date = bt.date
                 );

Note the following changes:

The tables are given aliases, which are abbreviations for the table names.

The columns are all qualified with the table aliases.

The first two subqueries simply use MIN() and MAX().  These could be combined into one subquery or join, but this follows your original formulation.

The last subquery uses EXISTS rather than CONCAT().  Actually, this could also use IN with tuples (something that MySQL supports, but not all databases).


问:
MySQL Stored Procedure: Executing prepared statement with IN parameter in select statement throws "Error Code: 1054 Unknown column"
I am new to MySQl stored procedure. I am trying to create a simple procedure with single IN parameter with execution of simple prepare select statement. Am using IN parameter directly in select statement while creating PREPARE, this throwing Unknown column error for IN parameter on executing prepare statement.

```<code>DELIMITER $$

DROP PROCEDURE IF EXISTS test_prep_stmt_two$$

CREATE PROCEDURE test_prep_stmt_two(IN user_id_in INT)
BEGIN
    #this line causing error
    PREPARE param_stmt FROM "select * from users u where u.user_id=user_id_in";

    EXECUTE param_stmt;

    DEALLOCATE PREPARE param_stmt;

END $$

DELIMITER ;

DELIMITER $$
</code>```

when I call procedure like CALL test_prep_stmt_two(1); am getting below error.

```<code>Error Code: 1054
Unknown column 'user_id_in' in 'where clause'
</code>```

But if I set IN param value to any variable inside procedure and use that in prepare select statement then it's working fine. Below procedure is working fine.

```<code>DELIMITER $$

DROP PROCEDURE IF EXISTS test_prep_stmt_three$$

CREATE PROCEDURE test_prep_stmt_three(IN user_id_in INT)
BEGIN

    SET @user_id_in=user_id_in;

    #this works fine
    PREPARE set_stmt FROM "select * from users u where u.user_id=@user_id_in";

    EXECUTE set_stmt;

    DEALLOCATE PREPARE set_stmt;

END $$

DELIMITER ;
</code>```

Please, can anyone explain me why using IN parameter in prepare select statement throwing error.

答:
```<code>DELIMITER $$

DROP PROCEDURE IF EXISTS test_prep_stmt_two$$

CREATE PROCEDURE test_prep_stmt_two(IN user_id_in INT)
BEGIN

  SET @t1 = CONCAT("SELECT * FROM users u WHERE u.user_id = '", user_id_in, "'");
  PREPARE param_stmt FROM @t1;
  EXECUTE param_stmt;
  DEALLOCATE PREPARE param_stmt;

END $$

DELIMITER ;
</code>```

Try the above code. Hope this will help.

Body:
I am new to MySQl stored procedure. I am trying to create a simple procedure with single IN parameter with execution of simple prepare select statement. Am using IN parameter directly in select statement while creating PREPARE, this throwing Unknown column error for IN parameter on executing prepare statement.

DELIMITER $$

DROP PROCEDURE IF EXISTS test_prep_stmt_two$$

CREATE PROCEDURE test_prep_stmt_two(IN user_id_in INT)
BEGIN
    #this line causing error
    PREPARE param_stmt FROM "select * from users u where u.user_id=user_id_in";

    EXECUTE param_stmt;

    DEALLOCATE PREPARE param_stmt;

END $$

DELIMITER ;

DELIMITER $$

when I call procedure like CALL test_prep_stmt_two(1); am getting below error.

Error Code: 1054
Unknown column 'user_id_in' in 'where clause'

But if I set IN param value to any variable inside procedure and use that in prepare select statement then it's working fine. Below procedure is working fine.

DELIMITER $$

DROP PROCEDURE IF EXISTS test_prep_stmt_three$$

CREATE PROCEDURE test_prep_stmt_three(IN user_id_in INT)
BEGIN

    SET @user_id_in=user_id_in;

    #this works fine
    PREPARE set_stmt FROM "select * from users u where u.user_id=@user_id_in";

    EXECUTE set_stmt;

    DEALLOCATE PREPARE set_stmt;

END $$

DELIMITER ;

Please, can anyone explain me why using IN parameter in prepare select statement throwing error.

Body:
DELIMITER $$

DROP PROCEDURE IF EXISTS test_prep_stmt_two$$

CREATE PROCEDURE test_prep_stmt_two(IN user_id_in INT)
BEGIN

  SET @t1 = CONCAT("SELECT * FROM users u WHERE u.user_id = '", user_id_in, "'");
  PREPARE param_stmt FROM @t1;
  EXECUTE param_stmt;
  DEALLOCATE PREPARE param_stmt;

END $$

DELIMITER ;

Try the above code. Hope this will help.

ContentLicense: CC BY-SA 4.0


问:
JSON Java 8 LocalDateTime format in Spring Boot
I'm having a small problem with formatting a Java 8 LocalDateTime in my Spring Boot Application. With 'normal' dates I have no problem, but the LocalDateTime fields are converted to the following:

```<code>"startDate" : {
    "year" : 2010,
    "month" : "JANUARY",
    "dayOfMonth" : 1,
    "dayOfWeek" : "FRIDAY",
    "dayOfYear" : 1,
    "monthValue" : 1,
    "hour" : 2,
    "minute" : 2,
    "second" : 0,
    "nano" : 0,
    "chronology" : {
      "id" : "ISO",
      "calendarType" : "iso8601"
    }
  }
</code>```

While I would like convert it to something like:

```<code>"startDate": "2015-01-01"
</code>```

My code looks like this:

```<code>@JsonFormat(pattern="yyyy-MM-dd")
@DateTimeFormat(iso = DateTimeFormat.ISO.TIME)
public LocalDateTime getStartDate() {
    return startDate;
}
</code>```

But either of the above annotations don't work, the date keeps getting formatted like above. Suggestions welcome!

答:
1) Dependency

```<code> compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.8.8'
</code>```

2) Annotation with date-time format.

```<code>public class RestObject {

    private LocalDateTime timestamp;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public LocalDateTime getTimestamp() {
        return timestamp;
    }
}
</code>```

3) Spring Config.

```<code>@Configuration
public class JacksonConfig {

    @Bean
    @Primary
    public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
        System.out.println("Config is starting.");
        ObjectMapper objectMapper = builder.createXmlMapper(false).build();
        objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
        return objectMapper;
    }
}
</code>```

Body:
I'm having a small problem with formatting a Java 8 LocalDateTime in my Spring Boot Application. With 'normal' dates I have no problem, but the LocalDateTime fields are converted to the following:

"startDate" : {
    "year" : 2010,
    "month" : "JANUARY",
    "dayOfMonth" : 1,
    "dayOfWeek" : "FRIDAY",
    "dayOfYear" : 1,
    "monthValue" : 1,
    "hour" : 2,
    "minute" : 2,
    "second" : 0,
    "nano" : 0,
    "chronology" : {
      "id" : "ISO",
      "calendarType" : "iso8601"
    }
  }

While I would like convert it to something like:

"startDate": "2015-01-01"

My code looks like this:

@JsonFormat(pattern="yyyy-MM-dd")
@DateTimeFormat(iso = DateTimeFormat.ISO.TIME)
public LocalDateTime getStartDate() {
    return startDate;
}

But either of the above annotations don't work, the date keeps getting formatted like above. Suggestions welcome!

Body:
1) Dependency

 compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.8.8'

2) Annotation with date-time format.

public class RestObject {

    private LocalDateTime timestamp;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public LocalDateTime getTimestamp() {
        return timestamp;
    }
}

3) Spring Config.

@Configuration
public class JacksonConfig {

    @Bean
    @Primary
    public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
        System.out.println("Config is starting.");
        ObjectMapper objectMapper = builder.createXmlMapper(false).build();
        objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
        return objectMapper;
    }
}


问:
Detecting is Div Out Of Screen
I coded dropdown menu via javascript(w/ jQuery) and CSS. Dropdown menu works fine but if dropdown menu located at corner for example rightmost or leftmost of user screen then if user opens the dropdown menu, it overflows to unseen area of window and causes horizontal scroll-bar.

How can I stop overflowing ?

HTML

```<code><ul class="dropdown">
    <li class="headlink">
        <a href="javascript://">Menu</a> <img src="/static/images/mini/sort_down.png" />

        <ul class="arrowlist invisible">
            <li>Hello 1</li>
            <li>Hello 2</li>
            <li>Hello 3</li>
        </ul>
    </li>
</ul>
</code>```

CSS

```<code>.dropdown {z-index: 1}
.dropdown .headlink{border:1px solid #C7C9CF;padding:4px 6px;}
.dropdown li{}
.dropdown a{outline:none}
.dropdown ul{z-index:100;border:1px solid #C7C9CF;-moz-border-radius: 4px; -webkit-border-radius: 4px;border-radius:4px;behavior: url(/static/css3pie.php);background: #FFF url("/static/images/grey_fade_back.png") repeat-x scroll bottom;padding:8px;position:absolute;top:-1px;left:-4px}
.dropdown ul li{margin:2px;white-space:nowrap}
</code>```

JS

```<code>$('.dropdown li.headlink')
    .click(function() {
        $(this).css('position', 'relative');
        $('ul', this).slideDown(100);
    });

        $('.dropdown li.headlink')
    .mouseleave(function(){
        var headlink = this;
        $('ul', this).slideUp(100, function(){
            $(headlink).css('position', 'static');
        })
    });
</code>```

答: I think you may need to store in a var the height in px of your drop down and check its y-offset. This post might be able to point you in the right direction How to see if an element in offscreen I wish I could provide you with working code.</p>

Title: Detecting is Div Out Of Screen

Body:
I coded dropdown menu via javascript(w/ jQuery) and CSS. Dropdown menu works fine but if dropdown menu located at corner for example rightmost or leftmost of user screen then if user opens the dropdown menu, it overflows to unseen area of window and causes horizontal scroll-bar.

How can I stop overflowing ?

HTML

        Menu

Hello 1

Hello 2

Hello 3

CSS

.dropdown {z-index: 1}
.dropdown .headlink{border:1px solid #C7C9CF;padding:4px 6px;}
.dropdown li{}
.dropdown a{outline:none}
.dropdown ul{z-index:100;border:1px solid #C7C9CF;-moz-border-radius: 4px; -webkit-border-radius: 4px;border-radius:4px;behavior: url(/static/css3pie.php);background: #FFF url("/static/images/grey_fade_back.png") repeat-x scroll bottom;padding:8px;position:absolute;top:-1px;left:-4px}
.dropdown ul li{margin:2px;white-space:nowrap}

JS

$('.dropdown li.headlink')
    .click(function() {
        $(this).css('position', 'relative');
        $('ul', this).slideDown(100);
    });

        $('.dropdown li.headlink')
    .mouseleave(function(){
        var headlink = this;
        $('ul', this).slideUp(100, function(){
            $(headlink).css('position', 'static');
        })
    });

ContentLicense: CC BY-SA 2.5


问:
Heroku, Django Collectstatic causing error
I am new to Heroku and I have been asked to look at someone's project hosted there (their previous supplier is not available).

This is a Django 1.4 project.

In order to learn if I've downloaded the project and loaded it to a new Heroku app.  Works fine, but I've had to set disable_collectstatic = 1 due to an error.  The original app is using an amazon s3 bucket for the static files so I can use those and all ok.

I'm now trying to setup my own s3 bucket and have it create the static files there.  I'm getting the following traceback

```<code>Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 70, in load_command_class
    return module.Command()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 57, in __init__
    self.storage.path('')
  File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 279, in _setup
    self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py", line 277, in get_storage_class
    raise ImproperlyConfigured('Error importing storage module %s: "%s"' % (module, e))
django.core.exceptions.ImproperlyConfigured: Error importing storage module storages.backends.s3boto: "cannot import name force_bytes"
</code>```

Interestingly I get the same ImproperlyConfigured error if I try and access admin from my 'new' project.

What is the cause of this and what am I missing?

答: So the problem here, which @e4c5 pointed towards, was packages being out of sync.  The problem wasn't boto but django-storages.  The requirements.txt file has django-storages==1.2a but that isn't being found so I went with v1.4.  When I worked through the code, I realised I needed to go backwards to 1.1.8 to get compatibility.  Now sorted.

Body:
I am new to Heroku and I have been asked to look at someone's project hosted there (their previous supplier is not available).

This is a Django 1.4 project.

In order to learn if I've downloaded the project and loaded it to a new Heroku app.  Works fine, but I've had to set disable_collectstatic = 1 due to an error.  The original app is using an amazon s3 bucket for the static files so I can use those and all ok.

I'm now trying to setup my own s3 bucket and have it create the static files there.  I'm getting the following traceback

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 70, in load_command_class
    return module.Command()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 57, in __init__
    self.storage.path('')
  File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 279, in _setup
    self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py", line 277, in get_storage_class
    raise ImproperlyConfigured('Error importing storage module %s: "%s"' % (module, e))
django.core.exceptions.ImproperlyConfigured: Error importing storage module storages.backends.s3boto: "cannot import name force_bytes"

Interestingly I get the same ImproperlyConfigured error if I try and access admin from my 'new' project.

What is the cause of this and what am I missing?


问:
The link doesn't work if I change its position in the code
Something weird is happening and I can't figure out what the problem might be.

var imageSliding = $('.box > .img');

//Lighbox & back shadow

$('.lightbox').click(function() {
  $('.backdrop, .box').animate({
    'opacity': '.50'
  }, 300, 'linear');
  $('.box').animate({
    'opacity': '1.00'
  }, 300, 'linear');
  $('.backdrop, .box').css('display', 'block');
});

$('.close').click(function() {
  close_box();
});

$('.backdrop').click(function() {
  close_box();
});

function close_box() {
  $('.backdrop, .box').animate({
    'opacity': '0'
  }, 300, 'linear', function() {
    $('.backdrop, .box').css('display', 'none');
  });
}

/* Slider */
var speed = 100;

$(".prev").click(function() {
  var now = $(this).parent().next("ul.gallery").children(":visible"),
    last = $(this).parent().next("ul.gallery").children(":last"),
    prev = now.prev();
  prev = prev.index() == -1 ? last : prev;
  now.fadeOut(speed, function() {
    prev.fadeIn(speed);
  });
});

$(".next").click(function() {
  var now = $(this).parent().next("ul.gallery").children(':visible'),
    first = $(this).parent().next("ul.gallery").children(':first'),
    next = now.next();
  next = next.index() == -1 ? first : next;
  now.fadeOut(speed, function() {
    next.fadeIn(speed);
  });
});

$(".gallery li").click(function() {
  var first = $(this).parent().children(':first'),
    next = $(this).next();
  next = next.index() == -1 ? first : next;
  $(this).fadeOut(speed, function() {
    next.fadeIn(speed);
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  font-family: Helvetica, Arial;
}

.backdrop {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 100%;
  background: #000;
  opacity: .0;
  filter: alpha(opacity=0);
  z-index: 50;
  display: none;
}

.box {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  left: 50%;
  background: white;
  text-align: left;
  z-index: 51;
  padding: 0;
  margin: 0;
  display: none;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  -moz-box-shadow: 0px 0px 5px #444444;
  -webkit-box-shadow: 0px 0px 5px #444444;
  box-shadow: 0px 0px 5px #444444;
  border: 10px solid #fff;
  width: 40%;
}

@media (min-width: 320px) and (max-width: 900px) {
  .box {
    width: 98%;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .box {
    width: 60%;
  }
}

@media (min-width: 1201px) {
  .box {
    width: 48%;
  }
}

.box img {
  width: 100%;
}

.caption {
  padding-top: 10px;
  font-size: 15px;
}

.prev,
.next {
  position: relative;
  padding: 3px;
  cursor: pointer;
  float: right;
  border: 1px solid black;
}

.prev:active,
.next:active {
  background-color: black;
  color: white;
}

.gallery li {
  display: none;
  list-style: none;
  margin-left: -40px;
}

.gallery li:first-child {
  display: block;
}

.gallery img {
  max-height: 550px;
}

.slideButtons {
  position: relative;
}</code>```

Welcome Within

  Open Lightbox

      Next
      Previous

This thing is called 'Caption'. Let me tell you:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
        dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

```

you see this class "sliderButtons"?
yes, when it's on the bottom of the ul it doesn't work, and whn I put it on the top of the ul, it works..kinda weird for me.

I want the buttons to be on the bottom though, I tried changing the span to  or <button> but not use.

答:
Since you are use .next() which target immediately following sibling thus it works when you place slideButtons before UL element

You should use .closest() to traverse up to .box then use .find()to target the desired element;

```<code>var gallery = $(this).closest('.box').find("ul.gallery"),
    now = gallery.children(":visible"),
    last = gallery.children(":last"),
</code>```

var imageSliding = $('.box > .img');
$('.lightbox').click(function() {
  $('.backdrop, .box').animate({
    'opacity': '.50'
  }, 300, 'linear');
  $('.box').animate({
    'opacity': '1.00'
  }, 300, 'linear');
  $('.backdrop, .box').css('display', 'block');
});

$('.close').click(function() {
  close_box();
});

$('.backdrop').click(function() {
  close_box();
});

function close_box() {
  $('.backdrop, .box').animate({
    'opacity': '0'
  }, 300, 'linear', function() {
    $('.backdrop, .box').css('display', 'none');
  });
}

/* Slider */
var speed = 100;

$(".prev").click(function() {
  var gallery = $(this).closest('.box').find("ul.gallery"),
    now = gallery.children(":visible"),
    last = gallery.children(":last"),
    prev = now.prev();
  prev = prev.index() == -1 ? last : prev;
  now.fadeOut(speed, function() {
    prev.fadeIn(speed);
  });
});

$(".next").click(function() {
  var gallery = $(this).closest('.box').find("ul.gallery"),
    now = gallery.children(":visible"),
    last = gallery.children(":last"),
    next = now.next();
  next = next.index() == -1 ? first : next;
  now.fadeOut(speed, function() {
    next.fadeIn(speed);
  });
});

$(".gallery li").click(function() {
  var first = $(this).parent().children(':first'),
    next = $(this).next();
  next = next.index() == -1 ? first : next;
  $(this).fadeOut(speed, function() {
    next.fadeIn(speed);
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  font-family: Helvetica, Arial;
}

.backdrop {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 100%;
  background: #000;
  opacity: .0;
  filter: alpha(opacity=0);
  z-index: 50;
  display: none;
}

.box {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  left: 50%;
  background: white;
  text-align: left;
  z-index: 51;
  padding: 0;
  margin: 0;
  display: none;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  -moz-box-shadow: 0px 0px 5px #444444;
  -webkit-box-shadow: 0px 0px 5px #444444;
  box-shadow: 0px 0px 5px #444444;
  border: 10px solid #fff;
  width: 40%;
}

@media (min-width: 320px) and (max-width: 900px) {
  .box {
    width: 98%;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .box {
    width: 60%;
  }
}

@media (min-width: 1201px) {
  .box {
    width: 48%;
  }
}

.box img {
  width: 100%;
}

.caption {
  padding-top: 10px;
  font-size: 15px;
}

.prev,
.next {
  position: relative;
  padding: 3px;
  cursor: pointer;
  float: right;
  border: 1px solid black;
}

.prev:active,
.next:active {
  background-color: black;
  color: white;
}

.gallery li {
  display: none;
  list-style: none;
  margin-left: -40px;
}

.gallery li:first-child {
  display: block;
}

.gallery img {
  max-height: 550px;
}

.slideButtons {
  position: relative;
}</code>```

Welcome Within

  Open Lightbox

      Next
      Previous

This thing is called 'Caption'. Let me tell you:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
        dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

```

Body:
Something weird is happening and I can't figure out what the problem might be.

var imageSliding = $('.box > .img');

//Lighbox & back shadow

$('.lightbox').click(function() {
  $('.backdrop, .box').animate({
    'opacity': '.50'
  }, 300, 'linear');
  $('.box').animate({
    'opacity': '1.00'
  }, 300, 'linear');
  $('.backdrop, .box').css('display', 'block');
});

$('.close').click(function() {
  close_box();
});

$('.backdrop').click(function() {
  close_box();
});

function close_box() {
  $('.backdrop, .box').animate({
    'opacity': '0'
  }, 300, 'linear', function() {
    $('.backdrop, .box').css('display', 'none');
  });
}

/* Slider */
var speed = 100;

$(".prev").click(function() {
  var now = $(this).parent().next("ul.gallery").children(":visible"),
    last = $(this).parent().next("ul.gallery").children(":last"),
    prev = now.prev();
  prev = prev.index() == -1 ? last : prev;
  now.fadeOut(speed, function() {
    prev.fadeIn(speed);
  });
});

$(".next").click(function() {
  var now = $(this).parent().next("ul.gallery").children(':visible'),
    first = $(this).parent().next("ul.gallery").children(':first'),
    next = now.next();
  next = next.index() == -1 ? first : next;
  now.fadeOut(speed, function() {
    next.fadeIn(speed);
  });
});

$(".gallery li").click(function() {
  var first = $(this).parent().children(':first'),
    next = $(this).next();
  next = next.index() == -1 ? first : next;
  $(this).fadeOut(speed, function() {
    next.fadeIn(speed);
  });
});

body {
  font-family: Helvetica, Arial;
}

.backdrop {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 100%;
  background: #000;
  opacity: .0;
  filter: alpha(opacity=0);
  z-index: 50;
  display: none;
}

.box {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  left: 50%;
  background: white;
  text-align: left;
  z-index: 51;
  padding: 0;
  margin: 0;
  display: none;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  -moz-box-shadow: 0px 0px 5px #444444;
  -webkit-box-shadow: 0px 0px 5px #444444;
  box-shadow: 0px 0px 5px #444444;
  border: 10px solid #fff;
  width: 40%;
}

@media (min-width: 320px) and (max-width: 900px) {
  .box {
    width: 98%;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .box {
    width: 60%;
  }
}

@media (min-width: 1201px) {
  .box {
    width: 48%;
  }
}

.box img {
  width: 100%;
}

.caption {
  padding-top: 10px;
  font-size: 15px;
}

.prev,
.next {
  position: relative;
  padding: 3px;
  cursor: pointer;
  float: right;
  border: 1px solid black;
}

.prev:active,
.next:active {
  background-color: black;
  color: white;
}

.gallery li {
  display: none;
  list-style: none;
  margin-left: -40px;
}

.gallery li:first-child {
  display: block;
}

.gallery img {
  max-height: 550px;
}

.slideButtons {
  position: relative;
}

Welcome Within

  Open Lightbox

      Next
      Previous

This thing is called 'Caption'. Let me tell you:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
        dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

you see this class "sliderButtons"?
yes, when it's on the bottom of the ul it doesn't work, and whn I put it on the top of the ul, it works..kinda weird for me.

I want the buttons to be on the bottom though, I tried changing the span to  or <button> but not use.

Body:
Since you are use .next() which target immediately following sibling thus it works when you place slideButtons before UL element

You should use .closest() to traverse up to .box then use .find()to target the desired element;

var gallery = $(this).closest('.box').find("ul.gallery"),
    now = gallery.children(":visible"),
    last = gallery.children(":last"),

var imageSliding = $('.box > .img');
$('.lightbox').click(function() {
  $('.backdrop, .box').animate({
    'opacity': '.50'
  }, 300, 'linear');
  $('.box').animate({
    'opacity': '1.00'
  }, 300, 'linear');
  $('.backdrop, .box').css('display', 'block');
});

$('.close').click(function() {
  close_box();
});

$('.backdrop').click(function() {
  close_box();
});

function close_box() {
  $('.backdrop, .box').animate({
    'opacity': '0'
  }, 300, 'linear', function() {
    $('.backdrop, .box').css('display', 'none');
  });
}

/* Slider */
var speed = 100;

$(".prev").click(function() {
  var gallery = $(this).closest('.box').find("ul.gallery"),
    now = gallery.children(":visible"),
    last = gallery.children(":last"),
    prev = now.prev();
  prev = prev.index() == -1 ? last : prev;
  now.fadeOut(speed, function() {
    prev.fadeIn(speed);
  });
});

$(".next").click(function() {
  var gallery = $(this).closest('.box').find("ul.gallery"),
    now = gallery.children(":visible"),
    last = gallery.children(":last"),
    next = now.next();
  next = next.index() == -1 ? first : next;
  now.fadeOut(speed, function() {
    next.fadeIn(speed);
  });
});

$(".gallery li").click(function() {
  var first = $(this).parent().children(':first'),
    next = $(this).next();
  next = next.index() == -1 ? first : next;
  $(this).fadeOut(speed, function() {
    next.fadeIn(speed);
  });
});

body {
  font-family: Helvetica, Arial;
}

.backdrop {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 100%;
  background: #000;
  opacity: .0;
  filter: alpha(opacity=0);
  z-index: 50;
  display: none;
}

.box {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  left: 50%;
  background: white;
  text-align: left;
  z-index: 51;
  padding: 0;
  margin: 0;
  display: none;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  -moz-box-shadow: 0px 0px 5px #444444;
  -webkit-box-shadow: 0px 0px 5px #444444;
  box-shadow: 0px 0px 5px #444444;
  border: 10px solid #fff;
  width: 40%;
}

@media (min-width: 320px) and (max-width: 900px) {
  .box {
    width: 98%;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .box {
    width: 60%;
  }
}

@media (min-width: 1201px) {
  .box {
    width: 48%;
  }
}

.box img {
  width: 100%;
}

.caption {
  padding-top: 10px;
  font-size: 15px;
}

.prev,
.next {
  position: relative;
  padding: 3px;
  cursor: pointer;
  float: right;
  border: 1px solid black;
}

.prev:active,
.next:active {
  background-color: black;
  color: white;
}

.gallery li {
  display: none;
  list-style: none;
  margin-left: -40px;
}

.gallery li:first-child {
  display: block;
}

.gallery img {
  max-height: 550px;
}

.slideButtons {
  position: relative;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container-fluid">
  <h1>Welcome Within</h1>
  <a href="#" class="lightbox">Open Lightbox</a>
  <div class="backdrop"></div>
  <div class="box">
    <ul class="gallery" id="olympGallery">
      <li><img src="http://urbanphenomena.net/imgs/trabzoni/trabzoni1.png" alt="" title="" /></li>
      <li><img src="http://urbanphenomena.net/imgs/trabzoni/trabzoni2.png" alt="" title="" /></li>
      <li><img src="http://urbanphenomena.net/imgs/trabzoni/trabzoni3.png" alt="" /></li>
    </ul>

    <div class="slideButtons">
      <span class="next">Next</span>
      <span class="prev">Previous</span>
    </div>
    <div class="caption">
      <p>This thing is called 'Caption'. Let me tell you:</p>
      <hr />
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
        dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </div>
  </div>
</div>


问:
allocation failed for scaled bitmap - Xamarin Visual Studio
I have a home page which is rich with images(20KB to 300KB feeds fectched online). I have another page which displays contacts and their images(20KB to 300KB) in a refactored circle. On the contact page, it is a tab with 3 fragments. When i switch from fragement 1 to 2 to  3 and repeat vice versa, my app stops working and throw an error.

Also, when the app launches the home page and i scroll through the feeds, when i move to the next activity (contact page), it lags a bit before it gets to the contact page (after some seconds, it crashes). Looking into my log, this is what i see and i have been trying finding my way through.

In all my activities, i included GC.Collect() to get more spaces for other activities but still not working for me.

I have by the way increase the java heap size in my application to 1G. I have also handled bitmaps on my contact page.

Any idea of what is causing this issue?

Exception

```<code>[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_nonvirtual_object_method'.
[Mono] Probing 'java_interop_jnienv_call_nonvirtual_object_method'.
[Mono] Found as 'java_interop_jnienv_call_nonvirtual_object_method'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_void_method_a'.
[Mono] Probing 'java_interop_jnienv_call_void_method_a'.
[Mono] Found as 'java_interop_jnienv_call_void_method_a'.
[Mono] Assembly Ref addref Xamarin.Android.Support.Design[0x7cf85210] -> Xamarin.Android.Support.Core.UI[0x7ce7c4a8]: 4
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_new_local_ref'.
[Mono] Probing 'java_interop_jnienv_new_local_ref'.
[Mono] Found as 'java_interop_jnienv_new_local_ref'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_boolean_method_a'.
[Mono] Probing 'java_interop_jnienv_call_boolean_method_a'.
[Mono] Found as 'java_interop_jnienv_call_boolean_method_a'.
[Adreno-EGL] <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
[Adreno-EGL] OpenGL ES Shader Compiler Version: E031.24.00.07
[Adreno-EGL] Build Date: 01/22/14 Wed
[Adreno-EGL] Local Branch: base_au149_adreno_au169_patches
[Adreno-EGL] Remote Branch:
[Adreno-EGL] Local Patches:
[Adreno-EGL] Reconstruct Branch:
[OpenGLRenderer] Enabling debug mode 0
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_int_method'.
[Mono] Probing 'java_interop_jnienv_call_int_method'.
[Mono] Found as 'java_interop_jnienv_call_int_method'.
[Mono] Assembly Ref addref Xamarin.Android.Support.v7.AppCompat[0x7d0e4ac0] -> Xamarin.Android.Support.Compat[0x7bbff618]: 4
[dalvikvm-heap] Grow heap (frag case) to 43.690MB for 14449048-byte allocation
[RecyclerView] No adapter attached; skipping layout
[RecyclerView] No adapter attached; skipping layout
[RecyclerView] No adapter attached; skipping layout
[RecyclerView] No adapter attached; skipping layout
[Mono] GC_TAR_BRIDGE bridges 24 objects 34 opaque 8 colors 24 colors-bridged 24 colors-visible 24 xref 6 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.05ms tarjan 0.10ms scc-setup 0.05ms gather-xref 0.00ms xref-setup 0.00ms cleanup 0.04ms
[Mono] GC_BRIDGE: Complete, was running for 25.34ms
[Mono] GC_MAJOR_SWEEP: major size: 784K in use: 199K
[Mono] GC_MAJOR: (user request) time 3.53ms, stw 3.72ms los size: 1024K in use: 8K
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_void_method'.
[Mono] Probing 'java_interop_jnienv_call_void_method'.
[Mono] Found as 'java_interop_jnienv_call_void_method'.
[Mono] Assembly Ref addref Xamarin.Android.Support.Fragment[0x7cfeb058] -> Xamarin.Android.Support.Core.UI[0x7ce7c4a8]: 5
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_get_field_id'.
[Mono] Probing 'java_interop_jnienv_get_field_id'.
[Mono] Found as 'java_interop_jnienv_get_field_id'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_get_int_field'.
[Mono] Probing 'java_interop_jnienv_get_int_field'.
[Mono] Found as 'java_interop_jnienv_get_int_field'.
[Mono] Assembly Ref addref Xamarin.Android.Support.v7.RecyclerView[0x7d4d3508] -> Xamarin.Android.Support.Core.UI[0x7ce7c4a8]: 6
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_get_object_array_element'.
[Mono] Probing 'java_interop_jnienv_get_object_array_element'.
[Mono] Found as 'java_interop_jnienv_get_object_array_element'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_set_boolean_field'.
[Mono] Probing 'java_interop_jnienv_set_boolean_field'.
[Mono] Found as 'java_interop_jnienv_set_boolean_field'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_set_int_field'.
[Mono] Probing 'java_interop_jnienv_set_int_field'.
[Mono] Found as 'java_interop_jnienv_set_int_field'.
Thread started: <Thread Pool> #2
Thread started: <Thread Pool> #3
[Mono] [0x853813e8] worker starting
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
[Mono] [0x85e6fb88] worker starting
[Mono] [0x85e6ffd8] worker starting
Thread started: <Thread Pool> #6
[Mono] [0x85e7bcf8] worker starting
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_get_static_field_id'.
[Mono] Probing 'java_interop_jnienv_get_static_field_id'.
[Mono] Found as 'java_interop_jnienv_get_static_field_id'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_get_static_object_field'.
[Mono] Probing 'java_interop_jnienv_get_static_object_field'.
[Mono] Found as 'java_interop_jnienv_get_static_object_field'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_nonvirtual_boolean_method_a'.
[Mono] Probing 'java_interop_jnienv_call_nonvirtual_boolean_method_a'.
[Mono] Found as 'java_interop_jnienv_call_nonvirtual_boolean_method_a'.
[Mono] [0x85e6ffd8] hill climbing, change max number of threads 4
[Choreographer] Skipped 34 frames!  The application may be doing too much work on its main thread.
[Mono] [0x85e6ffd8] hill climbing, change max number of threads 5
Thread started: <Thread Pool> #7
Thread started: <Thread Pool> #8
[Mono] [0x85de0cb8] worker starting
[Mono] [0x85e19438] worker starting
[dalvikvm-heap] Clamp target GC heap from 134.009MB to 128.000MB
[dalvikvm-heap] Clamp target GC heap from 138.888MB to 128.000MB
[dalvikvm-heap] Forcing collection of SoftReferences for 1575952-byte allocation
[dalvikvm-heap] Clamp target GC heap from 142.888MB to 128.000MB
[dalvikvm-heap] Out of memory on a 1575952-byte allocation.
[skia] --- allocation failed for scaled bitmap
[dalvikvm-heap] Clamp target GC heap from 142.888MB to 128.000MB
[dalvikvm-heap] Forcing collection of SoftReferences for 921616-byte allocation
[dalvikvm-heap] Clamp target GC heap from 142.888MB to 128.000MB
[dalvikvm-heap] Out of memory on a 921616-byte allocation.
[skia] --- allocation failed for scaled bitmap
[Mono] Image addref System.Runtime.Serialization[0x82d6fad0] -> System.Runtime.Serialization.dll[0x82d6ece8]: 2
[Mono] Prepared to set up assembly 'System.Runtime.Serialization' (System.Runtime.Serialization.dll)
[Mono] Assembly System.Runtime.Serialization[0x82d6fad0] added to domain RootDomain, ref_count=1
[Mono] AOT: image 'System.Runtime.Serialization.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.peaceapp.peaceapp-115/libaot-System.Runtime.Serialization.dll.so" not found
[Mono] AOT: image '/usr/local/lib/mono/aot-cache/arm/System.Runtime.Serialization.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.peaceapp.peaceapp-115/libaot-System.Runtime.Serialization.dll.so" not found
[Mono] Config attempting to parse: 'System.Runtime.Serialization.dll.config'.
[Mono] Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Runtime.Serialization/System.Runtime.Serialization.config'.
[Mono] Assembly Ref addref Mono.Android[0x7d63cb60] -> System.Runtime.Serialization[0x82d6fad0]: 2
[Mono] Assembly Ref addref System.Runtime.Serialization[0x82d6fad0] -> mscorlib[0x72798a08]: 31
Loaded assembly: System.Runtime.Serialization.dll [External]
Thread finished: <Thread Pool> #5
[Mono] [0x85e6ffd8] worker finishing
</code>```

答:
You can request LargeHeap within your manifest or via an attribute on your Application subclass

Manifest (Application Section)

```<code>android:largeHeap
</code>```

Application subclass attribute:

```<code>[Application(LargeHeap = true)]
public class XamarinAndroidApp : Application
{
   ~~~~
}
</code>```

This is just a request and depending upon the device you may or may not get an increased Java/Dalvik heap and your app should not rely on getting the increased heap size.

Most apps should not need this and should instead focus on reducing their overall memory usage for improved performance. Enabling this also does not guarantee a fixed increase in available memory, because some devices are constrained by their total available memory.

As your error shows, your Java heap is constrained to 128MB on that device and that is moderate heap size as they can range as low as 16MB on older low-end devices and on newer high-end devices this can go up to 512MB (and more on certain devices). But note, the heap size is not variable per device and is hardwired (/system/build.prop) and you can not control it other then having your app request a LargeHeap.

The real solution involves:

Ensuring that you have profiled your app's allocations and are not leaking memory

You are not holding references to Bitmaps via a hidden or non-displayed Fragment, View, etc.. in such a way that they can not be collected and released

You are using a Bitmap cache (i.e. LruCache) to manage how many Bitmaps are been held in memory at any give time

That the Bitmaps that are actually being held in memory are sized appropriately for the device's resolution, i.e.:

Resizing content on the device on the fly and file caching the results

Dynamically via the web service that you are requesting them from

Body:
I have a home page which is rich with images(20KB to 300KB feeds fectched online). I have another page which displays contacts and their images(20KB to 300KB) in a refactored circle. On the contact page, it is a tab with 3 fragments. When i switch from fragement 1 to 2 to  3 and repeat vice versa, my app stops working and throw an error.

Also, when the app launches the home page and i scroll through the feeds, when i move to the next activity (contact page), it lags a bit before it gets to the contact page (after some seconds, it crashes). Looking into my log, this is what i see and i have been trying finding my way through.

In all my activities, i included GC.Collect() to get more spaces for other activities but still not working for me.

I have by the way increase the java heap size in my application to 1G. I have also handled bitmaps on my contact page.

Any idea of what is causing this issue?

Exception

[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_nonvirtual_object_method'.
[Mono] Probing 'java_interop_jnienv_call_nonvirtual_object_method'.
[Mono] Found as 'java_interop_jnienv_call_nonvirtual_object_method'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_void_method_a'.
[Mono] Probing 'java_interop_jnienv_call_void_method_a'.
[Mono] Found as 'java_interop_jnienv_call_void_method_a'.
[Mono] Assembly Ref addref Xamarin.Android.Support.Design[0x7cf85210] -> Xamarin.Android.Support.Core.UI[0x7ce7c4a8]: 4
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_new_local_ref'.
[Mono] Probing 'java_interop_jnienv_new_local_ref'.
[Mono] Found as 'java_interop_jnienv_new_local_ref'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_boolean_method_a'.
[Mono] Probing 'java_interop_jnienv_call_boolean_method_a'.
[Mono] Found as 'java_interop_jnienv_call_boolean_method_a'.
[Adreno-EGL] <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
[Adreno-EGL] OpenGL ES Shader Compiler Version: E031.24.00.07
[Adreno-EGL] Build Date: 01/22/14 Wed
[Adreno-EGL] Local Branch: base_au149_adreno_au169_patches
[Adreno-EGL] Remote Branch:
[Adreno-EGL] Local Patches:
[Adreno-EGL] Reconstruct Branch:
[OpenGLRenderer] Enabling debug mode 0
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_int_method'.
[Mono] Probing 'java_interop_jnienv_call_int_method'.
[Mono] Found as 'java_interop_jnienv_call_int_method'.
[Mono] Assembly Ref addref Xamarin.Android.Support.v7.AppCompat[0x7d0e4ac0] -> Xamarin.Android.Support.Compat[0x7bbff618]: 4
[dalvikvm-heap] Grow heap (frag case) to 43.690MB for 14449048-byte allocation
[RecyclerView] No adapter attached; skipping layout
[RecyclerView] No adapter attached; skipping layout
[RecyclerView] No adapter attached; skipping layout
[RecyclerView] No adapter attached; skipping layout
[Mono] GC_TAR_BRIDGE bridges 24 objects 34 opaque 8 colors 24 colors-bridged 24 colors-visible 24 xref 6 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.05ms tarjan 0.10ms scc-setup 0.05ms gather-xref 0.00ms xref-setup 0.00ms cleanup 0.04ms
[Mono] GC_BRIDGE: Complete, was running for 25.34ms
[Mono] GC_MAJOR_SWEEP: major size: 784K in use: 199K
[Mono] GC_MAJOR: (user request) time 3.53ms, stw 3.72ms los size: 1024K in use: 8K
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_void_method'.
[Mono] Probing 'java_interop_jnienv_call_void_method'.
[Mono] Found as 'java_interop_jnienv_call_void_method'.
[Mono] Assembly Ref addref Xamarin.Android.Support.Fragment[0x7cfeb058] -> Xamarin.Android.Support.Core.UI[0x7ce7c4a8]: 5
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_get_field_id'.
[Mono] Probing 'java_interop_jnienv_get_field_id'.
[Mono] Found as 'java_interop_jnienv_get_field_id'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_get_int_field'.
[Mono] Probing 'java_interop_jnienv_get_int_field'.
[Mono] Found as 'java_interop_jnienv_get_int_field'.
[Mono] Assembly Ref addref Xamarin.Android.Support.v7.RecyclerView[0x7d4d3508] -> Xamarin.Android.Support.Core.UI[0x7ce7c4a8]: 6
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_get_object_array_element'.
[Mono] Probing 'java_interop_jnienv_get_object_array_element'.
[Mono] Found as 'java_interop_jnienv_get_object_array_element'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_set_boolean_field'.
[Mono] Probing 'java_interop_jnienv_set_boolean_field'.
[Mono] Found as 'java_interop_jnienv_set_boolean_field'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_set_int_field'.
[Mono] Probing 'java_interop_jnienv_set_int_field'.
[Mono] Found as 'java_interop_jnienv_set_int_field'.
Thread started: <Thread Pool> #2
Thread started: <Thread Pool> #3
[Mono] [0x853813e8] worker starting
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
[Mono] [0x85e6fb88] worker starting
[Mono] [0x85e6ffd8] worker starting
Thread started: <Thread Pool> #6
[Mono] [0x85e7bcf8] worker starting
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_get_static_field_id'.
[Mono] Probing 'java_interop_jnienv_get_static_field_id'.
[Mono] Found as 'java_interop_jnienv_get_static_field_id'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_get_static_object_field'.
[Mono] Probing 'java_interop_jnienv_get_static_object_field'.
[Mono] Found as 'java_interop_jnienv_get_static_object_field'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_nonvirtual_boolean_method_a'.
[Mono] Probing 'java_interop_jnienv_call_nonvirtual_boolean_method_a'.
[Mono] Found as 'java_interop_jnienv_call_nonvirtual_boolean_method_a'.
[Mono] [0x85e6ffd8] hill climbing, change max number of threads 4
[Choreographer] Skipped 34 frames!  The application may be doing too much work on its main thread.
[Mono] [0x85e6ffd8] hill climbing, change max number of threads 5
Thread started: <Thread Pool> #7
Thread started: <Thread Pool> #8
[Mono] [0x85de0cb8] worker starting
[Mono] [0x85e19438] worker starting
[dalvikvm-heap] Clamp target GC heap from 134.009MB to 128.000MB
[dalvikvm-heap] Clamp target GC heap from 138.888MB to 128.000MB
[dalvikvm-heap] Forcing collection of SoftReferences for 1575952-byte allocation
[dalvikvm-heap] Clamp target GC heap from 142.888MB to 128.000MB
[dalvikvm-heap] Out of memory on a 1575952-byte allocation.
[skia] --- allocation failed for scaled bitmap
[dalvikvm-heap] Clamp target GC heap from 142.888MB to 128.000MB
[dalvikvm-heap] Forcing collection of SoftReferences for 921616-byte allocation
[dalvikvm-heap] Clamp target GC heap from 142.888MB to 128.000MB
[dalvikvm-heap] Out of memory on a 921616-byte allocation.
[skia] --- allocation failed for scaled bitmap
[Mono] Image addref System.Runtime.Serialization[0x82d6fad0] -> System.Runtime.Serialization.dll[0x82d6ece8]: 2
[Mono] Prepared to set up assembly 'System.Runtime.Serialization' (System.Runtime.Serialization.dll)
[Mono] Assembly System.Runtime.Serialization[0x82d6fad0] added to domain RootDomain, ref_count=1
[Mono] AOT: image 'System.Runtime.Serialization.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.peaceapp.peaceapp-115/libaot-System.Runtime.Serialization.dll.so" not found
[Mono] AOT: image '/usr/local/lib/mono/aot-cache/arm/System.Runtime.Serialization.dll.so' not found: dlopen failed: library "/data/app-lib/com.companyname.peaceapp.peaceapp-115/libaot-System.Runtime.Serialization.dll.so" not found
[Mono] Config attempting to parse: 'System.Runtime.Serialization.dll.config'.
[Mono] Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Runtime.Serialization/System.Runtime.Serialization.config'.
[Mono] Assembly Ref addref Mono.Android[0x7d63cb60] -> System.Runtime.Serialization[0x82d6fad0]: 2
[Mono] Assembly Ref addref System.Runtime.Serialization[0x82d6fad0] -> mscorlib[0x72798a08]: 31
Loaded assembly: System.Runtime.Serialization.dll [External]
Thread finished: <Thread Pool> #5
[Mono] [0x85e6ffd8] worker finishing

Body:
You can request LargeHeap within your manifest or via an attribute on your Application subclass

Manifest (Application Section)

android:largeHeap

Application subclass attribute:

[Application(LargeHeap = true)]
public class XamarinAndroidApp : Application
{
   ~~~~
}

This is just a request and depending upon the device you may or may not get an increased Java/Dalvik heap and your app should not rely on getting the increased heap size.

Most apps should not need this and should instead focus on reducing their overall memory usage for improved performance. Enabling this also does not guarantee a fixed increase in available memory, because some devices are constrained by their total available memory.

As your error shows, your Java heap is constrained to 128MB on that device and that is moderate heap size as they can range as low as 16MB on older low-end devices and on newer high-end devices this can go up to 512MB (and more on certain devices). But note, the heap size is not variable per device and is hardwired (/system/build.prop) and you can not control it other then having your app request a LargeHeap.

The real solution involves:

Ensuring that you have profiled your app's allocations and are not leaking memory

You are not holding references to Bitmaps via a hidden or non-displayed Fragment, View, etc.. in such a way that they can not be collected and released

You are using a Bitmap cache (i.e. LruCache) to manage how many Bitmaps are been held in memory at any give time

That the Bitmaps that are actually being held in memory are sized appropriately for the device's resolution, i.e.:

Resizing content on the device on the fly and file caching the results

Dynamically via the web service that you are requesting them from


问:
How to run node server and java server in same command line in package.json start
I need to run :

```<code>node server.js
</code>```

And :

```<code>java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000
</code>```

I tried :

```<code>node server.js; java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000
</code>```

Or

```<code>node server.js && java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000
</code>```

But in both case the java server is not running when I ask it in the node applicaition. But if I run both commande in 2 differents console.
There is no problem.
Thank you

Edit: I try to do it in the npm start

答:
Ok so I found a way to do it :
My package.json:

```<code>"scripts": {
    "start-nlp" : "java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000 &",
    "start-node": "node server.js",
    "start": "npm run start-nlp && npm run start-node"
</code>```

},

Body:
I need to run :

node server.js

And :

java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000

I tried :

node server.js; java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000

Or

node server.js && java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000

But in both case the java server is not running when I ask it in the node applicaition. But if I run both commande in 2 differents console.
There is no problem.
Thank you

Edit: I try to do it in the npm start

Body:
Ok so I found a way to do it :
My package.json:

"scripts": {
    "start-nlp" : "java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000 &",
    "start-node": "node server.js",
    "start": "npm run start-nlp && npm run start-node"

},


问:
Running ffmpeg command on Android results in "Unable to find a suitable output format for ' -map 0:v:0 -map 1:a:0'"
I am using this command for replacing audio of video and genrate new video having new audio. Here file1 is my video.mp4, file2 is my audio.mp3 and output would be the output.mp4:

```<code>complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-c", "copy", " -map 0:v:0 -map 1:a:0", rootPath + "/output.mp4"};
</code>```

Below is My code:

```<code>    private void changeAudioofVideo(String selectedUri, String videoPath) {

    String[] complexCommand;

    File f = new File("/storage/emulated/0");
    if (!f.getParentFile().exists())
        f.getParentFile().mkdirs();
    if (!f.exists())
        try {
            f.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }

    file1 = new File(videoPath);
    if (file1.exists()) {
        Log.d("yes", "File 1 exists");
    } else {
        Log.d("no", "File 1 not exists");
    }

    file2 = new File(selectedUri);
    if (file2.exists()) {
        Log.d("yes", "File 1 exists");
    } else {
        Log.d("no", "File 1 not exists");
    }

    String rootPath = f.getPath();

    complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-c", "copy", " -map 0:v:0 -map 1:a:0", rootPath + "/output.mp4"};

    FFmpeg ffmpeg = FFmpeg.getInstance(this);

    try {
        //Load the binary
        ffmpeg.loadBinary(new LoadBinaryResponseHandler() {

            @Override
            public void onStart() {
            }

            @Override
            public void onFailure() {
            }

            @Override
            public void onSuccess() {
            }

            @Override
            public void onFinish() {
            }
        });
    } catch (FFmpegNotSupportedException e) {
        // Handle if FFmpeg is not supported by device
        Toast.makeText(getApplicationContext(), "Not Supported by Device", Toast.LENGTH_LONG).show();
    }

    try {

        final String finalRootPath = rootPath;
        ffmpeg.execute(complexCommand, new FFmpegExecuteResponseHandler() {
            @Override
            public void onSuccess(String message) {
                Log.d("Success", message);

                Toast.makeText(getApplicationContext(), "Successful" + finalRootPath.toString(), Toast.LENGTH_LONG).show();
                Uri path = Uri.parse(finalRootPath + "/output.mp4");
                playVideo(path.toString());

            }

            @Override
            public void onProgress(String message) {
                Log.d("progress", message);
                pd.show();
            }

            @Override
            public void onFailure(String message) {
                Log.d("failure", message);
                pd.dismiss();

            }

            @Override
            public void onStart() {
                Log.d("Start", "merge started");
            }

            @Override
            public void onFinish() {
                Log.d("finish", "merge finish");
                pd.dismiss();
            }
        });
    } catch (FFmpegCommandAlreadyRunningException e) {
        e.printStackTrace();
    }

   }
</code>```

Below is my output:

```<code>   05-26 18:39:35.533 29188-29188/com.example.codal.videotm D/failure: ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
                                                                  built with gcc 4.8 (GCC)
                                                                  configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-and    roid/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
                                                                  libavutil      55. 17.103 / 55. 17.103
                                                                  libavcodec     57. 24.102 / 57. 24.102
                                                                  libavformat    57. 25.100 / 57. 25.100
                                                                  libavdevice    57.  0.101 / 57.  0.101
                                                                  libavfilter     6. 31.100 /  6. 31.100
                                                                  libswscale      4.  0.100 /  4.  0.100
                                                                  libswresample   2.  0.101 /  2.  0.101
                                                                  libpostproc    54.  0.100 / 54.  0.100
                                                                Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/videokit/out2.mp4':
                                                                  Metadata:
                                                                    major_brand     : isom
                                                                    minor_version   : 512
                                                                    compatible_brands: isomiso2mp41
                                                                    encoder         : Lavf56.23.100
                                                                    comment         : Courtesy of National Geographic.  Used by Permission.
                                                                  Duration: 00:00:04.20, start: 0.046440, bitrate: 577 kb/s
                                                                    Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 160x120 [SAR 9:16 DAR 3:4], 521 kb/s, 30 fps, 30 tbr, 15360 tbn, 30 tbc (default)
                                                                    Metadata:
                                                                      handler_name    : VideoHandler
                                                                    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 50 kb/s (default)
                                                                    Metadata:
                                                                      handler_name    : SoundHandler
                                                                [mp3 @ 0xb86ade60] Skipping 0 bytes of junk at 132692.
                                                                [mjpeg @ 0xb86c9980] Changing bps to 8
                                                                [mp3 @ 0xb86ade60] Estimating duration from bitrate, this may be inaccurate
                                                                Input #1, mp3, from '/storage/emulated/0/Download/01 Kaari Kaari - Dobaara.mp3':
                                                                  Metadata:
                                                                    album           : Dobaara (SongsMp3.Co)
                                                                    artist          : Arko , Asees Kaur
                                                                    album_artist    : Arko & Asees Kaur
                                                                    composer        : Arko
                                                                    performer       : SongsMp3.Co
                                                                    copyright       : SongsMp3.Co
                                                                    disc            : 1/1
                                                                    encoded_by      : iTunes 12.6.0.100
                                                                    genre           : Bollywood
                                                                    TEXT            : SongsMp3.Co
                                                                    TPE4            : SongsMp3.Co
                                                                    TRSN            : SongsMp3.Co
                                                                    TOPE            : SongsMp3.Co
                                                                    TOLY            : SongsMp3.Co
                                                                    publisher       : SongsMp3.Co
                                                                    title           : Kaari Kaari (SongsMp3.Co)
                                                                    track           : 1/1
                                                                    date            : 2017
                                                                  Duration: 00:03:46.72, start: 0.000000, bitrate: 324 kb/s
                                                                    Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
                                                                    Stream #1:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 600x600 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
                                                                    Metadata:
                                                                      comment         : Cover (front)
                                                                [NULL @ 0xb86cab70] Unable to find a suitable output format for ' -map 0:v:0 -map 1:a:0'
                                                                 -map 0:v:0 -map 1:a:0: Invalid argument
05-26 18:39:35.543 29188-29188/com.example.codal.videotm D/ViewRootImpl: #3 mView = null
05-26 18:39:35.543 29188-29188/com.example.codal.videotm D/finish: merge finish
</code>```

答:
You are not consistent in the way you construct your command.

You should split it into individual arguments:

complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-c", "copy", "-map", "0:v:0", "-map", "1:a:0", rootPath + "/output.mp4"};

OwnerDisplayName: Akash Dubey

Body:
I am using this command for replacing audio of video and genrate new video having new audio. Here file1 is my video.mp4, file2 is my audio.mp3 and output would be the output.mp4:

complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-c", "copy", " -map 0:v:0 -map 1:a:0", rootPath + "/output.mp4"};

Below is My code:

    private void changeAudioofVideo(String selectedUri, String videoPath) {

    String[] complexCommand;

    File f = new File("/storage/emulated/0");
    if (!f.getParentFile().exists())
        f.getParentFile().mkdirs();
    if (!f.exists())
        try {
            f.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }

    file1 = new File(videoPath);
    if (file1.exists()) {
        Log.d("yes", "File 1 exists");
    } else {
        Log.d("no", "File 1 not exists");
    }

    file2 = new File(selectedUri);
    if (file2.exists()) {
        Log.d("yes", "File 1 exists");
    } else {
        Log.d("no", "File 1 not exists");
    }

    String rootPath = f.getPath();

    complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-c", "copy", " -map 0:v:0 -map 1:a:0", rootPath + "/output.mp4"};

    FFmpeg ffmpeg = FFmpeg.getInstance(this);

    try {
        //Load the binary
        ffmpeg.loadBinary(new LoadBinaryResponseHandler() {

            @Override
            public void onStart() {
            }

            @Override
            public void onFailure() {
            }

            @Override
            public void onSuccess() {
            }

            @Override
            public void onFinish() {
            }
        });
    } catch (FFmpegNotSupportedException e) {
        // Handle if FFmpeg is not supported by device
        Toast.makeText(getApplicationContext(), "Not Supported by Device", Toast.LENGTH_LONG).show();
    }

    try {

        final String finalRootPath = rootPath;
        ffmpeg.execute(complexCommand, new FFmpegExecuteResponseHandler() {
            @Override
            public void onSuccess(String message) {
                Log.d("Success", message);

                Toast.makeText(getApplicationContext(), "Successful" + finalRootPath.toString(), Toast.LENGTH_LONG).show();
                Uri path = Uri.parse(finalRootPath + "/output.mp4");
                playVideo(path.toString());

            }

            @Override
            public void onProgress(String message) {
                Log.d("progress", message);
                pd.show();
            }

            @Override
            public void onFailure(String message) {
                Log.d("failure", message);
                pd.dismiss();

            }

            @Override
            public void onStart() {
                Log.d("Start", "merge started");
            }

            @Override
            public void onFinish() {
                Log.d("finish", "merge finish");
                pd.dismiss();
            }
        });
    } catch (FFmpegCommandAlreadyRunningException e) {
        e.printStackTrace();
    }

   }

Below is my output:

   05-26 18:39:35.533 29188-29188/com.example.codal.videotm D/failure: ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
                                                                  built with gcc 4.8 (GCC)
                                                                  configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-and    roid/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
                                                                  libavutil      55. 17.103 / 55. 17.103
                                                                  libavcodec     57. 24.102 / 57. 24.102
                                                                  libavformat    57. 25.100 / 57. 25.100
                                                                  libavdevice    57.  0.101 / 57.  0.101
                                                                  libavfilter     6. 31.100 /  6. 31.100
                                                                  libswscale      4.  0.100 /  4.  0.100
                                                                  libswresample   2.  0.101 /  2.  0.101
                                                                  libpostproc    54.  0.100 / 54.  0.100
                                                                Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/videokit/out2.mp4':
                                                                  Metadata:
                                                                    major_brand     : isom
                                                                    minor_version   : 512
                                                                    compatible_brands: isomiso2mp41
                                                                    encoder         : Lavf56.23.100
                                                                    comment         : Courtesy of National Geographic.  Used by Permission.
                                                                  Duration: 00:00:04.20, start: 0.046440, bitrate: 577 kb/s
                                                                    Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 160x120 [SAR 9:16 DAR 3:4], 521 kb/s, 30 fps, 30 tbr, 15360 tbn, 30 tbc (default)
                                                                    Metadata:
                                                                      handler_name    : VideoHandler
                                                                    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 50 kb/s (default)
                                                                    Metadata:
                                                                      handler_name    : SoundHandler
                                                                [mp3 @ 0xb86ade60] Skipping 0 bytes of junk at 132692.
                                                                [mjpeg @ 0xb86c9980] Changing bps to 8
                                                                [mp3 @ 0xb86ade60] Estimating duration from bitrate, this may be inaccurate
                                                                Input #1, mp3, from '/storage/emulated/0/Download/01 Kaari Kaari - Dobaara.mp3':
                                                                  Metadata:
                                                                    album           : Dobaara (SongsMp3.Co)
                                                                    artist          : Arko , Asees Kaur
                                                                    album_artist    : Arko & Asees Kaur
                                                                    composer        : Arko
                                                                    performer       : SongsMp3.Co
                                                                    copyright       : SongsMp3.Co
                                                                    disc            : 1/1
                                                                    encoded_by      : iTunes 12.6.0.100
                                                                    genre           : Bollywood
                                                                    TEXT            : SongsMp3.Co
                                                                    TPE4            : SongsMp3.Co
                                                                    TRSN            : SongsMp3.Co
                                                                    TOPE            : SongsMp3.Co
                                                                    TOLY            : SongsMp3.Co
                                                                    publisher       : SongsMp3.Co
                                                                    title           : Kaari Kaari (SongsMp3.Co)
                                                                    track           : 1/1
                                                                    date            : 2017
                                                                  Duration: 00:03:46.72, start: 0.000000, bitrate: 324 kb/s
                                                                    Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
                                                                    Stream #1:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 600x600 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
                                                                    Metadata:
                                                                      comment         : Cover (front)
                                                                [NULL @ 0xb86cab70] Unable to find a suitable output format for ' -map 0:v:0 -map 1:a:0'
                                                                 -map 0:v:0 -map 1:a:0: Invalid argument
05-26 18:39:35.543 29188-29188/com.example.codal.videotm D/ViewRootImpl: #3 mView = null
05-26 18:39:35.543 29188-29188/com.example.codal.videotm D/finish: merge finish

OwnerDisplayName: slhck


问:
Wordpress inside docker container behind nginx proxy with ssl
I alm facing a problem on my server configuration, and I can't figure out what am I doing wrong.

So I have a nginx proxy like this :

```<code>server {
    listen *:443 ssl;
    ssl_certificate /root/software/keys/mywebsite.keys/mywebsite.crt;
    ssl_certificate_key /root/software/keys/mywebsite.keys/mywebsite.key;

    server_name www.mywebsite.com mywebsite.com;

    access_log /var/log/nginx/mywebsite.access.log;
    error_log /var/log/nginx/mywebsite.error.log;

    root /srv/new-website;
    index index.html index.htm index.php;

    location  / {
        proxy_redirect          off;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        client_body_buffer_size 128k;
        proxy_connect_timeout   90;
        proxy_send_timeout      90;
        proxy_read_timeout      90;
        proxy_buffers           32 4k;
        proxy_set_header X-Forwarded-Proto https;
        proxy_pass http://127.0.0.1:8082;
    }
}
</code>```

My container is listening on port 8082 in my docker-compose.yml file :

```<code>version: '2'

services:
    websites:
        build:
            context: ./dockerfiles/
            args:
                MYSQL_ROOT_PASSWORD: MyPassword
        volumes:
            - ./logs:/var/log
            - ./html:/var/www
            - ./mysql-data:/var/lib/mysql
        ports:
            - "8082:80"
</code>```

Inside my container, I am installing nginx, with this configuration :

```<code>server {
    listen *:80;

    server_name www.mywebsite.com mywebsite.com;

    access_log /var/log/nginx/mywebsite.access.log;
    error_log /var/log/nginx/mywebsite.error.log;

    root /var/www/mywebsite;
    index index.html index.htm index.php;

    # WordPress single blog rules.
    # Designed to be included in any server {} block.

    # Uncomment the code below to use htpasswd authentication
    #location ~* (wp-login)\.php$ {
    #    auth_basic            "Administrator Login";
    #    auth_basic_user_file  /full/path/to/.htpasswd;
    #}

    # This order might seem weird - this is attempted to match last if rules below fail.
    # http://wiki.nginx.org/HttpCoreModule
    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    # Directives to send expires headers and turn off 404 error logging.
    location ~* ^.+\.    (ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       access_log off; log_not_found off; expires max;
    }

    # Uncomment one of the lines below for the appropriate caching plugin (if used).
    #include global/wordpress-wp-super-cache.conf;
    #include global/wordpress-w3-total-cache.conf;

    location ~ [^/]\.php(/|$) {

        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        fastcgi_index index.php;
        include fcgi.conf;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}
</code>```

I alos configured my woordpress site with inside the wp-config.php

```<code>define('FORCE_SSL_ADMIN',   true);
define('FORCE_SSL_LOGIN',   true);
define('FORCE_SSL_CONTENT', true);
</code>```

And changed the url inside the databse with the correct url https://www.mywebsite.com

My proble is, I've got the ERR_TOO_MANY_REDIRECTS problem. The proxy seems to work well, since I have some nginx logs inside the container :

```<code>[20/Mar/2017:10:50:17 +0100] "GET /wp-login.php HTTP/1.1" 302 5 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
</code>```

Thanks all for the help you can provide.

EDIT 1 :

So I continue on my problem, and probably find some answers. The problem seems to be on wordpress, and not on the proxy configuration.

If I add :

```<code>define('WP_CACHE', true); // Added by W3 Total Cache
echo 'test';exit();
</code>```

inside the wp-config.php, my website is loaded with my correct certificate, and eveything is working well. So my problem seems to be on wordpress, which is looping on https, but I can't figure out why. I will try to debug step by step.

答:
Just had a similar problem setting everything up.  Below is an example YAML file that worked for me.</p>

```<code>version: '2'

services:

  wordpress:
    image: wordpress
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_PASSWORD: MyPassword
      VIRTUAL_HOST: example.com # replace with real domain
      LETSENCRYPT_HOST: example.com # replace with real domain
      LETSENCRYPT_EMAIL: email@email.com # replace with real email

  mysql:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: MyPassword

  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - /etc/certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /etc/nginx/vhost.d
      - /usr/share/nginx/html
    labels:
      com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: letsencrypt
    volumes:
      - /etc/certs:/etc/nginx/certs:rw
      - /var/run/docker.sock:/var/run/docker.sock:ro
    volumes_from:
      - nginx-proxy
</code>```

Body:
I alm facing a problem on my server configuration, and I can't figure out what am I doing wrong.

So I have a nginx proxy like this :

server {
    listen *:443 ssl;
    ssl_certificate /root/software/keys/mywebsite.keys/mywebsite.crt;
    ssl_certificate_key /root/software/keys/mywebsite.keys/mywebsite.key;

    server_name www.mywebsite.com mywebsite.com;

    access_log /var/log/nginx/mywebsite.access.log;
    error_log /var/log/nginx/mywebsite.error.log;

    root /srv/new-website;
    index index.html index.htm index.php;

    location  / {
        proxy_redirect          off;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        client_body_buffer_size 128k;
        proxy_connect_timeout   90;
        proxy_send_timeout      90;
        proxy_read_timeout      90;
        proxy_buffers           32 4k;
        proxy_set_header X-Forwarded-Proto https;
        proxy_pass http://127.0.0.1:8082;
    }
}

My container is listening on port 8082 in my docker-compose.yml file :

version: '2'

services:
    websites:
        build:
            context: ./dockerfiles/
            args:
                MYSQL_ROOT_PASSWORD: MyPassword
        volumes:
            - ./logs:/var/log
            - ./html:/var/www
            - ./mysql-data:/var/lib/mysql
        ports:
            - "8082:80"

Inside my container, I am installing nginx, with this configuration :

server {
    listen *:80;

    server_name www.mywebsite.com mywebsite.com;

    access_log /var/log/nginx/mywebsite.access.log;
    error_log /var/log/nginx/mywebsite.error.log;

    root /var/www/mywebsite;
    index index.html index.htm index.php;

    # WordPress single blog rules.
    # Designed to be included in any server {} block.

    # Uncomment the code below to use htpasswd authentication
    #location ~* (wp-login)\.php$ {
    #    auth_basic            "Administrator Login";
    #    auth_basic_user_file  /full/path/to/.htpasswd;
    #}

    # This order might seem weird - this is attempted to match last if rules below fail.
    # http://wiki.nginx.org/HttpCoreModule
    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    # Directives to send expires headers and turn off 404 error logging.
    location ~* ^.+\.    (ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       access_log off; log_not_found off; expires max;
    }

    # Uncomment one of the lines below for the appropriate caching plugin (if used).
    #include global/wordpress-wp-super-cache.conf;
    #include global/wordpress-w3-total-cache.conf;

    location ~ [^/]\.php(/|$) {

        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        fastcgi_index index.php;
        include fcgi.conf;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

I alos configured my woordpress site with inside the wp-config.php

define('FORCE_SSL_ADMIN',   true);
define('FORCE_SSL_LOGIN',   true);
define('FORCE_SSL_CONTENT', true);

And changed the url inside the databse with the correct url https://www.mywebsite.com

My proble is, I've got the ERR_TOO_MANY_REDIRECTS problem. The proxy seems to work well, since I have some nginx logs inside the container :

[20/Mar/2017:10:50:17 +0100] "GET /wp-login.php HTTP/1.1" 302 5 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"

Thanks all for the help you can provide.

EDIT 1 :

So I continue on my problem, and probably find some answers. The problem seems to be on wordpress, and not on the proxy configuration.

If I add :

define('WP_CACHE', true); // Added by W3 Total Cache
echo 'test';exit();

inside the wp-config.php, my website is loaded with my correct certificate, and eveything is working well. So my problem seems to be on wordpress, which is looping on https, but I can't figure out why. I will try to debug step by step.

Body:
Just had a similar problem setting everything up.  Below is an example YAML file that worked for me.

version: '2'

services:

  wordpress:
    image: wordpress
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_PASSWORD: MyPassword
      VIRTUAL_HOST: example.com # replace with real domain
      LETSENCRYPT_HOST: example.com # replace with real domain
      LETSENCRYPT_EMAIL: email@email.com # replace with real email

  mysql:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: MyPassword

  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - /etc/certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /etc/nginx/vhost.d
      - /usr/share/nginx/html
    labels:
      com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: letsencrypt
    volumes:
      - /etc/certs:/etc/nginx/certs:rw
      - /var/run/docker.sock:/var/run/docker.sock:ro
    volumes_from:
      - nginx-proxy