Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure for react-native run-android #82

Open
abhaychitnis opened this issue Jun 10, 2017 · 1 comment
Open

Build failure for react-native run-android #82

abhaychitnis opened this issue Jun 10, 2017 · 1 comment

Comments

@abhaychitnis
Copy link

My react native run android fails with following error:

C:\Users\abhay\React\infp_devices\android\app\src\main\java\com\infp_devices\MainActivity.java:19:
error: cannot find symbol
protected List getPackages() {
^ symbol: class List location: class MainActivity C:\Users\abhay\React\infp_devices\android\app\src\main\java\com\infp_devices\MainActivity.java:19:
error: cannot find symbol
protected List getPackages() {
^ symbol: class ReactPackage location: class MainActivity
C:\Users\abhay\React\infp_devices\android\app\src\main\java\com\infp_devices\MainActivity.java:18:
error: method does not override or implement a method from a supertype
@OverRide
^ C:\Users\abhay\React\infp_devices\android\app\src\main\java\com\infp_devices\MainActivity.java:21:
error: cannot find symbol
new MainReactPackage(),
^ symbol: class MainReactPackage location: class MainActivity
C:\Users\abhay\React\infp_devices\android\app\src\main\java\com\infp_devices\MainActivity.java:20:
error: cannot find symbol
return Arrays.asList(
^ symbol: class ReactPackage location: class MainActivity
C:\Users\abhay\React\infp_devices\android\app\src\main\java\com\infp_devices\MainActivity.java:20:
error: cannot find symbol
return Arrays.asList(
^ symbol: variable Arrays location: class MainActivity 6 errors :app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I have made following changes :

In android/setting.gradle :

include ':react-native-chart-android'
project(':react-native-chart-android').projectDir = new 
File(rootProject.projectDir, '../node_modules/react-native-chart-
android/android')

In android/app/build.gradle:

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_module
    compile project(':react-native-chart-android') //Changes to the code
}

My entire android/app/src/main/java/com/xxxxxxx/MainActivity.java, (XXXXXXX is my app name), looks as follows :

package com.xxxxxxx;  // xxxxxxx is my app name

import com.facebook.react.ReactActivity;

import cn.mandata.react_native_mpchart.MPChartPackage;  // <--- import

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "xxxxxxx";   //xxxxxxx is my app name
        }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new MPChartPackage());
}
}

My application code looks as follows :

import React from 'react';
import { View, Text } from 'react-native';

import {
  BarChart,
  CombinedChart
} from 'react-native-chart-android';

import { getBarData } from './graphComponent';


const graphDisplay = (props) => {
  // const myData = getBarData();
  return (
    <View style={{flex:1}}>
      <BarChart style={{flex:1}} data={getBarData()} />
   /View>
    );
});

export default graphDisplay;

I get a fatal ESLint error on the BarChart tag line as "Unterminated JSX content (Fatal)". However I have not got around to solving it. Not sure if it is relevant for this problem.

Please help

Edited:

My code for the imported getBarData() function is as follows:

export function getBarData() {
  const data = {
    xValues: ['1', '2', '3'],
    yValues: [
      {
        data: [4.0, 5.0, 6.0],
        label: 'test1',
        config: {
          color: 'blue'
        }
      },
      {
        data: [4.0, 5.0, 6.0],
        label: 'test2',
        config: {
          color: 'red'
        }
      },
      {
        data: [4.0, 5.0, 6.0],
        label: 'test2',
        config: {
          color: 'yellow'
        }
    }
    ]
  };
  return (data);
}
@taatiq882
Copy link

Did you found any solutions ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants