douglasjunior / react-native-easybluetooth-classic

⚛ A Library for easy implementation of Serial Bluetooth Classic on React Native (Android Only).
https://www.npmjs.com/package/easy-bluetooth-classic
MIT License
43 stars 7 forks source link

build application failed due to new ClassicPackage() #14

Closed AtlasMaxima-zz closed 6 years ago

AtlasMaxima-zz commented 6 years ago

The app build failed because import io.github.douglasjunior.ReactNativeEasyBluetooth.classic does not exist which failed to retrieve new MainReactPackage(), new ClassicPackage()

I followed the steps under installation. Would I need to put the ClassicPackage inside of my project folder somewhere?

douglasjunior commented 6 years ago

No, the only steps required are those displayed on Readme.

you can check if react-native link has linked everything correctly, see this example:

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 easy-bluetooth-classic dependency
dependencies {
+    compile project(':easy-bluetooth-classic')
    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 ':easy-bluetooth-classic'
+ project(':easy-bluetooth-classic').projectDir = new File(rootProject.projectDir, '../node_modules/easy-bluetooth-classic/android')
In android/app/src/main/java/com/example/MainApplication.java, add the ClassicPackage dependency.
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
+ import io.github.douglasjunior.ReactNativeEasyBluetooth.classic.ClassicPackage;                                                                              

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 ClassicPackage()                                                                                          
        );
    }
}
aidooyaw1992 commented 6 years ago

thank you for the help