-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drawable files are not accessible in Android 11. adding support for android 11? #12
Comments
@chlegou Thanks for opening the issue. I tried to reproduce it using Android R simulator, Android Studio 4.0, latest Build Tools etc but couldn't reproduce it. Here was my configuration for the sample app code that is included in the master branch: Project Level build.gradle
App level build.gradle:
1- Can you include the top level build file and the app level build file for your project? |
for me, it's working fine, it didn't happened for me (having android 7). |
Thanks for the update @chlegou. Glad it worked out fine. Let me know if you see any other issue around it or the frequency of the error changes. For the time being I'm closing the issue. Feel free to reopen if it persists |
following this issue further, i have noticed other crashes:
I'm now 100% sure that it's not related to Android 11 (being in Beta currently, made me think it's related to it when noticing the first crash report). After peeking your source code, it's related to this: i recommend using:
this is part of the the crash report, hopefully might helps you to improve it better:
|
Thanks @chlegou. I've reopened it for further investigation. Can you please add the XML where you are adding |
Well, i believe it has nothing to do with it. but here it is anyway:
Also, following the vector drawables errors further, i finally get this solution that is working reliably good so far after 3 days of annoying drawables crashes: (instead of the above solution i have mentioned earlier) setting an image resource in XML layout file as a placeholder. then fetching the vector drawable using this method:
if the drawable fetched by this method isn't null, i apply it from java. otherwise, it's the default placeholder affected from the xml layout which is image drawable not vector drawable. This workaround is preventing app crashes so far. |
Thanks for looking into it further. I haven't been getting much time
lately. If you have the solution and has been working fine in prod, please
feel free to make a pull request to the repository.
Cheers!
…On Sun., Jun. 21, 2020, 4:35 a.m. chlegou, ***@***.***> wrote:
Well, i believe it has nothing to do with it. but here it is anyway:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
***@***.***/grey_50"
tools:context=".activity.MainActivity">
...........
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/footer"
android:layout_below="@+id/header">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="60dp"
android:orientation="vertical"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbars="none"
android:scrollingCache="true">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".activity.MainActivity">
................
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/layout_sign_in"
android:layout_width="match_parent"
android:layout_height="wrap_content"
***@***.***/blue_50"
android:gravity="center"
android:orientation="vertical"
***@***.***/spacing_large">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
***@***.***/message_login"
***@***.***/TextAppearance.AppCompat.Title"
android:textIsSelectable="true" />
<com.shobhitpuri.custombuttons.GoogleSignInButton
android:id="@+id/btn_sign_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="12dp"
***@***.***/common_signin_button_text_long"
app:isDarkTheme="true" />
</androidx.appcompat.widget.LinearLayoutCompat>
..........
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.core.widget.NestedScrollView>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>
Also, following the vector drawables errors further, i finally get this
solution that is working reliably good so far after 3 days of annoying
drawables crashes: (instead of the above solution i have mentioned earlier)
setting an image resource in XML layout file as a placeholder. then
fetching the vector drawable using this method:
/**
* This is a support method for API < 21 vector drawables.
*/
@nullable
public static Drawable getVectorDrawable(int resId) {
Drawable drawable = null;
try {
drawable = AppCompatResources.getDrawable(MainApp.getInstance().getApplicationContext(), resId);
} catch (Exception ignored) {
}
return drawable;
}
if the drawable fetched by this method isn't null, i apply it from java.
otherwise, it's the default placeholder affected from the xml layout which
is image drawable not vector drawable.
This workaround is preventing app crashes so far.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA22HX2ZCL32PVHX4MPA4A3RXXV63ANCNFSM4N45FHCA>
.
|
Hi im also facing this issue... Can someone help me ? |
Hi there, when deploying my app to production, i have seen this error in crashlytics happening to a user having an Android 11 Pixel 4 XL device. here is the error exception:
Please add support for Android 11 devices.
Thanks.
The text was updated successfully, but these errors were encountered: