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

Not working latest version of react native cli and java version 11 #165

Open
rexin1995 opened this issue Oct 20, 2022 · 11 comments
Open

Not working latest version of react native cli and java version 11 #165

rexin1995 opened this issue Oct 20, 2022 · 11 comments

Comments

@rexin1995
Copy link

Since expo dependency is mandatory not syncing with the latest version of react native CLI

@osvald0
Copy link

osvald0 commented Nov 1, 2022

I have the same problem. I can provide more information about it:

Example project to reproduce the error 👉 here.

React:

react: 18.1.0 => 18.1.0
react-native: 0.70.4 => 0.70.4

Android:

buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31

if (System.properties['os.arch'] == "aarch64") {
    // For M1 Users we need to use the NDK 24 which added support for aarch64
    ndkVersion = "24.0.8215888"
} else {
     // Otherwise we default to the side-by-side NDK version from AGP.
     ndkVersion = "21.4.7075529"
 }

Error:

info JS server already running.
info Installing the app...

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 5 up-to-date

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/osvaldo/Projects/Osvaldo/RN/ChartsTest/node_modules/@unimodules/react-native-adapter/android/build.gradle' line: 3

* What went wrong:
A problem occurred evaluating project ':unimodules_react-native-adapter'.
> Plugin with id 'maven' not found.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':unimodules_react-native-adapter'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

@rexin1995
Copy link
Author

hi osvald0
@unimodules/react-native-adapter this package has been deprecated you can use this (npx install-expo-modules@latest) to get expo dependency. I have tried this also but my kotlin version is not matching with expo kotlin dependency.
if you got any progress on this please let me know. thanks in advance..

@osvald0
Copy link

osvald0 commented Nov 2, 2022

@rexin1995 I tried that option too but I got more errors. I removed @unimodules/react-native-adapter and installed install-expo-modules@latest. Also I installed react-native-webview and I patched node_modules/react_native/index.js to solve an issue with deprecated prop-types (see error here).

Finally the result was this error:

Screen Shot 2022-11-02 at 09 30 36

@osvald0
Copy link

osvald0 commented Nov 16, 2022

Any comment about this issue?

@kristianfjelde
Copy link

Did you manage to get any further @osvald0? Are the devs even paying attention to this package or updating it? Seems like the documentation is outdated and will not work with later versions of Expo.

@osvald0
Copy link

osvald0 commented Jan 16, 2023

@kristianfjelde Nothing from my last message :(

@rexin1995
Copy link
Author

rexin1995 commented Jan 21, 2023 via email

@osvald0
Copy link

osvald0 commented Jan 30, 2023

@rexin1995 Could you fix the problem? It looks like the packages is abandoned. The last commit was 9 month ago.

@osvald0
Copy link

osvald0 commented Mar 2, 2023

This is the workaround I made to continue using fusioncharts until they update the package or we switch to another chart library.

import React from 'react';
import WebView from 'react-native-webview';
import { StyleSheet, View } from 'react-native';

const FUSIONCHARTS_BASE_HTML = `
    <!doctype html>
    <html>
    <head>
        <script src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script>
    </head>
    <body>
        <div id="chart-container"></div>
        <script>
            FusionCharts.ready(function () {
                var chart = new FusionCharts(CHART_CONFIG).render();
            });
        </script>
    </body>
    </html>
`;

const buildFusionChartsHTML = (chartConfig) => {
  return FUSIONCHARTS_BASE_HTML.replace(
    'CHART_CONFIG',
    JSON.stringify(chartConfig),
  );
};

const FusionCharts = ({ chartConfig }) => {
  const sourceHtml = buildFusionChartsHTML(chartConfig);

  return (
    <View style={styles.chartContainer}>
      <WebView originWhitelist={['*']} source={{ html: sourceHtml }} />
    </View>
  );
};

const styles = StyleSheet.create({
  chartContainer: {
    height: 200,
    width: '100%',
  },
});

export default FusionCharts;

You need to pay around the styling because the web version works a little bit different.

@osvald0
Copy link

osvald0 commented Mar 2, 2023

Another option is to create a web project only to "host" the fusioncharts project.

From the react native project:

import React from 'react';
import WebView from 'react-native-webview';
import { StyleSheet, View } from 'react-native';

const FusionCharts = ({ chartConfig }) => {
  const encodedConfig = encodeURI(JSON.stringify(chartConfig));

  return (
    <View style={styles.chartContainer}>
      <WebView
        source={{
          uri: `http://my_web_url.com?chart=${encodedConfig}`,
        }}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  chartContainer: {
    height: 400,
    width: '100%',
  },
});

export default FusionCharts;

And the react web project should be something like this:

import FusionCharts from "fusioncharts";
import ReactFC from "react-fusioncharts";
import Charts from "fusioncharts/fusioncharts.charts";
import FusionTheme from "fusioncharts/themes/fusioncharts.theme.fusion";

import { Routes, Route, useLocation } from "react-router-dom";

FusionCharts.options.license({
  key: 'LICENSE_KEY HERE',
  creditLabel: false,
});

ReactFC.fcRoot(FusionCharts, Charts, FusionTheme);

const decodeParams = (url) => {
  return decodeURIComponent(decodeURIComponent(url.split('chart=')[1]));
}

const App = () => {
  return (
    <Routes>
      <Route path="/" element={<Home />} />
    </Routes>
  );
}

const Home = () => {
  const { search } = useLocation();
  const data = decodeParams(search);
  return (
    <ReactFC {...JSON.parse(data)} />
  );
}

export default App;

It isn't perfect and both options have advantages and disadvantages. But It's the best I have right now with the lack of support from the fusioncharts team.

@rexin1995
Copy link
Author

rexin1995 commented Mar 3, 2023 via email

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

3 participants