AlbertBrand / react-native-android-tablayout

React Native Android TabLayout native component
140 stars 29 forks source link

App crashes with sample example #2

Closed fxhereng closed 8 years ago

fxhereng commented 8 years ago

As the title says, the app crashes for me (using react 0.17) : tab-layout-crash

Here is my code:

'use strict';

import {Tab, TabLayout} from 'react-native-android-tablayout';

const React = require('react-native');
const {
  StyleSheet,
  Component,
  View,
  Text,
  ScrollView,
  ToastAndroid,
} = React;

//I18n
const I18n = require('react-native-i18n-complete');
I18n.fallbacks = true; // Enable fallbacks if you want `en-US` and `en-GB` to fallback to `en`
I18n.translations = require('./res/Strings');

const Dimens = require('Fincaus/app/constants/Dimens');
const Colors = require('Fincaus/app/constants/Colors');

/**
* Enter invitation code
* @class MainPage
* @constructor
* @module Anuncios/views
*/
class MainPage extends Component {

  render() {
    return ( 
       <View style={styles.container}>
        <TabLayout>
          <Tab name="Tab 1" onTabSelected={()=>{ console.log('Tab 1 pressed'); }}/>
          <Tab name="Tab 2" onTabSelected={()=>{ console.log('Tab 2 pressed'); }}/>
          <Tab name="Tab 3" onTabSelected={()=>{ console.log('Tab 3 pressed'); }}/>
        </TabLayout>
      </View>
    );
  }

}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection: 'column',
    paddingLeft: Dimens.paddingPagePhone,
    paddingRight: Dimens.paddingPagePhone,
    paddingTop: Dimens.paddingPagePhone
  }
});

module.exports = MainPage;
AlbertBrand commented 8 years ago

Do you have a dependency on compile 'com.android.support:appcompat-v7:23.0.1' in your app/build.gradle ?

AlbertBrand commented 8 years ago

I just tried with 0.18-rc and it seems to be working properly (react-native init {projectName} -> then follow installation instructions). Not sure if this is due to 0.17 differences.

fxhereng commented 8 years ago

My bad, I had only compile 'com.android.support:appcompat-v7:23.1.1' and it's also necesary to add: compile 'com.android.support:design:23.1.1'

It's fixed now, thanks for helping :+1:

AlbertBrand commented 8 years ago

Officially your RN app should use 23.0.1 compat lib (in sync with the 23.0.1 build tools). But if it works for you, it's great :smile: