我只用了Androidlottie库,字体什么的都没动,可是为什么会出现字体错误呢?
I only used the Android lottie library, and I didn't touch anything about the font, but why does the font error appear?
正如标题所说,
我在 Android Studio
上的 Splash Activity 中放置了 lotie 动画
但是有一个错误叫做java.lang.RuntimeException: Font asset not found fonts/Microsoft YaHei UI.ttf.
为什么会这样?我没有触及任何 font-related 设置。
如果你知道为什么,请告诉我!
谢谢..
这是我的代码..
activity_splash.xml
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie_anime"
android:layout_width="250dp"
android:layout_height="250dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_rawRes="@raw/splash_anime" />
飞溅Activity
lottie_anime.playAnimation()
这是错误代码
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.appclient, PID: 5854
java.lang.RuntimeException: Font asset not found fonts/Microsoft YaHei UI.ttf
at android.graphics.Typeface.createFromAsset(Typeface.java:965)
at com.airbnb.lottie.manager.FontAssetManager.getFontFamily(FontAssetManager.java:87)
at com.airbnb.lottie.manager.FontAssetManager.getTypeface(FontAssetManager.java:61)
at com.airbnb.lottie.LottieDrawable.getTypeface(LottieDrawable.java:1067)
at com.airbnb.lottie.model.layer.TextLayer.drawTextWithFont(TextLayer.java:238)
at com.airbnb.lottie.model.layer.TextLayer.drawLayer(TextLayer.java:161)
at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:222)
at com.airbnb.lottie.model.layer.CompositionLayer.drawLayer(CompositionLayer.java:113)
at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:222)
at com.airbnb.lottie.LottieDrawable.drawWithOriginalAspectRatio(LottieDrawable.java:1224)
at com.airbnb.lottie.LottieDrawable.drawInternal(LottieDrawable.java:380)
at com.airbnb.lottie.LottieDrawable.draw(LottieDrawable.java:370)
at android.widget.ImageView.onDraw(ImageView.java:1434)
at android.view.View.draw(View.java:21421)
at android.view.View.updateDisplayListIfDirty(View.java:20298)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1975)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw(View.java:21424)
at com.android.internal.policy.DecorView.draw(DecorView.java:806)
at android.view.View.updateDisplayListIfDirty(View.java:20298)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:575)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:581)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:654)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3610)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3418)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2755)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/Process: Sending signal. PID: 5854 SIG: 9
这不是代码问题,
但是有 .json 动画资源。
这么简单的问题都没找到,好难过
//你可以通过下面的方法做乐蒂动画
//第一步:实现lottie的库
implementation 'com.airbnb.android:lottie:3.6.0'
//step 2: download the lotie json file form the website link is
https://lottiefiles.com/
//step 3: put the download lotiejson file in your asset folder of android studio
//step 4: put the below code in your xml
<com.airbnb.lottie.LottieAnimationView
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
app:lottie_autoPlay="true"
app:lottie_fileName="progress1.json"
app:lottie_loop="true"/>
正如标题所说,
我在 Android Studio
上的 Splash Activity 中放置了 lotie 动画
但是有一个错误叫做java.lang.RuntimeException: Font asset not found fonts/Microsoft YaHei UI.ttf.
为什么会这样?我没有触及任何 font-related 设置。
如果你知道为什么,请告诉我!
谢谢..
这是我的代码..
activity_splash.xml
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie_anime"
android:layout_width="250dp"
android:layout_height="250dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_rawRes="@raw/splash_anime" />
飞溅Activity
lottie_anime.playAnimation()
这是错误代码
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.appclient, PID: 5854
java.lang.RuntimeException: Font asset not found fonts/Microsoft YaHei UI.ttf
at android.graphics.Typeface.createFromAsset(Typeface.java:965)
at com.airbnb.lottie.manager.FontAssetManager.getFontFamily(FontAssetManager.java:87)
at com.airbnb.lottie.manager.FontAssetManager.getTypeface(FontAssetManager.java:61)
at com.airbnb.lottie.LottieDrawable.getTypeface(LottieDrawable.java:1067)
at com.airbnb.lottie.model.layer.TextLayer.drawTextWithFont(TextLayer.java:238)
at com.airbnb.lottie.model.layer.TextLayer.drawLayer(TextLayer.java:161)
at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:222)
at com.airbnb.lottie.model.layer.CompositionLayer.drawLayer(CompositionLayer.java:113)
at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:222)
at com.airbnb.lottie.LottieDrawable.drawWithOriginalAspectRatio(LottieDrawable.java:1224)
at com.airbnb.lottie.LottieDrawable.drawInternal(LottieDrawable.java:380)
at com.airbnb.lottie.LottieDrawable.draw(LottieDrawable.java:370)
at android.widget.ImageView.onDraw(ImageView.java:1434)
at android.view.View.draw(View.java:21421)
at android.view.View.updateDisplayListIfDirty(View.java:20298)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1975)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.updateDisplayListIfDirty(View.java:20289)
at android.view.View.draw(View.java:21153)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw(View.java:21424)
at com.android.internal.policy.DecorView.draw(DecorView.java:806)
at android.view.View.updateDisplayListIfDirty(View.java:20298)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:575)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:581)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:654)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3610)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3418)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2755)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/Process: Sending signal. PID: 5854 SIG: 9
这不是代码问题,
但是有 .json 动画资源。
这么简单的问题都没找到,好难过
//你可以通过下面的方法做乐蒂动画
//第一步:实现lottie的库
implementation 'com.airbnb.android:lottie:3.6.0'
//step 2: download the lotie json file form the website link is
https://lottiefiles.com/
//step 3: put the download lotiejson file in your asset folder of android studio
//step 4: put the below code in your xml
<com.airbnb.lottie.LottieAnimationView
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
app:lottie_autoPlay="true"
app:lottie_fileName="progress1.json"
app:lottie_loop="true"/>