$ npm install react-native-gpu-info --save
$ react-native link react-native-gpu-info
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNGpuInfoPackage;
to the imports at the top of the file - Add
new RNGpuInfoPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-gpu-info' project(':react-native-gpu-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gpu-info/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-gpu-info')
Within your host activity add the following code;
public class MainActivity extends ReactActivity {
private GlSurfaceInspector surfaceInspector = new GlSurfaceInspector();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
surfaceInspector.init(this);
}
@Override
protected void onPause() {
super.onPause();
surfaceInspector.onPause();
}
@Override
protected void onResume() {
super.onResume();
surfaceInspector.onResume();
}
}
Then in your Javascript code import the library;
import RNGpuInfo from 'react-native-gpu-info';
And retrieve the name of the GPU chip via;
const glRenderer = RNGpuInfo.getGlRenderer()