java.lang.NoClassDefFoundError in Android 9 (Pie) - android

I have following error in Android 9 (Pie) I don't get where is the error I think its related to google gms libs.
java.lang.NoClassDefFoundError:
at fa.b (com.google.android.gms.dynamite_mapsdynamite#14574081#14.5.74 (100400-219897028):3)
at ez.a (com.google.android.gms.dynamite_mapsdynamite#14574081#14.5.74 (100400-219897028):3)
at fb.a (com.google.android.gms.dynamite_mapsdynamite#14574081#14.5.74 (100400-219897028):15)
at com.google.maps.api.android.lib6.drd.al.a (com.google.android.gms.dynamite_mapsdynamite#14574081#14.5.74 (100400-219897028):6)
at ee.a (com.google.android.gms.dynamite_mapsdynamite#14574081#14.5.74 (100400-219897028):21)
at ee.run (com.google.android.gms.dynamite_mapsdynamite#14574081#14.5.74 (100400-219897028):8)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:169)
at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
at ac.loadClass (com.google.android.gms.dynamite_dynamiteloader#14574081#14.5.74 (100400-219897028):4)
at java.lang.ClassLoader.loadClass (ClassLoader.java:312)

Here is official docs
If you are using com.google.android.gms:play-services-maps:16.0.0 or
below and your app is targeting API level 28 (Android 9.0) or above,
you must include the following declaration within the
element of AndroidManifest.xml.
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
This is handled for you if you are using
com.google.android.gms:play-services-maps:16.1.0 and is not necessary
if your app is targeting a lower API level.
and also add this tag in Menifest.xml
<application
.....
.....
android:usesCleartextTraffic="true">
if you are using send and received request to server like (Volley , retrofit and Http request)
Also try this one (optional)
convert the project to AndroidX make sure backup of project first.

Related

app crashes with MapView if i use sdk 29 ------

I have a problem with MapView. My map was loaded correctly until I used "targetSdkVersion 19", but since I updated to "targetSdkVersion 29" every time I launch the map activity, the app crashes.
Can anyone tell me what the problem might be?
2019-08-29 17:04:05.679 29021-29119/mcsistemi.tentatavendita E/AndroidRuntime: FATAL EXCEPTION: Thread-8
Process: mcsistemi.tentatavendita, PID: 29021
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
at ce.b(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):3)
at cb.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):3)
at cd.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):14)
at com.google.maps.api.android.lib6.drd.ak.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):4)
at bf.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):22)
at bf.run(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):8)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/data/user_de/0/com.google.android.gms/app_chimera/m/000000c6/MapsDynamite.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/000000c6/MapsDynamite.apk!/lib/arm64-v8a, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at ad.loadClass(:com.google.android.gms.dynamite_dynamiteloader#19056081#19.0.56 (100400-262933554):4)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at ce.b(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):3) 
at cb.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):3) 
at cd.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):14) 
at com.google.maps.api.android.lib6.drd.ak.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):4) 
at bf.a(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):22) 
at bf.run(:com.google.android.gms.dynamite_mapsdynamite#19056081#19.0.56 (100400-262933554):8) 
Add this under <application> tag in Manifest.xml
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
With Android 6.0, we removed support for the Apache HTTP client.
Beginning with Android 9, that library is removed from the
bootclasspath and is not available to apps by default.
To continue using the Apache HTTP client, apps that target Android 9
and above can add the above line to their AndroidManifest.xml:
Here is more info
by Google
Since you say it started after android sdk 29, the problem could also be from the fact that you haven't changed your mappings to the current androidx mappings in the layout file that bring up this problem
If there is a library call like android.support.v7.widget.CardView in your layout causing the problem, you must change it to androidx.cardview.widget.CardView in android X and sdk 29 upwards..
For more mappings and how its currently written in the layout files, kindly check this link for the other class mappings https://developer.android.com/jetpack/androidx/migrate/class-mappings

Android 9 Pie crash (com.google.android.gms... ClassNotFoundException)

I have a Unity3D game published on Android, and it have worked well so far.
However, the Android Vitals Dashboard is now reporting a lot of crashes. Here's the detailed info:
By Android version: Android 9 4500 100.0%
Stacktrace:
java.lang.Error: FATAL EXCEPTION [Thread-360]
Unity version : 2017.3.1p3
Device model : Google Pixel
Device fingerprint: google/sailfish/sailfish:9/PQ2A.190305.002/5240760:user/release-keys
Caused by
at lt.b (com.google.android.gms.policy_ads_fdr_dynamite#30000#30000.238272502.238272502:2)
at ls.a (com.google.android.gms.policy_ads_fdr_dynamite#30000#30000.238272502.238272502:1)
at lu.a (com.google.android.gms.policy_ads_fdr_dynamite#30000#30000.238272502.238272502:18)
at com.google.android.gms.ads.internal.util.ar.a (com.google.android.gms.policy_ads_fdr_dynamite#30000#30000.238272502.238272502:10)
at kx.a (com.google.android.gms.policy_ads_fdr_dynamite#30000#30000.238272502.238272502:7)
at kx.run (com.google.android.gms.policy_ads_fdr_dynamite#30000#30000.238272502.238272502:2)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
at ac.loadClass (com.google.android.gms.dynamite_dynamiteloader#16089081#16.0.89 (100400-239467275):4)
at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
My AndroidResolverDependencies.xml file:
<dependencies>
<packages>
<package>com.android.support:customtabs:[26.0.0, 27.2.0[</package>
<package>com.android.support:support-v4:[26.0.0, 27.2.0[</package>
<package>com.google.android.gms:play-services-ads:17.2.0</package>
<package>com.google.android.gms:play-services-analytics:11.8.0</package>
<package>com.google.android.gms:play-services-base:[10.2.1, 12.1.0[</package>
<package>com.google.android.gms:play-services-location:[10.2.1, 12.1.0[</package>
<package>com.google.firebase:firebase-messaging:[10.2.1, 12.1.0[</package>
</packages>
<files>
<file>Assets/Plugins/Android/android.arch.core.common-1.1.0.jar</file>
<file>Assets/Plugins/Android/android.arch.core.runtime-1.1.0.aar</file>
<file>Assets/Plugins/Android/android.arch.lifecycle.common-1.1.0.jar</file>
<file>Assets/Plugins/Android/android.arch.lifecycle.livedata-core-1.1.0.aar</file>
<file>Assets/Plugins/Android/android.arch.lifecycle.runtime-1.1.0.aar</file>
<file>Assets/Plugins/Android/android.arch.lifecycle.viewmodel-1.1.0.aar</file>
<file>Assets/Plugins/Android/com.android.support.customtabs-27.1.1.aar</file>
<file>Assets/Plugins/Android/com.android.support.support-annotations-27.1.1.jar</file>
<file>Assets/Plugins/Android/com.android.support.support-compat-27.1.1.aar</file>
<file>Assets/Plugins/Android/com.android.support.support-core-ui-27.1.1.aar</file>
<file>Assets/Plugins/Android/com.android.support.support-core-utils-27.1.1.aar</file>
<file>Assets/Plugins/Android/com.android.support.support-fragment-27.1.1.aar</file>
<file>Assets/Plugins/Android/com.android.support.support-media-compat-27.1.1.aar</file>
<file>Assets/Plugins/Android/com.android.support.support-v4-27.1.1.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-ads-17.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-ads-base-17.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-ads-identifier-16.0.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-ads-lite-17.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-analytics-16.0.8.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-analytics-impl-16.0.8.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-base-16.1.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-basement-16.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-gass-17.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-location-16.0.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-measurement-base-16.3.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-measurement-sdk-api-16.3.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-places-placereport-16.0.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-stats-16.0.1.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-tagmanager-v4-impl-16.0.8.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-tasks-16.0.1.aar</file>
<file>Assets/Plugins/Android/com.google.auto.value.auto-value-annotations-1.6.jar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-common-16.1.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-iid-17.1.2.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-iid-interop-16.0.1.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-measurement-connector-17.0.1.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-messaging-17.6.0.aar</file>
</files>
</dependencies>
Target API level: 28
Minimum API level: 16
I've seen a similar thread in Google AdMob's discussion group suggesting to add the following to the AndroidManifest.xml file:
<uses-library android:name="org.apache.http.legacy" android:required="false" />
However:
I'm not sure the problem is caused by any apache-related API.
I'm afraid this will restrict the number of installs in my app since it will be available to a smaller audience in Google Play due to the uses-library declaration.
As per Behavior changes: apps targeting API level 28+
Apache HTTP client deprecation
With Android 6.0, we removed support for the Apache HTTP client.
Beginning with Android 9, that library is removed from the
bootclasspath and is not available to apps by default. To continue using the Apache HTTP client, apps that target Android 9 and above can add the following to their AndroidManifest.xml:
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
Note: The android:required="false" attribute is required for apps that
have a minimum SDK of 23 or lower, because on devices with API levels
lower than 24, the org.apache.http.legacy library is not available.
(On those devices, the Apache HTTP classes are available on the
bootclasspath.)
As an alternative to using the runtime Apache library, apps can bundle
their own version of the org.apache.http library in their APK. If you
do this, you must repackage the library (with a utility like Jar Jar)
to avoid class compatibility issues with the classes provided in the
runtime.

ClassNotFoundException in ad.loadClass in Android 9 (API 28)

I have an app in the production, and some of the users in Android 9 are getting this error:
ClassNotFoundException in ad.loadClass in Android 9 (API 28)
Here is more detailed report, it seems that something wrong with ads.
I'm using this version of google ads:
implementation 'com.google.android.gms:play-services-ads:17.1.1'
Any ideas how to fix it?
I added to Manifest, this line, and it seems that this error disappeared:
<uses-library android:name="org.apache.http.legacy" android:required="false" />

App crashes when running maps activity

My projects Map activity is not working
I just pasted the api key in place google_maps_api.xml
and clicked run
Logcat:
E/AndroidRuntime: FATAL EXCEPTION: Thread-5
Process: com.example.appmy.lofind, PID: 10901
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
at el.b(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):3)
at ek.a(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):4)
at em.a(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):51)
at com.google.maps.api.android.lib6.drd.ap.a(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):11)
at dw.a(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):16)
at dw.run(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):61)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/system/priv-app/PrebuiltGmsCore/app_chimera/m/MapsDynamite.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000006/MapsDynamite.apk!/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:126)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at ad.loadClass(:com.google.android.gms.dynamite_dynamiteloader#12848026#12.8.48 (040700-196123505):25)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at el.b(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):3) 
at ek.a(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):4) 
at em.a(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):51) 
at com.google.maps.api.android.lib6.drd.ap.a(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):11) 
at dw.a(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):16) 
at dw.run(:com.google.android.gms.dynamite_mapsdynamite#12848026#12.8.48 (040700-196123505):61) 
E/SchedPolicy: set_timerslack_ns write failed: Operation not permitted
I've found another solution at
Android Google maps java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion
Just add this in your manifest:
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
Update:
Starting from Google Maps SDK version 16.1.0 you can skip adding the solution above as the tag has been added to the AndroidManifest of the maps library.
https://developers.google.com/maps/documentation/android-sdk/releases#2019-02-06
Added the following declaration to the AndroidManifest.xml to support
the Apache HTTP client on Android P and above. After updating to
com.google.android.gms:play-services-maps:16.1.0 you can remove this
line from your own AndroidManifest.xml. (Issue 117591497)
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
The same problem here when using target SDK 28. Reverting to SDK 27 solved the problem.
Don't revert your target SDK.
Better use this solution https://stackoverflow.com/a/50944537/5710605
Put this in the Manifest tag:
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
More info: https://issuetracker.google.com/issues/79478779
as google documentation said:
If you are using com.google.android.gms:play-services-maps:16.0.0 or
below and your app is targeting API level 28 (Android 9.0) or above,
you must include the following declaration within the
element of AndroidManifest.xml.

Fabric initialization could not calculate hash for app icon in case of Android Instant Apps

I am initializing Fabric in Application class as
Fabric.with(context, crashlyticsKit);
My project is divided into three modules - base feature module, apk-wrapper module and an instant-app module. App Icon is declared as application attribute in AndroidManifest.xml of base feature module.
At startup of Instant app, Fabric throws following error
E/Fabric: Could not calculate hash for app icon.
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1351)
at android.content.res.Resources.openRawResource(Resources.java:1265)
at android.content.res.Resources.openRawResource(Resources.java:1241)
at io.fabric.sdk.android.services.common.CommonUtils.getAppIconHashOrNull(CommonUtils.java:824)
at io.fabric.sdk.android.services.settings.Settings.initialize(Settings.java:83)
at io.fabric.sdk.android.Onboarding.retrieveSettingsData(Onboarding.java:124)
at io.fabric.sdk.android.Onboarding.doInBackground(Onboarding.java:99)
at io.fabric.sdk.android.Onboarding.doInBackground(Onboarding.java:45)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:63)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:28)
at io.fabric.sdk.android.services.concurrency.AsyncTask$2.call(AsyncTask.java:311)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
This is a known issue with Fabric + Instant Apps. It's not critical though and will only mean your console will not be able to display your app icon.
Go over the app icons and make sure your app has the proper launcher icon for all versions (both android:icon and android:roundIcon )
Make sure to have a proper fallback to versions below 26 if you use adaptive icons.
Simply add an app icon in your manifest like so:
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher" <----- add this
android:label="#string/app_name"
android:theme="#style/AppTheme">
...
...
...
</application>

Categories

Resources