第一步,下载工程
git clone https://github.com/maplibre/maplibre-react-native.git
第二步,运行工程
cd maplibre-react-native/example
yarn install # 多次执行,直到没有错误提示
yarn react-native run-android
第三步,排错
Didn't find class "com.facebook.drawee.backends.pipeline.info.ImagePerfDataListener"
运行后闪退,rn端没有任何提示,android studio调试显示原生错误:
FATAL EXCEPTION: mqt_native_modules
Process: com.rnmaplibreexample, PID: 25623
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/drawee/backends/pipeline/info/ImagePerfDataListener;
at com.rnmaplibreexample.ReactNativeFlipper.initializeFlipper(ReactNativeFlipper.java:27)
at com.rnmaplibreexample.MainApplication.onCreate(MainApplication.java:58)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1225)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:8718)
at android.app.ActivityThread.access$2900(ActivityThread.java:315)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2962)
at android.os.Handler.dispatchMessage(Handler.java:117)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:293)
at android.app.ActivityThread.loopProcess(ActivityThread.java:10069)
at android.app.ActivityThread.main(ActivityThread.java:10058)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1245)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.drawee.backends.pipeline.info.ImagePerfDataListener" on path: DexPathList[[zip file "/data/app/~~w9D3M9ba1BdjyAdwotXZow==/com.rnmaplibreexample-xr02Od1o1zBP7Omx8JD7Og==/base.apk"],nativeLibraryDirectories=[/data/app/~~w9D3M9ba1BdjyAdwotXZow==/com.rnmaplibreexample-xr02Od1o1zBP7Omx8JD7Og==/lib/arm64, /data/app/~~w9D3M9ba1BdjyAdwotXZow==/com.rnmaplibreexample-xr02Od1o1zBP7Omx8JD7Og==/base.apk!/lib/arm64-v8a, /system/lib64, /hw_product/lib64, /system/lib64/module/multimedia, /system/product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.rnmaplibreexample.ReactNativeFlipper.initializeFlipper(ReactNativeFlipper.java:27)
at com.rnmaplibreexample.MainApplication.onCreate(MainApplication.java:58)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1225)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:8718)
at android.app.ActivityThread.access$2900(ActivityThread.java:315)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2962)
at android.os.Handler.dispatchMessage(Handler.java:117)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:293)
at android.app.ActivityThread.loopProcess(ActivityThread.java:10069)
at android.app.ActivityThread.main(ActivityThread.java:10058)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1245)
解决办法:全局搜索ReactNativeFlipper.initializeFlipper
方法并删除,一般在android/app/src/main/java/com/rnmaplibreexample/MainApplication.java
文件的onCreate
方法中