Skip to content

Manual linking Android

洪加煌 edited this page Aug 26, 2016 · 3 revisions
In android/build.gradle add the jitpack repository to your project.
allprojects {
    repositories {
        mavenLocal()
        jcenter()
+       maven {                                                                                                             
+          url "https://jitpack.io"                                                                                       
+       }                                                                                                                   
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$projectDir/../../node_modules/react-native/android"
        }
    }
}
In android/app/build.gradle, add the react-native-spinkit dependency
dependencies {
+    compile project(':react-native-spinkit')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}
In android/settings.gradle
include ':app'
+ include ':react-native-spinkit'
+ project(':react-native-spinkit').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-spinkit/android')
In android/app/src/main/java/com/example/MainApplication.java, add the RNSpinkitPackage dependency.
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
+ import com.react.rnspinkit.RNSpinkitPackage;                                                                              

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

    ...
    
    /**
     * A list of packages used by the app. If the app uses additional views
     * or modules besides the default ones, add more packages here.
     */
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
+           new RNSpinkitPackage()                                                                                          
        );
    }
}