How to solve the Navigation View resource issue in Android Oreo? - android

In Android Oreo device, Navigation View always showing below mentioned issue.
W/Resources: ColorStateList android:color/text_color_primary has unresolved theme attributes! Consider using Resources.getColorStateList(int, Theme) or Context.getColorStateList(int).
java.lang.RuntimeException
at android.content.res.Resources.getColorStateList(Resources.java:990)
at android.support.design.widget.NavigationView.createDefaultColorStateList(NavigationView.java:416)
at android.support.design.widget.NavigationView.(NavigationView.java:144)
at android.support.design.widget.NavigationView.(NavigationView.java:96)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at info.androidhive.navigationdrawer.activity.MainActivity.onCreate(MainActivity.java:71)
how can i resolve this?

Related

Android ResourceNotFoundException in preview custom View

I've got a custom view, let's call it CustomView. In the initialization, I call the following method
textPaint.setTypeface(ResourcesCompat.getFont(getContext(),R.font.pretty_font));
In the app, this view works perfectly and the font is displayed as it should but the problem is that the preview of the view wont load in the editor with the following details:
android.content.res.Resources$NotFoundException: Font resource ID
0x7f090000 could not be retrieved.
at androidx.core.content.res.ResourcesCompat.loadFont(ResourcesCompat.java:365)
at
androidx.core.content.res.ResourcesCompat.getFont(ResourcesCompat.java:230)
at
com.mycompany.myapp.view.views.CustomView.init(CustomView.java:490)
at
com.mycompany.myapp.view.views.CustomView.initAttrs(CustomView.java:484)
at
com.mycompany.myapp.view.views.CustomView.(CustomView.java:116)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at
org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:403)
at
org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:186)
at
org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:144)
at
com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:309)
at
android.view.BridgeInflater.loadCustomView(BridgeInflater.java:418)
at
android.view.BridgeInflater.loadCustomView(BridgeInflater.java:429)
at
android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:333)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at
android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863)
at
android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:837) at
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at
android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:866)
at
android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:837) at
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at
android.view.LayoutInflater.inflate(LayoutInflater.java:394) at
com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:323)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:394)
at
com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:200)
at
com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:572)
at
com.android.tools.idea.rendering.RenderTask.lambda$inflate$5(RenderTask.java:698)
at
java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Why won't this resource be loaded in the editor but it has no problem running in the app?
FYI, MinSdk = 21 and TargetSdk = 28
Don't call setTypeface in design mode. Use:
if (!isInEditMode()) {
textPaint.setTypeface(ResourcesCompat.getFont(getContext(),R.font.pretty_font))
}

ResourceNotFoundException after splitting apks

After integrating App-Bundle into my professional app I faced many issues through Crashlytics about the first screen of the app when inflating an ImageView.
This is the ResourceNotFoundException.
Caused by: android.view.InflateException: Binary XML file line #48: Binary XML file line #48: Error inflating class ImageView
Caused by: android.view.InflateException: Binary XML file line #48: Error inflating class ImageView
Caused by: android.content.res.Resources$NotFoundException: Drawable (missing name) with resource ID #0x7f08009d
Caused by: android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f08009d
at android.content.res.ResourcesImpl.getResourceName(ResourcesImpl.java:242)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:739)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:609)
at android.content.res.Resources.loadDrawable(Resources.java:885)
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:953)
at android.content.res.TypedArray.getDrawable(TypedArray.java:928)
at android.widget.ImageView.<init>(ImageView.java:188)
at android.widget.ImageView.<init>(ImageView.java:171)
at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:72)
at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
at androidx.appcompat.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:187)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:107)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1267)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1317)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:470)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:141)
at io.example.SplashScreen.onCreate(SplashScreenActivity.kt:50)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
2019-03-11 12:13:52.605 14143-14143/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Of course I couldn't reproduce at the beginning then I made many attempts with bundletool. I've seen similar threads but not digging the issue enough.
I figured out that generating an apk from the bundle with a lower density could reproduce the crash.
With my attempt I extracted Nexus6P specs as following
{
"supportedAbis": ["x86"],
"supportedLocales": ["en_US"],
"screenDensity": 560,
"sdkVersion": 26
}
Then I changed screenDensity to 320 or even 120 which makes the crash happen.
Lookin' deeper at the *.apks generated file we have :
base-en.apk
base-ldpi.apk
base-master.apk
I currently have mdpi/hdpi/xhdpi/xxhdpi/xxxhdpi folders.
I tried adding drawable-ldpi folder but in vain.
I checked in base-ldpi.apk to look after the resource not found, it is well present in the apk.
As a quick fix I can disable density splitting from gradle configuration or even turn off app bundle but I wish for a better ending.
Any idea ? Thank you :)

