Importing on Android (import com.learnium.RNDeviceInfo.RNDeviceInfo) doesn’t work

Followed the setup instructions, but am not able to get it to build. Tested on:

  • an existing project (RN v0.31.0)
    • with npm@3
  • a new, freshly initialized RN project (v0.32.1)
    • with both npm@3 and npm@2

Here’s the log after running react-native run-android:

/Users/martins/RNDeviceInfoTest/android/app/src/main/java/com/rndeviceinfotest/MainApplication.java:11: error: package com.learnium.RNDeviceInfo does not exist
import com.learnium.RNDeviceInfo.RNDeviceInfo;
                                ^
/Users/martins/RNDeviceInfoTest/android/app/src/main/java/com/rndeviceinfotest/MainApplication.java:28: error: cannot find symbol
          , new RNDeviceInfo()
                ^
  symbol: class RNDeviceInfo
2 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Might be a dupe of #91

1 possible answer(s) on “Importing on Android (import com.learnium.RNDeviceInfo.RNDeviceInfo) doesn’t work

  1. Ok, got it working. The docs are missing two steps:

    In android/app/build.gradle add:

    compile project(':react-native-device-info')

    In android/settings.gradle add:

    include ':react-native-device-info'
    project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')

Importing on Android (import com.learnium.RNDeviceInfo.RNDeviceInfo) doesn’t work

Followed the setup instructions, but am not able to get it to build. Tested on:

  • an existing project (RN v0.31.0)
    • with npm@3
  • a new, freshly initialized RN project (v0.32.1)
    • with both npm@3 and npm@2

Here’s the log after running react-native run-android:

/Users/martins/RNDeviceInfoTest/android/app/src/main/java/com/rndeviceinfotest/MainApplication.java:11: error: package com.learnium.RNDeviceInfo does not exist
import com.learnium.RNDeviceInfo.RNDeviceInfo;
                                ^
/Users/martins/RNDeviceInfoTest/android/app/src/main/java/com/rndeviceinfotest/MainApplication.java:28: error: cannot find symbol
          , new RNDeviceInfo()
                ^
  symbol: class RNDeviceInfo
2 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Might be a dupe of #91

1 possible answer(s) on “Importing on Android (import com.learnium.RNDeviceInfo.RNDeviceInfo) doesn’t work

  1. Ok, got it working. The docs are missing two steps:

    In android/app/build.gradle add:

    compile project(':react-native-device-info')

    In android/settings.gradle add:

    include ':react-native-device-info'
    project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')