React Native Splash Screen Android构建失败

时间:2018-09-17 11:46:57

标签: android react-native-android splash-screen

在android / app / build.gradle中

dependencies {
    compile project(':react-native-splash-screen')
}

在android / app / src / main / java / com / [projectName] /MainApplication.java

import org.devio.rn.splashscreen.SplashScreenReactPackage;

public class MainApplication extends Application implements ReactApplication {

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
            return BuildConfig.DEBUG;
        }

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

    @Override
    public ReactNativeHost getReactNativeHost() {
        return mReactNativeHost;
    }
}

每当我添加这些代码时,Android的构建就会失败并给出这些错误。

enter image description here

我在iOS和android中都将react-native-splash-screen程序包用于启动画面。可以在iOS上正常使用,构建失败只能在android上进行。

1 个答案:

答案 0 :(得分:0)

更新android / build.gradle

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        // Add ===========================
        maven {
            url 'https://maven.google.com'
        }
        // ===============================
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}