Android Studio not rendering AppCompatButton in preview and design

I have this AppCompatButton :
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn1"
android:layout_width="0dp"
style="#style/buttons_style"
android:text="#string/text1" />
But Android Studio designer preview displays it like this, how can make it update the preview show complete preview? :
There are errors in designer, saying AppCompatButton is raising exceptions while rendering :
java.lang.UnsupportedOperationException
at android.content.res.Resources_Delegate.obtainTypedArray(Resources_Delegate.java:531)
at android.content.res.Resources.obtainTypedArray(Resources.java:615)
at android.widget.TextView.<init>(TextView.java:1386)
at android.widget.Button.<init>(Button.java:166)
at android.widget.Button.<init>(Button.java:141)
at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:70)
at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:66)
at sun.reflect.GeneratedConstructorAccessor925.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:481)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:264)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:222)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:209)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:337)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:348)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:248)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:866)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:866)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:866)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:204)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:900)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:859)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:866)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:325)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:384)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:544)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:678)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
i guess he's missing n layout_height attribute in #style/buttons_style

app is working on android 7 and 8 but not working on android 5 and 6

App working fine on android 8 virtual device but it crashes and force closes on android 6.0.1 hardware device. MinSDK version of the app is API21 android 5. everything is working fine on virtual device app functionality database connectivity but when I try to run app on a hardware device it just show splash screen and then it closes itself show error app stopped working on and shows a lot of error in logcat which I am having understanding them. I have provided all the java code which I have used in-app for your better understanding
Error in LogCat
06-16 14:27:20.657 21865-21865/com.example.tanishqshastri_mppolice.jansunwai E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.tanishqshastri_mppolice.jansunwai, PID: 21865
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tanishqshastri_mppolice.jansunwai/com.example.tanishqshastri_mppolice.jansunwai.MainActivity}: android.view.InflateException: Binary XML file line #38: Binary XML file line #38: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #38: Binary XML file line #38: Error inflating class <unknown>
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.tanishqshastri_mppolice.jansunwai.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6323)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #38: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.tanishqshastri_mppolice.jansunwai.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6323)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.tanishqshastri_mppolice.jansunwai.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6323)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.tanishqshastri_mppolice.jansunwai:drawable/roundstatus" (7f070082) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f070082 a=-1 r=0x7f070082}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2625)
at android.content.res.Resources.loadDrawable(Resources.java:2563)
at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
at android.view.View.<init>(View.java:3975)
at android.view.ViewGroup.<init>(ViewGroup.java:574)
at android.widget.LinearLayout.<init>(LinearLayout.java:203)
at android.widget.LinearLayout.<init>(LinearLayout.java:199)
at android.widget.LinearLayout.<init>(LinearLayout.java:195)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.tanishqshastri_mppolice.jansunwai.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6323)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
The real error is this one:
Resource "com.example.tanishqshastri_mppolice.jansunwai:drawable/roundstatus" (7f070082) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f070082 a=-1 r=0x7f070082}
Something in the definition of this drawable object is not compatible with Android 6, I can't help you more than that without more details about that drawable resource
If your app is working fine in android 8 emulator you can't assume that it will be working fine on every previous version of android! If you use an android 6 emulator image the app will crash exactly as with real device
I renamed the drawable-v24 to drawable-xxhpi and it my app is working on Android 6.

Instant App module searches for resources in another not base module

