Yossi
Yossi

Reputation: 6027

react-native android build: package does not exist

I have received from somebody a demo react-native application that is using a native module.

This native module includes the following import statement:

import com.xxx.yyy.zzz;

The demo build runs successfully on my Windows PC and works fine.

I am trying to use the same native module in own application, so I did the same setup in the android\app\src\main\java\com\<app-name>\* files that was done in the demo.

However, when I run the build of my app I get the following error for the above statement:

error: package com.xxx.yyy.zzz does not exist

Any idea what is the reason for this error?

(One difference between my app and the demo is that the demo is using only a single native module, while my app is using multiple modules. Not sure why this should make a difference. I am just trying to find a reason for my problem...)

Upvotes: 4

Views: 3837

Answers (2)

fazeel haider
fazeel haider

Reputation: 5

import android.os.Build where you are using Build.

Upvotes: 0

atkristin
atkristin

Reputation: 61

I stumbled in this issue today. The native module I was using was written in kotlin, so what I did was include:

In android/build.gradle

buildscript{
   ext{
      ...
      ext.kotlin_version = '1.3.60'
      ...
   }
   dependencies{
      classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
   }
}

In android/app/build.gradle

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

dependencies {
    ...
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    ...
}

Upvotes: 4

Related Questions