Google PlusOneButton not compatible with Instant Run - android

Every time Instant Run applied code changes and restart an activity containing a GooglePlusOne button the app crashes with the following exception:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mycompany.myapp, PID: 26877
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycompany.myapp/com.mycompany.activities.MyActivity}: android.view.InflateException: Binary XML file line #221: Error inflating class <unknown>
...
Caused by: android.view.InflateException: Binary XML file line #221: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
...
...
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1266)
at android.content.res.Resources.getDrawable(Resources.java:785)
at android.content.res.Resources.getDrawable(Resources.java:752)
at com.google.android.gms.plus.PlusOneDummyView$zzb.getDrawable(Unknown Source)
at com.google.android.gms.plus.PlusOneDummyView.<init>(Unknown Source)
at com.google.android.gms.plus.internal.zzg.zza(Unknown Source)
at com.google.android.gms.plus.PlusOneButton.zzca(Unknown Source)
at com.google.android.gms.plus.PlusOneButton.<init>(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at com.mycompany.MyActivity.inializeContents(MyActivity.java:37)
...
...
I do not know where to fill a bug report for Google Play Services, hoping the Google team look at StackOverflow.
And is there any workaround to make Instant Run works even in this such case?
Note: I'm using Android Studio 2.2 and Google Play Services 9.6.0 but this problem also occurred on previous versions.

Related

Error inflating class android.webkit.WebView on android 5

I got the following error testing on Android 5.0 (API 21). Tested on other OS versions works well.
java.lang.RuntimeException: Unable to start activity
ComponentInfo{...ui.activities.navigationActivity.fragments.legalFragment.LegalDetailActivity}:
android.view.InflateException: Binary XML file line #24: Error
inflating class android.webkit.WebView
Can't find nothing special about the xml layout, at line 24:
<WebView
android:id="#+id/nav_fg_legal_detail_web"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
The code:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setTheme(R.style.AppTheme_NoActionBar)
setContentView(R.layout.legal_detail_activity) // crash here. Nothing done to web view yet.
I am using library 'androidx.appcompat:appcompat:1.1.0'.
Update:
the full stack:
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.byte_artisan.mchat2, PID: 4198
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.byte_artisan.mchat2/com.byte_artisan.mchat2.ui.activities.navigationActivity.fragments.legalFragment.LegalDetailActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class android.webkit.WebView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class android.webkit.WebView
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.byte_artisan.mchat2.ui.activities.navigationActivity.fragments.legalFragment.LegalDetailActivity.onCreate(LegalDetailActivity.kt:18)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 
at android.app.ActivityThread.access$800(ActivityThread.java:144) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5221) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) 
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) 
at com.byte_artisan.mchat2.ui.activities.navigationActivity.fragments.legalFragment.LegalDetailActivity.onCreate(LegalDetailActivity.kt:18) 
at android.app.Activity.performCreate(Activity.java:5937) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 
at android.app.ActivityThread.access$800(ActivityThread.java:144) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5221) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040002
at android.content.res.Resources.getText(Resources.java:274)
at android.content.res.Resources.getString(Resources.java:360)
at com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:702)
at com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:608)
at com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:619)
at com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:758)
at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:608)
at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:546)
at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:312)
at com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:97)
at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:264)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.drainQueue(WebViewChromium.java:124)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue$1.run(WebViewChromium.java:111)
at com.android.org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:144)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.addTask(WebViewChromium.java:108)
at com.android.webview.chro
24 April 2020, I solved it with this:
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
Previous and not working version is below:
implementation 'androidx.appcompat:appcompat:1.1.0'
Recently I faced the same, There is an issue which is mentioned over here, which is not solved yet. The crash only occurs on API 21.
There are few solutions which mention downgrading the androidx.appcompat:appcompat versions. This answer helped me. Also, there are other possible workarounds mentioned, pick the answer that applies to you.
EDIT: The crash also occurs on API 22 and 23 if the user doesn't have Google Play installed.
EDIT 2: As mentioned in the issue tracker here, and upgrading the androidx.appcompat:appcompat version to 1.2.0-alpha02 is providing the fix in some cases. Please go through a detailed discussion to find a suitable workaround.
As mentioned by #MiguelSlv adding this maven repository is a temporary fix, However, all the above workarounds have side effects. As the bug is not fixed yet, it is not a clean solution.
EDIT 3: As of May, 2020, there is a fix.
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
Previous not working version:
implementation 'androidx.appcompat:appcompat:1.1.0'
This answer I am writing in Mar, 2020, could be changed after that.
In my case , in build.gradle (app level), I changed
implementation 'androidx.appcompat:appcompat:1.0.0'
to
implementation 'androidx.appcompat:appcompat:1.2.0-alpha02'
and the Problem is solved.
Other configuration I already have, but I didn't change them:-
In Gradle project level
classpath 'com.android.tools.build:gradle:3.5.3'
And in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
And in gradle app level
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
...
}
Noting that this solution is tested on real device with android version 5
I have over ten apps, All of my apps have "Inflating problems" I was trying to solve problems... And I have tested with emulators and real device, they have no crash ... But My user thus!
Finally while testing with emulator , I catched crash.. Here is result:
This answer writing with 19 April 2020:
androidx.appcompat:appcompat:1.2.0-beta01
androidx.appcompat:appcompat:1.2.0-alpha03
androidx.appcompat:appcompat:1.2.0-alpha02
above versions have Serious problems.... Creating dialog, cause Edittext or TextView inflating problems...
below versions have been tested a little but there were no crash
androidx.appcompat:appcompat:1.2.0-alpha01
androidx.appcompat:appcompat:1.1.0
Still testing this versions , will share results

