I have installed react-native-navigation package for navigation in react native. After that I didn't like it and try use another package for navigation. But when I tried to uninstall this package and tried to run the app, it gives the following errors as given below. I didn't do anything, I had just uinstalled this react-native-navigation package from npm.
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: S:\Collab\ReactNative\Edesign\node_modules\#react-native-firebase\messaging\android\src\main\java\io\invertase\firebase\messaging\ReactNativeFirebaseMessagingModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainActivity.java:4: error: package com.reactnativenavigation does not exist
import com.reactnativenavigation.NavigationActivity;
^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainActivity.java:7: error: cannot find symbol
public class MainActivity extends NavigationActivity {
^
symbol: class NavigationActivity
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:9: error: package com.reactnativenavigation does not exist
import com.reactnativenavigation.NavigationApplication;
^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:10: error: package com.reactnativenavigation.react does not exist
import com.reactnativenavigation.react.NavigationPackage;
^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:35: error: package com.reactnativenavigation.react does not exist
import com.reactnativenavigation.react.NavigationReactNativeHost;
^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:41: error: cannot find symbol
public class MainApplication extends NavigationApplication {
^
symbol: class NavigationApplication
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainActivity.java:11: error: method does not override or implement a method from a supertype
#Override
^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainActivity.java:13: error: cannot find symbol
super.onCreate(null);
^
symbol: variable super
location: class MainActivity
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:44: error: cannot find symbol
new NavigationReactNativeHost(this) {
^
symbol: class NavigationReactNativeHost
location: class MainApplication
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:45: error: method does not override or implement a method from a supertype
#Override
^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:50: error: method does not override or implement a method from a supertype
#Override
^
S:\Collab\ReactNative\Edesign\android\app\src\main\java\com\edesign\MainApplication.java:53: error: no suitable constructor found for PackageList(<anonymous NavigationReactNativeHost>)
List<ReactPackage> packages = new PackageList(this).getPackages();
Is there any solution for this??
After you uninstalled react-native-navigation from npm, you should also revert back installation on Android
Update MainActivity.java
remove this line:
import com.reactnativenavigation.NavigationActivity;
Instead add this:
import com.facebook.react.ReactActivity;
Also, extends from ReactActivity, not NavigationActivity
Update MainApplication.java
Remove these:
import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.react.NavigationReactNativeHost;
Update this line:
public class MainApplication extends NavigationApplication
to this one:
public class MainApplication extends Application implements ReactApplication {
Update this line:
new NavigationReactNativeHost(this) {
to this one:
new ReactNativeHost(this) {
onCreate method:
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false); // add this one
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
Related
Everything was working until two days ago I got this error:
> Task :app:compileDebugJavaWithJavac FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
224 actionable tasks: 195 executed, 29 up-to-date
Note: /Users/yashatreya/Desktop/realyze/node_modules/#react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorage
Module.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/yashatreya/Desktop/realyze/node_modules/#react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerD
ialogFragment.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /Users/yashatreya/Desktop/realyze/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/yashatreya/Desktop/realyze/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/yashatreya/Desktop/realyze/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /Users/yashatreya/Desktop/realyze/node_modules/react-native-sound/android/src/main/java/com/zmxv/RNSound/RNSoundModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/yashatreya/Desktop/realyze/node_modules/react-native-svg/android/src/main/java/com/horcrux/svg/TSpanView.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/Users/yashatreya/Desktop/realyze/android/app/build/generated/rncli/src/main/java/debug/facebook/react/PackageList.java:90: error: getApplication() has protected access in ReactNativeHost
return this.reactNativeHost.getApplication();
^
1 error
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 my MainApplication.java
package com.realyze;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import io.expo.appearance.RNCAppearancePackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
//MultiDex
import androidx.multidex.MultiDexApplication;
//RN-PushNotification
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
public class MainApplication extends MultiDexApplication implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
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());
new ReactNativePushNotificationPackage();
return packages;
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
}
/**
* Loads Flipper in React Native templates.
*
* #param context
*/
private static void initializeFlipper(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
Versions:
React Native: 0.61.4
Android Studio: 3.6.1
Gradle Plugin: 3.4.2
I have tried clearing the build cache but it still gives me the same error.
I am a beginner react-native developer and I can't understand what is going wrong.
Your help would be very much appreciated
The comments inside MainApplication.java are there to help and guide you on how to add packages that do not get to auto-link; so, if react-native-push-notification does not support auto-linking, you'll have to add it to the packages list like this:
//RN-PushNotification
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
public class MainApplication extends MultiDexApplication implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
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:
// Add a new ReactNativePushNotificationPackage to the packages
// ONLY IF ReactNativePushNotificationPackage does not support auto-linking
packages.add(new ReactNativePushNotificationPackage());
return packages;
}
...
If it does support auto-linking, then you'll have to remove/reverse the manual installation steps, clean the project and let React Native handle the native linking with the new RN >= 60 auto-linking system.
Below if I import Entity I get the posts's subject error (TypeError: Object prototype may only be an Object or null: undefined), but if I replace the import with the actual Entity declaration the code runs fine.
Stackblitz demo here.
This is Customer.ts in the form that produces the error when I run the code with ts-node:
index.ts
export { Customer } from "./Customer";
export { Entity } from "./Entity";
Customer.ts
import { Entity } from "./index";
export class Customer extends Entity {
sku: string;
constructor(po: any) {
super();
this.sku = po.sku;
}
}
Entity.ts
export abstract class Entity {
id?: string;
}
Run.ts (The test code)
import {Customer} from "./";
let c = new Customer({
name: "Bob"
});
console.log(c);
If I replace the Entity import with the declaration like this:
export abstract class Entity {
id?: string;
}
export class Customer extends Entity {
sku: string;
constructor(po: any) {
super();
this.sku = po.sku;
}
}
Then Run.ts logs this:
Customer { sku: undefined }
In other words it runs fine and produces no errors. Thoughts?
As I suspected, your original program has circular imports. Run.ts imports index.ts, which imports Customer.ts, which imports index.ts again. Since index.ts is already in the process of loading and itself depends on Customer.ts, the import { Entity } from "./index"; just binds the Entity of index.ts (which is not set yet) to the Entity of Customer.ts, and execution proceeds even though index.ts isn't finished loading. Then Entity is undefined at the time you try to extend it. You might argue that a circular import should be an error or that JavaScript engines should use some other algorithm that correctly handles your scenario; I'm not qualified to comment on why the current design was chosen. (Others feel free to add information about this.)
As you saw, changing Customer.ts to import from ./Entity directly instead of ./index breaks the cycle, and everything works as expected. Another solution would be to reverse the order of imports in index.ts.
This is not directly an answer to the example above, but I got the same error message when I had Vue and Parcel, and this kind of code:
class Proxy {}
class MyProxy extends Proxy {}
After some lengthy debugging, it turned out that there seems to be some class name conflict with the name "Proxy", maybe from Parcel. After I renamed the super class as "AbstractProxy" or anything else than "Proxy", it started to work.
You can try this command and check the application:
ng update #angular/cli #angular/core --force
npm install
ng serve -o
I am trying to import a new service provider that I just created after pulling from the latest branch in my ionic app.
When I try to import this line of code:
import { AuthServiceProvider } from '../providers/auth-service'
in app.module.ts I always got an error saying that:
Uncaught Error: Cannot find module "."
at webpackMissingModule (index.js:3)
at e.code (index.js:3)
at Object.<anonymous> (index.js:9)
at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)
at Object.690 (slide.transition.ts:67)
at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)
at Object.495 (main.js:1885)
at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)
at Object.487 (notification-api.ts:6)
at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)
But take note that I am also importing another service from my provider that is working perfectly.
Here is the code of my auth-service.ts below.
import { HttpClient } from '#angular/common/http';
import { Injectable } from '#angular/core';
import { Events } from 'ionic-angular/umd';
/*
Generated class for the AuthServiceProvider provider.
See https://angular.io/guide/dependency-injection for more info on providers
and Angular DI.
*/
#Injectable()
export class AuthServiceProvider {
public isLoggedIn = false;
constructor(
public http: HttpClient,
private events: Events
) {
console.log('Hello AuthServiceProvider Provider');
events.subscribe('user:logged-in', (user) => {
this.isLoggedIn = true;
console.log('Welcome', user);
});
}
}
I won't show my code in my app.module.ts because it is bombarded by import plugins and other providers.
Here is my ionic info
cli packages: (/usr/lib/node_modules)
#ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
#ionic/app-scripts : 3.1.8
Cordova Platforms : android 6.3.0 browser 5.0.3
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
Node : v6.12.2
npm : 4.6.1
OS : Linux 4.13
Environment Variables:
ANDROID_HOME : /home/clifford/Android/Sdk
So why I am having an error in that specific service provider compare to other providers which are just the same?
Any thoughts?
Appreciate if someone could help.
Thanks in advance.
I finally figure it out to solve the problem. The error occurs when I import the events from ionic-angular.
So instead of: import { Events } from 'ionic-angular/umd';
Just remove the umd at the end. I don't know why it happened because I am using auto import from my vs code.
I changed import { Events } from 'ionic-angular/umd'; to import { Events } from 'ionic-angular';. I was using "typescript": "~2.6.2". I tried to change the version of typescript and I have heard that typescript 3.1 can be fix in some cases. In my case once i went higher than typescript 2.8.0 I started getting other issues related to ionic. At the end the above fix works, and I think this is more a ionic framework issue.
My question is about typescript and streams in nodejs. I wan't to extend the stream base class, and access the highWaterMark option.
In typescript, the following code works (i.e. the highWaterMark options is printed)
import * as stream from 'stream';
class ExampleStream extends stream.Readable {
constructor() {
super(options)
console.log(this._readableState.highWaterMark)
}
_read() {}
_write() {}
}
But typescript gives me the following error message regarding the line:
console.log(this._readableState.highWaterMark)
[ts] Property '_readableState' does not exist on type 'ExampleStream'.
How do I fix that?
Given that _readableState is not exposed as part of the public API I don't think it will be/should be added to the node typings. To workaround this issue you can cast this to any and use the proeprties not available in node type definitions:
console.log((this as any)._readableState.highWaterMark)
I am trying to use the pubnub javascript 4.0 sdk within my Angular 2 application that is using Typescript. I have successfully installed the library through npm and linked the module using SystemJS, and I can import it into my service that I'm using for chat. The problem comes when I try to access it within the service itself, I get a Error: CompileMetadataResolver. There are no type definitions for this library, so I found an open source .d.ts file someone posted online. Am I missing a type file (hence the metadata resolve)?
import { Subject } from 'rxjs/Subject';
import { Observable } from 'rxjs/Observable';
import {PUBNUB} from 'pubnub';
export class ChatService {
private pnService: PUBNUB.PUBNUB;
constructor(private pubNub: PUBNUB){
//trying to access or create object here results in error
this.pnService = new
}
initialize(subkey:string, pubKey:string) {
//this.pubNub.init({subscribe_key : subKey, publish_key : pubKey, ssl: true, origin: 'pubsub.pubnub.com'});
}
}