Gradle build error after adding facebook dependency in Android Studio

时间:2017-08-30 20:29:34

标签: java android gradle android-gradle facebook-android-sdk

I am creating an android app currently using firebase and facebook. I am trying to add a facebook login button, but when I add the line a.js I get the error

graphql-tools

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.0-alpha1) from [com.android.support:design:26.0.0-alpha1] AndroidManifest.xml:27:9-38 is also present at [com.android.support:cardview-v7:25.3.1] AndroidManifest.xml:24:9-31 value=(25.3.1). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:25:5-27:41 to override.

when I try to sync the gradle build. Here is what my app build.gradle file looks like:

class Searcher extends React.Component {
  constructor(props){
    super(props);
    this.state = {
      query: [],
      application: null,
    }
  }

  componentDidMount () {
    this.handleSearchRequest();
  }



  handleSearchRequest() {
    console.log('this.state', this.state);

    // we will replace BASE_URL with Anu's search api
    const BASE_URL = 'https://itunes.apple.com/search?';

    const FETCH_URL = BASE_URL + 'term=' + this.state.query + '&limit=4';

    console.log('FETCH_URL', FETCH_URL);

    fetch(FETCH_URL, {
      method: 'GET'
    })

    // Initial test to see what the console response is after hiting the API
    // .then(response => console.log('response', response));

      .then(response => response.json())
        // const applications = response.data
        //   this.setState({applications})

    //testing the json results
        .then(json => {
          // console.log('json', json)

          const application = json.results[0];
          this.setState({application})
          console.log({application})


        });
  }

  handleChange(event) {
    this.setState({ query: event.target.value})
  }


  render () {

    return (
      <div style={{position: 'relative'}}>

           {/* <IconButton
             iconStyle={styles.smallIcon}
             style={styles.iconButton}
             onClick={() => this.handleSearchRequest()}
           >
                <Search color={black} />

           </IconButton>

          <TextField
            underlineShow={false}
            id="searchId"
            value={this.state.query}
            fullWidth={true}
            style={styles.textField}
            inputStyle={styles.inputStyle}
            hintStyle={styles.hintStyle}
            onChange={event => {this.setState({ query: event.target.value}) }}
            onKeyPress={event => {
              if (event.key === 'Enter') {
                this.handleSearchRequest()
              }
            }}
          /> */}

        <br/>
        <br/>

        <ChipInput
          fullWidth={true}
          defaultValue={this.state.query}
          onChange={(event) => this.handleChange(event)}
        />

        {
          this.state.application != null
          ?
            <ResultItem
              {...this.props} {...this.state}
              application={this.state.application}/>
          : <div></div>
        }
      </div>

    );
  }
}

export default Searcher;

1 个答案:

答案 0 :(得分:0)

这是因为Facebook库使用com.android.support:cardview-v7:25.3.1并且您不能使用具有不同版本号的不同支持库。我解决了将compileSdkVersion降级为25以及将所有支持库降级为25.3.1的问题。您可以通过以下链接检查Facebook库是否正在使用com.android.support:cardview-v7:25.3.1Facebook Core Gradle

希望它有所帮助。