Retrofit& amp;内存异常找不到字体资产

时间:2017-10-24 17:57:47

标签: java android service fonts retrofit2

我尝试使用Retrofit库从json服务获取数据。当我在三星Galaxy S6上测试时它运行正常。但是当我试图在三星Galaxy S4上运行它时。它给了我内存异常和资产中找不到的字体。甚至我在fonts目录中也有字体资源。

以下是我的日志:

10-24 22:42:36.546 827-3374/com.mianasad.deen D/TAG: request
                                                     Sending request http://mianasad.com/***/getFatwasbyCategory.php?keyword=%D8%AD%D8%AC on null
10-24 22:42:38.108 827-3374/com.mianasad.deen D/TAG: response
                                                     Received response for http://mianasad.com/***/getFatwasbyCategory.php?keyword=%D8%AD%D8%AC in 1044.1ms
                                                     Date: Tue, 24 Oct 2017 17:42:06 GMT
                                                     Server: Apache
                                                     X-Powered-By: PHP/5.6.31
                                                     Vary: Accept-Encoding
                                                     Content-Type: text/html; charset=UTF-8

                                                     {"response":[{"Fatwa":"\u0635\u0627\u062d\u0628\u0650 \u062d\u062b\u06cc\u062a \u06a9\u0648 \u067e\u06c1\u0644\u06d2 \u062d\u062c \u06a9\u0631\u0646\u0627 \u0686\u0627\u06c1\u06cc\u06d2 \u06cc\u0627 \u0639\u0645\u0631\u06c1\u061f","Id":"158","Answer":"\u0639\u0645\u0631\u06c1 \u06a9\u0631\u0646\u06d2 \u0633\u06d2 \u062d\u062c \u0641\u0631\u0636 \u0646\u06c1\u06cc\u06ba \u06c1\u0648\u062a\u0627\u060c \u062d\u062c \u0635\u0627\u062d\u0628 \u0627\u0633\u062a\u0637\u0627\u0639\u062a \u0634\u062e\u0635 \u067e\u0631 \u0641\u0631\u0636 \u06c1\u0648\u062a\u0627 \u06c1\u06d2\u06d4 \u062c\u0648 \u0627\u0633\u062a\u0637\u0627\u0639\u062a \u0631\u06a9\u06be\u062a\u0627 \u06c1\u06d2\u060c \u062d\u062c \u06a9\u0631\u06d2 \u0627\u0648\u0631 \u0648\u06c1\u0627\u06ba \u062c\u0627 \u06a9\u0631 \u062c\u062a\u0646\u06d2 \u0639\u0645\u0631\u06d2 \u06a9\u0631 \u0633\u06a9\u062a\u06d2 \u06c1\u06cc\u06ba \u0628\u06d2 \u0634\u06a9 \u06a9\u0631\u06cc\u06ba\u060c \u06a9\u0648\u0626\u06cc \u067e\u0627\u0628\u0646\u062f\u06cc \u0646\u06c1\u06cc\u06ba \u06c1\u06d2\u06d4 \u0639\u0645\u0631\u06c1 \u06a9\u0631\u0646\u06d2 \u06a9\u0627 \u0648\u0642\u062a \u067e\u06c1\u0644\u06d2 \u0645\u06cc\u0633\u0631 \u06c1\u0648 \u062a\u0648 \u067e\u06c1\u0644\u06d2 \u0628\u06be\u06cc \u06a9\u0631 \u0633\u06a9\u062a\u06d2 \u06c1\u06cc\u06ba\u06d4","Mufti":"\u0639\u0628\u062f\u0627\u0644\u0642\u06cc\u0648\u0645 \u06c1\u0632\u0627\u0631\u0648\u06cc"},{"Fatwa":"\u06a9\u06cc\u0627 \u0633\u0639\u0648\u062f\u06cc \u062d\u06a9\u0648\u0645\u062a \u06a9\u06cc \u0637\u0631\u0641 \u0633\u06d2 \u0644\u0648\u06af\u0648\u06ba \u067e\u0631 \u0627\u062f\u0627\u0626\u06cc\u06af\u06cc \u062d\u062c \u0633\u06d2 \u0631\u0648\u06a9\u0646\u06d2 \u06a9\u06d2 \u0644\u06cc\u06d2 \u067e\u0627\u0628\u0646\u062f\u06cc\u0627\u06ba \u0644\u06af\u0627\u0646\u0627 \u062c\u0627\u0626\u0632 \u06c1\u06d2\u061f","Id":"187","Answer":"\u062c\u0648\u06ba \u062c\u0648\u06ba \u0622\u0628\u0627\u062f\u06cc \u0628\u0691\u06be\u062a\u06cc \u062c\u0627 \u0631\u06c1\u06cc \u06c1\u06d2 \u062a\u0648\u06ba \u062a\u0648\u06ba \u0645\u0633\u0627\u0626\u0644 \u0645\u06cc\u06ba \u0628\u06be\u06cc \u0627\u0636\u0627\u0641\u06c1 \u06c1\u0648\u062a\u0627 \u062c\u0627 \u0631\u06c1\u0627 \u06c1\u06d2\u060c \u0627\u0633 \u0644\u06cc\u06d2 \u0627\u06af\u0631 \u0633\u0639\u0648\u062f\u06cc \u062d\u06a9\u0648\u0645\u062a \u0628\u0627\u0631 \u0628\u0627\u0631 \u062d\u062c \u06a9\u0631\u0646\u06d2 \u067e\u0631 \u067e\u0627\u0628\u0646\u062f\u06cc \u0644\u06af\u0627\u0626\u06d2 \u062a\u0627\u06a9\u06c1 \u0633\u0628 \u06a9\u0648 \u0645\u0648\u0642\u0639 \u0645\u0644\u06d2 \u06cc\u0627 \u0645\u062e\u062a\u0644\u0641 \u0645\u0644\u06a9\u0648\u06ba \u06a9\u06d2 \u0644\u06cc\u06d2 \u0622\u0628\u0627\u062f\u06cc \u06a9\u06d2 \u0645\u0637\u0627\u0628\u0642 \u0645\u062e\u062a\u0644\u0641 \u06a9\u0648\u0679\u06d2 \u0631\u06a9\u06be \u062f\u06d2 \u062a\u0648 \u0627\u0633 \u0637\u0631\u062d \u06a9\u06cc \u067e\u0627\u0628\u0646\u062f\u06cc\u0627\u06ba \u0644\u06af\u0627\u0626\u06cc \u062c\u0627 \u0633\u06a9\u062a\u06cc \u06c1\u06cc\u06ba\u06d4 \u062c\u0627\u0626\u0632 \u06c1\u06d2 \u06a9\u06cc\u0648\u0646\u06a9\u06c1 \u0627\u0646\u062a\u0638\u0627\u0645\u0627\u062a \u06a9\u06d2 \u0645\u0637\u0627\u0628\u0642 \u06c1\u06cc \u0644\u0648\u06af \u0641\u0631\u06cc\u0636\u06c1 \u062d\u062c \u0627\u062f\u0627 \u06a9\u0631 \u0633\u06a9\u06cc\u06ba \u06af\u06d2","Mufti":"\u0639\u0628\u062f\u0627\u0644\u0642\u06cc\u0648\u0645 \u06c1\u0632\u0627\u0631\u0648\u06cc"},{"Fatwa":"\u062d\u062c \u0642\u0631\u0627\u0646 \u0627\u0648\u0631 \u062d\u062c \u062a\u0645\u062a\u0639 \u06a9\u06d2 \u0628\u0627\u0631\u06d2 \u0645\u06cc\u06ba\u200c \u0628\u062a\u0627\u0626\u06cc\u06ba\u061f","Id":"195","Answer":"\u062d\u062c \u0642\u0631\u0627\u0646 \u0633\u06d2 \u0645\u0631\u0627\u062f \u062d\u062c
10-24 22:42:38.208 827-827/com.mianasad.deen E/Total Items Received:: 45
10-24 22:42:54.364 827-827/com.mianasad.deen E/filemap: mmap(0,20787696) failed: Out of memory
10-24 22:42:54.364 827-827/com.mianasad.deen W/asset: create map from entry failed
10-24 22:42:54.404 827-827/com.mianasad.deen D/AndroidRuntime: Shutting down VM
10-24 22:42:54.444 827-834/com.mianasad.deen W/art: Suspending all threads took: 7.171ms
10-24 22:42:54.454 827-827/com.mianasad.deen E/AndroidRuntime: FATAL EXCEPTION: main
                                                               Process: com.mianasad.deen, PID: 827
                                                               java.lang.RuntimeException: Font asset not found fonts/urdu.ttf
                                                                   at android.graphics.Typeface.createFromAsset(Typeface.java:272)
                                                                   at com.mianasad.deen.FatwaAdapter.onCreateViewHolder(FatwaAdapter.java:41)
                                                                   at com.mianasad.deen.FatwaAdapter.onCreateViewHolder(FatwaAdapter.java:29)
                                                                   at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6367)
                                                                   at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5555)
                                                                   at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5440)
                                                                   at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5436)
                                                                   at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2224)
                                                                   at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1551)
                                                                   at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1511)
                                                                   at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
                                                                   at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583)
                                                                   at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3025)
                                                                   at android.view.View.measure(View.java:18596)
                                                                   at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
                                                                   at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
                                                                   at android.view.View.measure(View.java:18596)
                                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
                                                                   at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
                                                                   at android.widget.LinearLayout.measureVertical(LinearLayout.java:721)
                                                                   at android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
                                                                   at android.view.View.measure(View.java:18596)
                                                                   at android.support.v4.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1420)
                                                                   at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                                                                   at android.support.v4.widget.NestedScrollView.onMeasure(NestedScrollView.java:482)
                                                                   at android.view.View.measure(View.java:18596)
                                                                   at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
                                                                   at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
                                                                   at android.view.View.measure(View.java:18596)
                                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
                                                                   at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                                                                   at android.view.View.measure(View.java:18596)
                                                                   at android.widget.LinearLayout.measureVertical(LinearLayout.java:874)
                                                                   at android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
                                                                   at android.view.View.measure(View.java:18596)
                                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
                                                                   at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                                                                   at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
                                                                   at android.view.View.measure(View.java:18596)
                                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
                                                                   at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
                                                                   at android.widget.LinearLayout.measureVertical(LinearLayout.java:721)
                                                                   at android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
                                                                   at android.view.View.measure(View.java:18596)
                                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
                                                                   at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                                                                   at android.view.View.measure(View.java:18596)
                                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
                                                                   at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
                                                                   at android.widget.LinearLayout.measureVertical(LinearLayout.java:721)
                                                                   at android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
                                                                   at android.view.View.measure(View.java:18596)
                                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
                                                                   at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                                                                at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:289

1 个答案:

答案 0 :(得分:0)

日志中的错误很明显。

  

java.lang.RuntimeException:找不到字体资产fonts / urdu.ttf

您正在项目中调用名为urdu.ttf的资产(这是一种字体资源),但您没有将其添加到/assets文件夹