-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Hi, I've got an issue using this library, I followed the manual installation section and when I want to open the settings:
import DeviceSettings from 'react-native-device-settings';
class Toto extends React.Component {
openSettings = () => {
DeviceSettings.open();
};
render() {
<Button onClick={this.openSettings}>
Open settings
</Button>
}
}I get a red screen error saying:
undefined is not an object (evaluating 'RNOpenSettings.generalSettings')
My MainActivity.java:
package com.MyApp.app;
import com.facebook.react.ReactActivity;
import com.rjblopes.opensettings.OpenSettingsPackage;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "MyApp";
}
}I've got these lines on my settings.graddle:
[...]
include ':react-native-device-settings'
project(':react-native-device-settings').projectDir = new File(settingsDir, '../node_modules/react-native-device-settings/android')
[...]And in my project-level build.gradle:
dependencies {
[...]
compile project(':react-native-device-settings')
[...]
}RN: 0.55.3
Library npm version: 1.2.0
Android device: Xiaomi Redmi Note 4X
Android simulator: API 27
[EDIT]
I fixed it, instead of doing what Readme.md is saying, I put:
import com.rjblopes.opensettings.OpenSettingsPackage; // Add this import
[...]
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 OpenSettingsPackage(), // Add this line
[...]
);
}
[...]on MainApplication.java and removed:
import com.rjblopes.opensettings.OpenSettingsPackage;from MainActivity.java
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels