React Native Navigation does not exist - reactjs

I had to take a break from working on my react native app for a couple of months and when i came back to work on it again i couldn't boot anything up and i am getting a load of React Native Navigation errors...
I dont really know where to start with this, i have made some changes to the java files but nothing seems to get me out of this hole...
the error is below... if anyone knows how to deal with this i would be really greatful
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainActivity.java:3: error: package com.reactnativenavigation does not exist
import com.reactnativenavigation.NavigationActivity;
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainActivity.java:5: error: cannot find symbol
public class MainActivity extends NavigationActivity {
^
symbol: class NavigationActivity
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:21: error: package com.reactnativenavigation does not exist
import com.reactnativenavigation.NavigationApplication;
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:22: error: package com.reactnativenavigation.react does not exist
import com.reactnativenavigation.react.NavigationReactNativeHost;
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:27: error: cannot find symbol
public class MainApplication extends NavigationApplication {
^
symbol: class NavigationApplication
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:29: error: cannot find symbol
new NavigationReactNativeHost(this) {
^
symbol: class NavigationReactNativeHost
location: class MainApplication
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:47: error: method does not override or implement a method from a supertype
#Override
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:51: error: method does not override or implement a method from a supertype
#Override
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:53: error: cannot find symbol
super.onCreate();
^
symbol: variable super
location: class MainApplication
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:54: error: cannot find symbol
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
^
symbol: method initializeFlipper(MainApplication,ReactInstanceManager)
location: class MainApplication
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
This is from the build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 19
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
RNNKotlinVersion = "1.3.61" // Or any version above 1.3.x
RNNKotlinStdlib = "kotlin-stdlib-jdk8"
}
repositories {
google()
mavenLocal()
mavenCentral()
jcenter()
maven { url "$rootDir/../node_modules/react-native/android" }
maven { url 'https://maven.google.com' }
// ADD THIS
maven { url "https://www.jitpack.io" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
classpath 'com.android.tools.build:gradle:3.6.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
this if from the app build.gradle
dependencies {
implementation project(':#react-native-community_async-storage')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-vector-icons')
implementation "androidx.appcompat:appcompat:1.0.0"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:design:27.1.0'
}
This is the mainapp
public class MainApplication extends NavigationApplication {
private final ReactNativeHost mReactNativeHost =
new NavigationReactNativeHost(this) {
#Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
main activigty just looks like this
package com.battlebuddy;
import com.reactnativenavigation.NavigationActivity;
public class MainActivity extends NavigationActivity {
}
If there is anything you can think of that would help a lot

Related

Flutter Floor Database from snapshot.data in Future Builder?

I can't able to store snapshot.data to database via floor in Flutter. I wrote entity, dao and database file, builded database and database.g.dart succesed to complete, but when I tried to insertUser function it turns below error;
What am I missing? Is there anything to do for record future snapshot.data which there isn't in [the guide]?1
Error:
════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════
The following NoSuchMethodError was thrown while handling a gesture:
The method 'insertUser' was called on null.
Receiver: null
Tried calling: insertUser(Instance of 'UserF')
My entity:
import 'package:floor/floor.dart';
#entity
class UserF {
#PrimaryKey(autoGenerate: true)
final int id;
final String user;
final int overview;
UserF({this.id,
this.user,
this.overview,
#override
int get hashCode => id.hashCode ^ user.hashCode ^ overview.hashCode ;
#override
String toString() {
return 'UserF{id: $id, user: $user, overview: $overview}';
}
}
DAO:
import 'package:floor/floor.dart';
import 'entity.dart';
#dao
abstract class UserDao {
#Query('SELECT * FROM UserF')
Future<List<UserF>> findAllUsers();
#Query('SELECT * FROM UserF WHERE id = :id')
Stream<UserF> findUserById(int id);
#insert
Future<void> insertUser(UserF userF);
#delete
Future<int> deleteUser(UserF userF);
}
Database:
import 'dart:async';
import 'package:floor/floor.dart';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart' as sqflite;
import 'user_dao.dart';
import 'entity.dart';
part 'database.g.dart'; // the generated code will be there
#Database(version: 1, entities: [UserF])
abstract class AppDatabase extends FloorDatabase {
UserDao get userDao;
}
Related Parts on my main.dart
Future<void> main() async{
WidgetsFlutterBinding.ensureInitialized();
final AppDatabase = await $FloorAppDatabase
.databaseBuilder('database.db')
.build();
runApp(MyApp());
}
....
floatingActionButton: FloatingActionButton(
onPressed: (){
final userf = UserF(user: snapshot.data.user, overview: snapshot.data.overview);
favoriteDao.insertUser(userf);
},
child: Icon(Icons.add),
....
If the code :
part 'database.g.dart';
is creating error that means you have to generate that file.
Add these dependencies if you haven't already:
Dependencies:
floor: ^0.14.0
sqflite: ^1.3.0
Dev Dependencies:
floor_generator: ^0.14.0
build_runner: ^1.8.1
In terminal run the following command:
flutter packages pub run build_runner build
And wait for some time. Flutter will generate the command.
Flutter will automatically generate the file.
REMEMBER: THE NAME OF THE DATABASE FILE AND NAME OF GENERATED FILE MUST BE SAME EXEPT FOR ADDING .g
For Example
if the database file name is mydatabase.dart
the generated file name must be mydatabase.g.dart

react-native-navigation 1.1.45 and RN 0.43 compatibility

I am not able to setting up react-native-navigation for android version. My IOS app is working fine with same version of RNN and RN.
Help me configure for android.
Here is few important file from my app,
MainActivity.java
package com.MY_APP_NAME;
import com.facebook.react.ReactActivity;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactnativenavigation.bridge.NavigationReactPackage;
public class MainActivity extends ReactActivity {
#Override
protected String getMainComponentName() {
return "ttapp";
}
}
MainApplication.java
package com.MY_APP_NAME;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.oblador.vectoricons.VectorIconsPackage;
import java.util.Arrays;
import java.util.List;
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 VectorIconsPackage()
);
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
/App/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId 'com.MY_APP_NAME'
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a": 1, "x86": 2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
productFlavors {
}
}
dependencies {
compile project(':react-native-splash-screen')
compile project(':react-native-navigation')
compile project(':react-native-vector-icons')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.0.3'
compile 'com.facebook.react:react-native:+'
// From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
Everything is working fine. App is also successfully builded. But react-native-navigation is not working.
Are you getting a white screen on the android device? It also happen to me (only while you have debugger enabled), but if you switch task you're good to go. Try to check this issue on the repo, maybe you could find your answers.
BTW as stated by Pritish, in the READ.ME the minimum version of RN supported is 0.48, for v2 you need version 0.51

how to configure a FileEntityStoreService

I'm trying to use a File EntityStore and I'm having an exception at activation because of slices being zero.
I assume it's an issue with configuration but I expected the default value to be 1.
I narrowed down to this assembly:
import org.apache.polygene.api.common.Visibility;
import org.apache.polygene.api.structure.Application;
import org.apache.polygene.bootstrap.Energy4Java;
import org.apache.polygene.entitystore.file.assembly.FileEntityStoreAssembler;
import org.apache.polygene.index.rdf.assembly.RdfNativeSesameStoreAssembler;
import org.apache.polygene.library.fileconfig.FileConfigurationAssembler;
public class FileStoreException {
public static void main(String[] args) throws Exception {
Energy4Java polygene = new Energy4Java();
Application application = polygene.newApplication(factory -> factory.newApplicationAssembly(
module -> {
new FileConfigurationAssembler()
.visibleIn(Visibility.application)
.assemble(module);
new FileEntityStoreAssembler()
.withConfig(module, Visibility.application)
.assemble(module);
new RdfNativeSesameStoreAssembler()
.withConfig(module, Visibility.application)
.assemble(module);
module.defaultServices();
})
);
application.activate();
}
}
The end of the stacktrace:
Caused by: java.lang.ArithmeticException: / by zero
at method "get" of FileEntityStoreService:FileEntityStoreService in module [Module 1] of layer [Layer 1].(:0)
at org.apache.polygene.entitystore.file.FileEntityStoreMixin.getDataFile(FileEntityStoreMixin.java:277)
at org.apache.polygene.entitystore.file.FileEntityStoreMixin.getDataFile(FileEntityStoreMixin.java:328)
at org.apache.polygene.entitystore.file.FileEntityStoreMixin.get(FileEntityStoreMixin.java:138)
at org.apache.polygene.spi.entitystore.helpers.JSONMapEntityStoreMixin.entityStateOf(JSONMapEntityStoreMixin.java:193)
... 14 more
I'm using version 3.0.0 and I'm on linux.
Adding FileConfigurationAssembler gave me the false impression that my config was done.
I struggled to find a working example of an assembly using a FileEntityStoreAssembler so here's one:
Application application = polygene.newApplication(factory -> factory.newApplicationAssembly(
module -> {
ModuleAssembly config = module.layer().module("Config");
config.defaultServices();
new MemoryEntityStoreAssembler().assemble(config);
config.entities(FileEntityStoreConfiguration.class);
new FileEntityStoreAssembler()
.withConfig(config, Visibility.application)
.assemble(module);
new RdfNativeSesameStoreAssembler()
.withConfig(config, Visibility.application)
.assemble(module);
module.defaultServices();
})
);
And to configure it:
config.forMixin(FileEntityStoreConfiguration.class)
.declareDefaults()
.directory().set("/home/user/appdata/");

Error while updating 'end' in shadow node of type: BVLinearGradient

I get "Error while updating 'end' in shadow node of type: BVLinearGradient" error when i run my react native app and the error seems to emanate from my MainApplication.java file here is my code:
package com.*;
import com.BV.LinearGradient.LinearGradientPackage;
import com.facebook.react.ReactPackage;
import com.horcrux.svg.SvgPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactnativenavigation.NavigationApplication;
import com.wheelpicker.WheelPickerPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends NavigationApplication {
#Override
public boolean isDebug() {
// Make sure you are using BuildConfig from your own application
return BuildConfig.DEBUG;
}
#Override
public List<ReactPackage> createAdditionalReactPackages() {
// Add the packages you require here.
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
new WheelPickerPackage(),
new VectorIconsPackage(),
new SvgPackage(),
new LinearGradientPackage()
);
}
}
Please help me resolve this
This is a bug with the react-native-linear-gradient. The issue is in open status. For the time being, there are 2 solutions-
Replace start with startPoint and end with endPoint props for <LinearGradient/>
Downgrade react-native version to 0.50.3
The details for this issue is below:
https://github.com/react-native-community/react-native-linear-gradient/issues/246

cucumber.runtime.CucumberException: There are undefined steps

Getting error as "There are undefined steps" while running the cucumber test with testNG in intelliJ editor, please guide with the steps that are missing
the error output as
Feature: New Tour Login Testing
Scenario: Valid data testing # src/main/java/features/loginnewtour.feature:2
Given user is already on Login Page
When title of login page is new tour
Then user enters "mercury"
cucumber.runtime.CucumberException: cucumber.runtime.CucumberException: There are undefined steps
at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:69)
at cucumber.api.testng.AbstractTestNGCucumberTests.feature(AbstractTestNGCucumberTests.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
at org.testng.TestNG.run(TestNG.java:1064)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
Caused by: cucumber.runtime.CucumberException: There are undefined steps
at cucumber.api.testng.FeatureResultListener.collectError(FeatureResultListener.java:60)
at cucumber.api.testng.FeatureResultListener.result(FeatureResultListener.java:45)
at cucumber.runtime.Runtime.runStep(Runtime.java:282)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:63)
... 24 more
Undefined scenarios:
src/main/java/features/loginnewtour.feature:2 # Scenario: Valid data testing
1 Scenarios (1 undefined)
3 Steps (3 undefined)
0m0.000s
Below are the files that I am using under
src/main/java/
features
loginnewtour.feature
myRunner
TestRunner.java
stepDef
loginstepdefnewtour.java
I have a feature file as "loginnewtour.feature"
Feature: New Tour Login Testing
Scenario: Valid data testing
Given user is already on Login Page
When title of login page is new tour
Then user enters "mercury"
implemented all steps mentioned in the feature file as "loginstepdefnewtour.java"
package stepDef;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.openqa.selenium.chrome.ChromeDriver;
public class loginstepdefnewtour {
WebDriver driver;
#Given("^user is already on Login Page$")
public void user_is_already_on_Login_Page() throws Throwable {
System.setProperty("webdriver.chrome.driver","c:\\Grid\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("http://newtours.demoaut.com/");
}
#When("^title of login page is new tour$")
public void title_of_login_page_is_new_tour() throws Throwable {
String title = driver.getTitle();
System.out.println(title);
}
#Then("^user enters \"([^\"]*)\"$")
public void user_enters_and(String arg1, String arg2) throws Throwable {
driver.findElement(By.name("userName")).sendKeys("sunil");
}
}
and "testrunner.java" is as
package myRunner;
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;
//#RunWith(Cucumber.class)
#CucumberOptions(
features = "src/main/java/features/loginnewtour.feature",
glue={"src/main/java/stepDef/loginstepdefnewtour.java"},
plugin= {"pretty","html:test-outout", "json:json_output/cucumber.json", "junit:junit_xml/cucumber.xml"},
monochrome = true,
strict = true,
dryRun = false
)
public class TestRunner extends AbstractTestNGCucumberTests{
}
You specified a wrong value for the glue path. You need to specified the Java packages to search for.
instead of
glue={"src/main/java/stepDef/loginstepdefnewtour.java"},
it should be
glue={"stepDef"},
Also a method signature is wrong
-- public void user_enters_and(String arg1, String arg2) throws Throwable {
public void user_enters_and(String arg1) throws Throwable {
edit The files in the project with the naming you provided (please consider to follow the Java naming convention for the files)
src/main/java/stepDef/loginstepdefnewtour.java
src/main/java/features/loginnewtour.feature
src/test/java/myRunner/TestRunner.java
loginstepdefnewtour.java
package stepDef;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class loginstepdefnewtour {
#Given("^user is already on Login Page$")
public void user_is_already_on_Login_Page() throws Throwable { }
#When("^title of login page is new tour$")
public void title_of_login_page_is_new_tour() throws Throwable { }
#Then("^user enters \"([^\"]*)\"$")
public void user_enters_and(String arg1) throws Throwable { }
}
loginnewtour.feature
Has the content you provided.
TestRunner.java
package myRunner;
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;
//#RunWith(Cucumber.class)
#CucumberOptions(
features = "src/main/java/features/loginnewtour.feature",
glue={"stepDef"},
plugin= {
"pretty","html:test-outout",
"json:json_output/cucumber.json",
"junit:junit_xml/cucumber.xml"
},
monochrome = true,
strict = true,
dryRun = false
)
public class TestRunner extends AbstractTestNGCucumberTests{
}
Execute the tests
mvn compile test
output
Running myRunner.TestRunner
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator#6bf2d08e
Feature: New Tour Login Testing
Scenario: Valid data testing # src/main/java/features/loginnewtour.feature:2
Given user is already on Login Page # loginstepdefnewtour.user_is_already_on_Login_Page()
When title of login page is new tour # loginstepdefnewtour.title_of_login_page_is_new_tour()
Then user enters "mercury" # loginstepdefnewtour.user_enters_and(String)
1 Scenarios (1 passed)
3 Steps (3 passed)

Resources