App Keeps Crashing (Dont Understand) | Android Studio | Kotlin [duplicate]

This question already has answers here:
How to handle OutOfMemoryError
(6 answers)
Closed 4 years ago.
I recently started on Android Studio but all of a sudden my app is crashing. My last time when I had this problem I was able to fix it after a bit of testing out and pinpointing what the problem was. This time, on the other hand, I am completely confused as I have 0 errors in my code screen. I checked the Logcat and I dont even understand anything from it. Can someone help me read this debug log so I can understand where to fix the problem?
08-17 14:20:32.048 31768-31775/? E/art: Failed sending reply to debugger: Broken pipe 08-17 14:20:32.423 31768-31768/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.mathe.trickytriviagame, PID: 31768
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mathe.trickytriviagame/com.example.mathe.trickytriviagame.HomePage}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2787)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1504)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.mathe.trickytriviagame.HomePage.onCreate(HomePage.kt:11)
at android.app.Activity.performCreate(Activity.java:6757)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2787)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1504)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 307200012 byte allocation with 8388608 free bytes and 246MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:620)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:455)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1152)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:855)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:706)
at android.content.res.Resources.loadDrawable(Resources.java:863)
at android.content.res.TypedArray.getDrawable(TypedArray.java:928)
at android.view.View.<init>(View.java:4188)
at android.view.ViewGroup.<init>(ViewGroup.java:578)
at android.view.ViewGroup.<init>(ViewGroup.java:574)
at android.view.ViewGroup.<init>(ViewGroup.java:570)
at android.support.constraint.ConstraintLayout.<init>(ConstraintLayout.java:566)
... 23 more
resize your layout images src from drawable folder, app is crashing due to image size is greater then usual make the image size reduce. to

App keeps stopping when I try running it on phone (android studio)

I am getting an error when I run my android studio app on my phone. It says my app keeps stopping and won't load it.
Here is the error I got from the logs:
06-05 17:22:55.578 2715-2715/com.app.supermarketaislefinder E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.supermarketaislefinder, PID: 2715
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.supermarketaislefinder/com.app.supermarketaislefinder.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.app.supermarketaislefinder.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:6676)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 207936012 byte allocation with 4154252 free bytes and 186MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:655)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:483)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1157)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:720)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:571)
at android.content.res.Resources.loadDrawable(Resources.java:972)
at android.content.res.TypedArray.getDrawable(TypedArray.java:931)
at android.view.View.(View.java:4226)
at android.view.ViewGroup.(ViewGroup.java:603)
at android.view.ViewGroup.(ViewGroup.java:599)
at android.view.ViewGroup.(ViewGroup.java:595)
at android.support.constraint.ConstraintLayout.(ConstraintLayout.java:565)
Thanks.
It's a view inflation error,
recheck what your inflating in your activity (R.id.activitylayouttoinflate)
try to CTRL+click it to reach the xml,
and then check that xml for syntex error \ unsupported library.
post a different question for the second question you have.

Toast.makeText Giving "Error inflating class Textview" Exception