I'm developing an Instant App, that has base module and 2 feature modules: feature1 and feature2. I'm getting strange crash when I'm trying to launch feature2 activity:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.myapp.qa/com.test.myapp.feature2.ui.activity.Feature2Activity}: android.view.InflateException: Binary XML file line #76: Binary XML file line #76: Error inflating class android.widget.ProgressBar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6540)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.view.InflateException: Binary XML file line #76: Binary XML file line #76: Error inflating class android.widget.ProgressBar
Caused by: android.view.InflateException: Binary XML file line #76: Error inflating class android.widget.ProgressBar
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:650)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:723)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:791)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at com.test.myapp.ui.activity.base.BaseActivity.setContentView(BaseActivity.java:237)
at com.test.myapp.feature2.ui.activity.Feature2Activity.onCreate(Feature2Activity.java:123)
at android.app.Activity.performCreate(Activity.java:6980)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6540)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.content.res.Resources$NotFoundException: Drawable com.test.myapp.qa:layout/random_feature1_layout with resource ID #0x82030011
E/AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: File res/layout/random_feature1_layout_fns.xml from drawable resource ID #0x82030011
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:754)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:598)
at android.content.res.Resources.loadDrawable(Resources.java:885)
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:953)
at android.content.res.TypedArray.getDrawable(TypedArray.java:928)
at android.widget.ProgressBar.<init>(ProgressBar.java:281)
at android.widget.ProgressBar.<init>(ProgressBar.java:230)
at android.widget.ProgressBar.<init>(ProgressBar.java:226)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:650)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:723)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:791)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at com.test.myapp.ui.activity.base.BaseActivity.setContentView(BaseActivity.java:237)
at com.test.myapp.feature2.ui.activity.Feature2Activity.onCreate(Feature2Activity.java:123)
at android.app.Activity.performCreate(Activity.java:6980)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6540)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.view.InflateException: Class not found LinearLayout
at android.graphics.drawable.DrawableInflater.inflateFromClass(DrawableInflater.java:220)
at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:139)
at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1295)
at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1254)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:744)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:598) 
at android.content.res.Resources.loadDrawable(Resources.java:885) 
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:953) 
at android.content.res.TypedArray.getDrawable(TypedArray.java:928) 
at android.widget.ProgressBar.<init>(ProgressBar.java:281) 
at android.widget.ProgressBar.<init>(ProgressBar.java:230) 
at android.widget.ProgressBar.<init>(ProgressBar.java:226) 
at java.lang.reflect.Constructor.newInstance0(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:334) 
at android.view.LayoutInflater.createView(LayoutInflater.java:650) 
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:723) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:791) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:869) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:827) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 
at com.test.myapp.ui.activity.base.BaseActivity.setContentView(BaseActivity.java:237) 
at com.test.myapp.feature2.ui.activity.Feature2Activity.onCreate(Feature2Activity.java:123) 
at android.app.Activity.performCreate(Activity.java:6980) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6540) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
06-18 10:42:37.616 11607-11607/com.test.myapp.qa E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "LinearLayout" on path: DexPathList[[zip file "/data/app/com.test.myapp.qa-ncO99Ptagbu_PYoBeZhFeA==/base.apk", zip file "/data/app/com.test.myapp.qa-ncO99Ptagbu_PYoBeZhFeA==/split_feature2.apk", zip file "/data/app/com.test.myapp.qa-ncO99Ptagbu_PYoBeZhFeA==/split_feature1.apk"],nativeLibraryDirectories=[/data/app/com.test.myapp.qa-ncO99Ptagbu_PYoBeZhFeA==/lib/x86, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.graphics.drawable.DrawableInflater.inflateFromClass(DrawableInflater.java:201)
... 47
If we look at Feature2Activity layout file, line 76 we'll see:
<ProgressBar
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="right"
android:indeterminateDrawable="#drawable/progress" />
Drawable progress.xml is located in feature2 resources. If we remove it, or change it to some drawable from base resources, everything works fine.
Another strange thing is this line:
Caused by: android.content.res.Resources$NotFoundException: Drawable com.test.myapp.qa:layout/random_feature1_layout with resource ID #0x82030011
Layout random_feature1_layout is located at feature1 resources, and shouldn't be referenced at all. But if we go to feature2\R.java file, and look for progress.xml drawable we'll find:
public static final int progress=0x80030011;
And if you look closer you'll notice that progress's and random_feature1_layout's ids are differ by one digit: 0x80030011 and 0x82030011. So I made an assumption, that feature2 for unknown reasons looks for progress drawable in feature1 resources. I tried to remove feature1 dependency and crash disappeared, that confirms my assumption.
I should also note that this issue is observed only for Instant app. Installed app works fine.
My question is how is it possible that feature2 searches for resources in feature1 apk? Do you have any ideas what caused this behaviour or maybe hints how to debug this issue?
With reference to Google issue tracker, it has been fixed with Android SDK Built-Tools to 27.0.2
Please update your Android SDK Built-Tools to 27.0.2
And ensure you are on Android Studio 3.0.1 or newer.
If any issue persists, please report at Google issue tracker they will re-open to examine. Thanks!

Categories

Resources