React native mapbox issue - react-native

i'm trying to use mapbox in reactnative and as documented i follow everything
but my app broking.
please find the below exception for your reference
null is not an object (evaluating 'MapboxGL.StyleURL').
Please help me

I just have this issue and maybe this will help you.
I have followed the official documentation to integrate #react-native-mapbox-gl/maps, but it keeps telling me
null is not an object(evaluating 'MapboxGL.StyleURL')
for version 7.0.8~7.2.0 and
Native part of Mapbox React Native libraries were not registered properly, double check our native installation guides.
after version 8.0.0.
I have added the RCTMGLPackage in the MainApplication:
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() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new MainReactPackage());
packages.add(new RCTMGLPackage());
return packages;
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
But still not work every time.
After checking the existing code, it has other places to add Native Module package in Activity.
in MainActivity :
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(this.getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModulePath("index")
.addPackage(new MainReactPackage())
.addPackage(new RCTMGLPackage())
.setCurrentActivity(this)
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
Not sure if you have the same case, may this will help you.

Related

React native auto linking is not working (RN0.61.5)

Recently I have upgraded from react-native 0.59.1 to 0.61.5 using the react-native upgrade command. Previously I was using manual linking for some packages and I had removed it using react-native unlink but now it is not working properly when I run on android it builds, but the app only shows the following error
I'm really new to react-native so I don't know what all to share. So if you need more info just ask.
MainApplication.java
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 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
);
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
There are some problems with auto linking in certain versions of ReactNative. All your packages are linked inside your MainApplication.java file. In your file, it is clearly seen that RNDeviceInfo is missing from the list of the packages and I suspect here that it might cause problems for rest of the third-party modules also. I am just mentioning here how to deal with the RNDeviceInfo module.
Update your source code as:
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 java.util.Arrays;
import java.util.List;
import com.learnium.RNDeviceInfo.RNDeviceInfo; //Add this import
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 RNDeviceInfo() //add this dependency in the list
);
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
Once you resolve this, same issue might raise for other modules. To resolve, just visit their github repositories and go through the manual linking process for android platform.
Hope this helps.
to make sure you have the update for version 0.61.5, check out this React-Native update help link https://react-native-community.github.io/upgrade-helper/.
After that run npm install, try to go to Android folder and run ./gradlew clean for powershell orgradlew clean for cmd.
I think this package (react-native-device-info) is not compatible for v0.6 , for example I couldn't migrate react-native-bluetooth-status without manual linking.
but I checked react-native-device-info and it has been updated 16 days ago , so I guess if you upgrade your package it links automatically.
I recently stumbled across the same issue -> when you look at a newly initialized project you can see that the getPackages() is implemented relying on PackageList(this).getPackages(); instead of having new MainReactPackage() in your list of dependencies.
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());
return packages;
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};

Compile Java for :react-native-firebase:compileDebugJavaWithJavac 712 ms

//mainapplication.java
package 'com.ruci';
import android.app.Application;
import 'com.facebook.react.ReactApplication';
import io.invertase.firebase.RNFirebasePackage';
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 RNFirebasePackage(),
new RNCWebViewPackage(),
new VectorIconsPackage(),
new RNSharePackage(),
new ReanimatedPackage(),
new RNMail(),
new RNCardViewPackage(),
new RNAdMobPackage(),
new LottiePackage()
);
}
...
#Override
protected String getJSMainModuleName() {
return "index";
}
};
...
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
...
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, false);
}
}
You havent described the problem you are facing, you have just posted the error snippet. We cant figure out what and when has happened. Next time be more clear, but as per the error i guess you have error when building apk . Can you try installing the below things and then clean the gradle and try rebuilding it ?
npm install --save-dev jetifier
npx jetify

ReactNavice Onesignal Integration Issiue

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 ReactNativeOneSignalPackage(),
new MapsPackage(),
new VectorIconsPackage());
}
#Override protected String getJSMainModuleName(){return"index";}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
//This part is giving error:
#Override
public List<ReactPackage> createAdditionalReactPackages() {
return getPackages();
}
}
Hi there i have a problem with integration onesignal push notification into myapp.
As you see i added necessary codes as documanted. But onesignal is not working and if i add createAdditionalReactPackages it gives error and not building. If i remove that part project building succesfully but onIds not working.
What is wrong i dont understand please help me
Thanks in advance.

Code-Push with React-Native bundle is always null

We are attempting to implement CodePush from Microsoft App Center. We have managed to get to the point where the application downloads the package, and unpacks it. However, it always ends with the response
Update is invalid - A JS bundle file named "null" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary.
react#16.2.0
react-native#0.53.3
react-native-code-push#5.3.2
We've made the changes to the MainApplication.java
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
#NonNull
#Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
and
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
// Add additional packages you require here
// No need to add RnnPackage and MainReactPackage
new ActionSheetPackage(),
new PickerPackage(),
new ReactNativeOneSignalPackage(),
new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG),
new CalendarEventsPackage()
);
}
In the app code, we call
Navigation.registerComponent(ScreenNames.Landing.id, () => CodePush(codePushOptions)(LandingScreen), store, Provider);
The final logs from code-push debug android
[11:31:37] Awaiting user action.
[11:31:42] Downloading package.
[11:31:43] An unknown error occurred.
[11:31:43] Update is invalid - A JS bundle file named "null" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary.
It appears the react-native linker is putting some things in the wrong class
public class MainApplication extends NavigationApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this)
{
#NonNull
#Override
public String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
The override should be on MainApplication, not the ReactNativeHost
public class MainApplication extends NavigationApplication {
#NonNull
#Override
public String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this)
{ /*... */ }
You have to Override it inside the ReactGateway createReactGateway(){} method.
That's works for me.
#Override
protected ReactGateway createReactGateway() {
ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
#Override
protected String getJSMainModuleName() {
return "index";
}
#NonNull
#Override
public String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
};
return new ReactGateway(this, isDebug(), host);
}

Has anyone successfully implemented react-native headless js?

https://facebook.github.io/react-native/releases/next/docs/headless-js-android.html#headless-js
I can't seem to find the right way to do it
I am running React-native 0.40
I implemented the HeadlessJsTaskService to execute some react native code.
For me the ReactExecutorService just silently failed, because i didn't provide any Extras when calling startService(new Intent(this, MyTaskService.class));. The following code fixes that:
#Override
#Nullable
protected HeadlessJsTaskConfig getTaskConfig(Intent intent) {
Bundle extras = intent.getExtras();
WritableMap data = extras != null ? Arguments.fromBundle(extras) : null;
return new HeadlessJsTaskConfig(
"FeatureExecutor",
data,
5000);
}
I also had an existing Application class, that didn't implement ReactApplication. I had to add some code to make the HeadlessJsTaskService work:
private final ReactNativeHost reactNativeHost = new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
// Insert your packages, e.g.
new MainReactPackage()
);
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return reactNativeHost;
}
You also have to add your custom service to the manifest. For example:
<service android:name=".MyTaskService"/>
Please provide some additional information about your issues in case the solutions above do not help.