Every single Toast.makeText in my app is giving me a stack trace similar to this:
/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.application, PID: 8843
android.view.InflateException: Binary XML file line #27: Binary XML file line #27: Error inflating class TextView
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.widget.Toast.makeText(Toast.java:263)
at com.myapp.application.activities.ReportActivity$5.success(ReportActivity.java:240)
at com.myapp.application.activities.ReportActivity$5.success(ReportActivity.java:236)
at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
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 #27: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
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.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
at android.widget.Toast.makeText(Toast.java:263) 
at com.myapp.application.activities.ReportActivity$5.success(ReportActivity.java:240) 
at com.myapp.application.activities.ReportActivity$5.success(ReportActivity.java:236) 
at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
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.ArrayIndexOutOfBoundsException: length=16; index=1191
at android.content.res.StringBlock.get(StringBlock.java:65)
at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:1151)
at android.content.res.TypedArray.getString(TypedArray.java:195)
at android.support.v7.widget.TintTypedArray.getString(TintTypedArray.java:142)
at android.support.v7.widget.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:243)
at android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:165)
at android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:80)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:70)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1016)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1073)
These are some sample Toast.makeText calls that are causing it
Toast.makeText(ReportActivity.this, "Reported for " + reportType, Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.network_unavailable, Toast.LENGTH_SHORT).show();
It all started when we upgraded our Gradle libraries and started using these versions
compileSdkVersion 27
buildToolsVersion '27.0.1'
The bug apparently occurs when using support library 26+, on API 25 and lower, and is supposedly fixed in Oreo.
See: https://issuetracker.google.com/issues/64053344
The fix in my case was to change the fontFamily defined in my default theme, by extracting sans-serif-light to a string resource, that is going from this:
<style name="AppCompatTheme" parent="android:...">
<item name="fontFamily">sans-serif-light</item>
</style>
To this:
<style name="AppCompatTheme" parent="android:...">
<item name="fontFamily">#string/default_font</item>
</style>
with in my strings.xml:
<string name="default_font" translatable="false">sans-serif-light</string>
My Toast callings was with getBaseContext(). I just change it to getApplicationContext() to solve the problem.
I solved the crashing from the Toast.makeText entries all throughout the app by doing a global search for fontFamily and deleting the entries.
It seems like the font family was being defined and the new build tools and SDK didn't like that.

Error inflating MapView

I'm trying to show a MapView inside a Fragment and I get an error when I inflate it:
03-21 14:34:44.234 32691-32691/com.example.javiersanzrozalen.fatrunners E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.javiersanzrozalen.fatrunners, PID: 32691
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class com.google.android.gms.maps.MapView
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.gms.maps.MapView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430) at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) at android.view.LayoutInflater.inflate(LayoutInflater.java:495) at android.view.LayoutInflater.inflate(LayoutInflater.java:426) at com.example.javiersanzrozalen.fatrunners.Fragments.NuevaCarreraFragment.onCreateView(NuevaCarreraFragment.java:53) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363 at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149) at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/safeparcel/AbstractSafeParcelable; at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source) at com.google.android.gms.maps.MapView.<init>(Unknown Source) at java.lang.reflect.Constructor.newInstance0(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:430)  at android.view.LayoutInflater.createView(LayoutInflater.java:645)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)  at android.view.LayoutInflater.inflate(LayoutInflater.java:495)  at android.view.LayoutInflater.inflate(LayoutInflater.java:426)  at com.example.javiersanzrozalen.fatrunners.Fragments.NuevaCarreraFragment.onCreateView(NuevaCarreraFragment.java:53)  at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)  at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)  at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363 at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)  at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013) 
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6119) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable" on path: DexPathList[[zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/base.apk", zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.javiersanzrozalen.fatrunners-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.javiersanzrozalen.fatrunners-2/lib/x86, /system/lib, /vendor/lib]]
03-21 14:34:44.234 32691-32691/com.example.javiersanzrozalen.fatrunners E/AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 27 more
Any idea ? This is the XML where I place my MapView:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Fragments.NuevaCarreraFragment">
<com.google.android.gms.maps.MapView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
UPDATE
Finally solved it compiling the last version of Google Maps library recommended.
You are attempting to use the original version of Google Maps support for Android (com.google.android.maps). We refer to that now as Maps V1.
This will not work, as Maps V1 has been deprecated for over two years. You can no longer get API keys for it, so even if your code would be correct, it would not work. The crash is because the old MapView had to be used inside of a MapActivity, as the error indicates.
The current version of Google Maps support for Android — Maps V2 — has a very different API and does not involve classes in the com.google.android.maps package.

Categories

Resources