crazycodeboy / react-native-splash-screen

A splash screen for react-native, hide when application loaded ,it works on iOS and Android.
MIT License
5.61k stars 1.1k forks source link

error import com.cboy.rn.splashscreen.SplashScreen; #401

Open MonAiss opened 5 years ago

MonAiss commented 5 years ago

Run react-native info in your project and share the content. react-native info info React Native Environment Info: System: OS: Windows 7 CPU: (4) x64 Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz Memory: 879.25 MB / 3.87 GB Binaries: Yarn: 1.12.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.5.0 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5056338

What react-native-splash-screen version are you using? react-native-splash-screen >= 0.3.1

What platform does your issue occur on? (Android/iOS/Both) Android

Describe your issue as precisely as possible : 1) Steps to reproduce the issue or to explain in which case you get the issue First step(Download): -npm i react-native-splash-screen --save Second step(Plugin Installation): -react-native link react-native-splash-screen Third step(Plugin Configuration): -Android:

Update the MainActivity.java to use react-native-splash-screen via the following changes:

import android.os.Bundle; // here import com.facebook.react.ReactActivity; // react-native-splash-screen >= 0.3.1 import org.devio.rn.splashscreen.SplashScreen; // here // react-native-splash-screen < 0.3.1 import com.cboy.rn.splashscreen.SplashScreen; // here

public class MainActivity extends ReactActivity { @Override protected void onCreate(Bundle savedInstanceState) { SplashScreen.show(this); // here super.onCreate(savedInstanceState); } // ...other code } -iOS:

Update AppDelegate.m with the following additions:

import "AppDelegate.h"

import <React/RCTBundleURLProvider.h>

import <React/RCTRootView.h>

import "RNSplashScreen.h" // here

@implementation AppDelegate

@end Getting started Import react-native-splash-screen in your JS file.

import SplashScreen from 'react-native-splash-screen'

Android: Create a file called launch_screen.xml in app/src/main/res/layout (create the layout-folder if it doesn't exist). The contents of the file should be the following:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">

Customize your launch screen by creating a launch_screen.png-file and placing it in an appropriate drawable-folder. Android automatically scales drawable, so you do not necessarily need to provide images for all phone densities. You can create splash screens in the following folders:

drawable-ldpi drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi drawable-xxxhdpi Add a color called primary_dark in app/src/main/res/values/colors.xml

<?xml version="1.0" encoding="utf-8"?>

#000000

Optional steps:

If you want the splash screen to be transparent, follow these steps.

Open android/app/src/main/res/values/styles.xml and add true to the file. It should look like this:

Join a screenshot or video of the problem on the simulator or device?

Show us the code you are using? react-native run-android info Starting JS server... info Building and installing the app on the device (cd android && gradlew.bat ap p:installDebug)...

Task :app:compileDebugJavaWithJavac FAILED C:\Users\hp\other_version\openPharmaApp_1\android\app\src\main\java\com\openphar maapp_1\MainActivity.java:9: error: package com.cboy.rn.splashscreen does not ex ist import com.cboy.rn.splashscreen.SplashScreen; ^ C:\Users\hp\other_version\openPharmaApp_1\android\app\src\main\java\com\openphar maapp_1\MainApplication.java:7: error: package com.cboy.rn.splashscreen does not exist import com.cboy.rn.splashscreen.SplashScreenReactPackage; ^ 2 errors

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. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:comm and_line_warnings

BUILD FAILED in 10s 52 actionable tasks: 1 executed, 51 up-to-date error Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/getting-started.html error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag

MonAiss commented 5 years ago

i found out where is the problem by myself, if you had the same problem just remove that line in "MainApplication.java" and "MainActivity.java":

import com.cboy.rn.splashscreen.SplashScreenReactPackage;

pebojote commented 3 years ago

According to @crazycodeboy React Native Splash Screen Documentation:

import android.os.Bundle; // here
import com.facebook.react.ReactActivity;
// react-native-splash-screen >= 0.3.1
import org.devio.rn.splashscreen.SplashScreen; // here
// react-native-splash-screen < 0.3.1
import com.cboy.rn.splashscreen.SplashScreen; // here

So it means, if you use react-native-splash-screen >= 0.3.1. Then use: import org.devio.rn.splashscreen.SplashScreen;

But if you use react-native-splash-screen < 0.3.1. Then use: import com.cboy.rn.splashscreen.SplashScreen;

jaskaran-online commented 3 years ago

According to @crazycodeboy React Native Splash Screen Documentation:

import android.os.Bundle; // here
import com.facebook.react.ReactActivity;
// react-native-splash-screen >= 0.3.1
import org.devio.rn.splashscreen.SplashScreen; // here
// react-native-splash-screen < 0.3.1
import com.cboy.rn.splashscreen.SplashScreen; // here

So it means, if you use react-native-splash-screen >= 0.3.1. Then use: import org.devio.rn.splashscreen.SplashScreen;

But if you use react-native-splash-screen < 0.3.1. Then use: import com.cboy.rn.splashscreen.SplashScreen;

thanks