Open nicoara opened 6 years ago
@nicoara Can I see your MainApplication.java
file in its entirety. And also the error message in full. Then I might be able to help more. 😄
https://github.com/nicoara/Parkour/tree/master/android/app/src/main/java/com/parkour2342345
package com.parkour2342345;
//import android.app.Application;
import com.facebook.react.ReactPackage;
import com.reactnativenavigation.NavigationApplication;
import com.oblador.vectoricons.VectorIconsPackage;
import com.imagepicker.ImagePickerPackage;
import fr.bamlab.rnimageresizer.ImageResizerPackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import java.util.Arrays;
import java.util.List;
import com.airbnb.android.react.maps.MapsPackage;
// Crashlytics
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;
// Facebook
import android.content.Intent;
import com.facebook.CallbackManager;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.appevents.AppEventsLogger;
import com.reactnativenavigation.controllers.ActivityCallbacks;
// Firebase dependencies
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;
import io.invertase.firebase.database.RNFirebaseDatabasePackage;
import io.invertase.firebase.storage.RNFirebaseStoragePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;
import com.apsl.versionnumber.RNVersionNumberPackage;
import com.babisoft.ReactNativeLocalization.ReactNativeLocalizationPackage;
import com.brentvatne.react.ReactVideoPackage;
import com.reactlibrary.RNThumbnailPackage;
public class MainApplication extends NavigationApplication {
//Facebook requirements
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
@Override
public boolean isDebug() {
// Make sure you are using BuildConfig from your own application
return BuildConfig.DEBUG;
}
protected List<ReactPackage> getPackages() {
// Add additional packages you require here
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
// eg. new VectorIconsPackage()
new RNFirebasePackage(),
new RNFirebaseAuthPackage(),
new RNFirebaseDatabasePackage(),
new RNFirebaseStoragePackage(),
new RNFirebaseNotificationsPackage(),
new RNFirebaseMessagingPackage(),
new RNFetchBlobPackage(),
new MapsPackage(),
new VectorIconsPackage(),
new ImagePickerPackage(),
new ImageResizerPackage(),
new RNVersionNumberPackage(),
new FBSDKPackage(mCallbackManager),
new ReactNativeLocalizationPackage(),
new ReactVideoPackage()
new RNThumbnailPackage()
);
}
@Override
public List<ReactPackage> createAdditionalReactPackages() {
return getPackages();
}
@Override
public String getJSMainModuleName() {
return "index";
}
// Crashlytics
@Override
public void onCreate() {
super.onCreate();
// required by Facebook
setActivityCallbacks(new ActivityCallbacks() {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
mCallbackManager.onActivityResult(requestCode, resultCode, data);
}
});
// FacebookSDK App Events requirement
AppEventsLogger.activateApp(this);
Fabric.with(this, new Crashlytics());
}
}
The IDE error is simply "Cannot resolve symbol 'reactlibrary'", and highlights reactlibrary in red.
Many thanks!
I have attempted to recreate the react-native-thumbnail library in my RN project as a NativeModule, instead of installing it from npm to avoid this thread's issue. I have added the corresponding native code from the library in Xcode and in Android Studio.
It works on an actual iOS device, gets the thumbnail (nice work), but on an actual Android device it crashes after a video is loaded to take a thumbnail from.
Here is the line in Android that crashes:
public void get(String filePath, Promise promise) {
filePath = filePath.replace("content://","");
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(filePath); //crashes here
filpath at that point is 'content://media/external/video/media/6676'.
Here is the error in Crashlytics:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:87)
at java.lang.StringBuilder.<init>(StringBuilder.java:95)
at com.facebook.react.devsupport.DevSupportManagerImpl$JSExceptionLogger.log(DevSupportManagerImpl.java:303)
at com.facebook.react.devsupport.DevSupportManagerImpl.handleException(DevSupportManagerImpl.java:287)
at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:501)
at com.facebook.react.bridge.CatalystInstanceImpl.access$900(CatalystInstanceImpl.java:40)
at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:517)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:33)
at android.os.Looper.loop(Looper.java:145)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:818)
Many thanks!
Update / Resolution: The solution was to give the thumbnail library instead of the content uri, the path: /storage/emulated/0/DCIM/Camera/20181026_233357.mp4 Now I get the thumbnail on Android as well. The type of url the library is expecting needs to be added to this libraries' documentation, since 'filepath' is not sufficiently descriptive.
The package name on readme is different with the android package name.
This might help you https://github.com/phuochau/react-native-thumbnail/pull/37
@nicoara
yes looks like the package is now me.hauvo.thumbnail
so the import should be:
import me.hauvo.thumbnail.RNThumbnailPackage;
Update: sometimes in November, I wrote my own nativemodule with the code from this library, to bypass the creator of the library that has gone MIA.
Hi,
Environment: OS: macOS High Sierra 10.13.6 Node: 8.10.0 Yarn: 1.5.1 npm: 5.6.0 Watchman: 4.9.0 Xcode: Xcode 9.4.1 Build version 9F2000 Android Studio: 3.1 AI-173.4670197
Packages: (wanted => installed) react: 16.2.0 => 16.2.0 react-native: 0.54.4 => 0.54.4
I cannot install the library on Android, It throws the error 'Cannot resolve symbol 'reactlibrary'' and it does not recognize the package when adding the line 'import com.reactlibrary.RNThumbnailPackage;' in MainApplication.java (NOT IN MainActivity as it is i believe wrongly stated on the project page). The package is installed with 'npm install react-native-thumbnail --save' and appears in package.json.
How to solve this ASAP? Thank you