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.
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.
Background
I have an app with Admob SDK used in it, to show Interstitial ads (full screen ads).
Reccently Google has updated the SDK, along with many other things (build tools, gradle plugin, IDE, etc...), including admob (firebase ads).
compile 'com.google.firebase:firebase-ads:11.4.2'
The problem
After updating, I noticed that whenever the app tries to show an Interstitial ad, it crashes.
The crash log is as such:
10-28 14:01:01.394 4523-4523/... I/Ads: Ad opening.
10-28 14:01:01.400 1606-2154/? E/ActivityManager: Activity Manager Crash. UID:10080 PID:4523 TRANS:63
java.lang.IllegalStateException: Only fullscreen activities can request orientation
at com.android.server.am.ActivityRecord.setRequestedOrientation(ActivityRecord.java:2189)
at com.android.server.am.ActivityManagerService.setRequestedOrientation(ActivityManagerService.java:4975)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:1101)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2927)
at android.os.Binder.execTransact(Binder.java:697)
10-28 14:01:01.403 4523-4523/... D/AndroidRuntime: Shutting down VM
10-28 14:01:01.406 4523-4523/... E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{.../com.google.android.gms.ads.AdActivity}: java.lang.IllegalStateException: Only fullscreen activities can request orientation
Thing is that it worked fine before. Now I'm not sure what causes it to occur.
Searching the web, I didn't see anything that talks about "Only fullscreen activities can request orientation" .
What I had in the manifest, is something a bit old, that might not be needed anymore:
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="#android:style/Theme.Translucent"/>
I say it's probably not needed, because i can't see it anymore in the tutorials, even though I remember I did in the past:
https://developers.google.com/admob/android/quick-start
https://developers.google.com/admob/android/interstitial
What I've tried
I tried to remove the manifest entry. Still same issue.
I tried to set the theme to be "#android:style/Theme.Translucent.NoTitleBar.Fullscreen" by force, but it also didn't help.
I even thought that it might be because I currently have Android 8.1, but when I tried using the app from the play store, I noticed it worked just fine, without crashes.
I tried to go back to as far as version 11.2.2 of admob and use gradle v 2.3.3 , but it also didn't help.
When trying on an emulator with Android 7.0 , it worked fine with latest versions of everything, and removal of the whole manifest activity tag.
I tried to use this in gradle file, instead of what I used :
compile 'com.google.android.gms:play-services-ads:11.4.2'
Still crashed on my device (Nexus 5x with Android 8.1) yet didn't crash on emulator.
Finally, I tried to run the app on emulator with Android 8.1, and it crashed just as on the real device.
Reported about this to Google Admob team, as well as Android issue tracker. I hope they will answer me about this.
The questions
What could be the cause to this issue?
Is it because of Android 8.1 ? If so, how come the older version of the app worked fine? I tried to revert there a lot of versions to old ones, yet it still crashed.
And, most importantly, how can I solve it?
EDIT
Now a newer admob version is available.
I confirm that using the latest releases (15.0.1 or newer) the issue doesn't appear anymore, so you can use the latest version of Admob
com.google.firebase:firebase-ads:17.1.2
setting the target version to the latest, if you have used the workaround previously suggested.
----------------------------------------------------------
Set the target to Android API Level to 26 to fix the issue, waiting for Admob update
In build.gradle
targetSdkVersion 26
if targetSdkVersion is >=27 ( > android.os.Build.VERSION_CODES.Othat is 26) you get this error, they have changed ActivityRecord in latest Android version adding this:
void setRequestedOrientation(int requestedOrientation) {
if (ActivityInfo.isFixedOrientation(requestedOrientation) && !fullscreen
&& appInfo.targetSdkVersion > O) {
throw new IllegalStateException("Only fullscreen activities can request orientation");
....
}
The change has been introduced in this commit
Prevent non-fullscreen activities from influencing orientation This
changelist enforces that activities targeting O and beyond can only
specify an orientation if they are fullscreen.
and probably in admob lib have messed some check
EDIT
the newer (above 16) admob version fixed the issue
Old Answer
try to add this in your manifest
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
tools:replace="android:theme"
/>
Or, if you are using appcompat:
<style name="TranslucentTheme" parent="#style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
etc
And in the manifest, make sure the activity is declared with
android:theme="#style/TranslucentTheme"
please do not use any properties in Android Manifest files AdActivity.
please remove this line from AdActivity in Manifest file
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
Just simply add this following line to Android Manifest file.
<activity android:name="com.google.android.gms.ads.AdActivity" />
If you want to set your desired activity as portrait mode please add this following line to your activities onCreate method:
if (android.os.Build.VERSION.SDK_INT != Build.VERSION_CODES.O) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
For firebase ADS 17.0.0 and upper versions use this line to manifest file.
<application
...........>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/app_id" />
</application>
You can get app id from Admob -> Apps -> your app -> App Settings -> App Id. Please copy and paste this App_Id into your project.
This issue will Automatically be fixed when ad mob will update their ads sdk for API 27
their ads dependency do not support API 27 so due to this issue occurring.
compile 'com.google.android.gms:play-services-ads:11.8.0'
Only full screen activities can request orientation, this is due to ads meta data in your mainfest file,admob should update their sdk for 27 version.
if you have set target sdk version 27 then you would get this error, actually android updating sdk very fast, and some update admob left behind to do ,for integration with android sdk, so admob have pending this update, they should do this very soon ,Its not on developer side issue, if you wants to escape from this crash then set your sdk to 26.
It seems that upgrading to:
com.google.firebase:firebase-ads:15.0.1
solved this issue for me. I've just tested it on Nexus 5X with 8.1.0 and Interstitial Admob ads work now.
More complete solution:
app's build.gradle:
...
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
...
targetSdkVersion 27
..
}
}
dependencies {
...
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-ads:15.0.1'
...
}
apply plugin: 'com.google.gms.google-services'
top level build.gradle:
buildscript {
...
dependencies {
...
classpath 'com.google.gms:google-services:3.3.0'
...
}
}
...
I got the same crash with Vungle SDK (which was included through Appodeal SDK), so this does not precisely answer the question related to Admob SDK, but in case anyone's getting this with Vungle or Appodeal SDK:
The versions were as follows: Appodeal SDK - 2.4.2-220518, Vungle SDK - 6.2.5.
After upgrading to the at that time newest Appodeal SDK (version 2.4.9-051218), newer Vungle SDK was included (version 6.3.12) and the crash no longer occured.
In Android Oreo You can't change the orientation by code so you have check whenever change the orientation
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
I am trying to change the transition from default to sliding in. I would like to keep my minSdkVersion to be 3 however overridePendingTransition wasn't added until API level 5 (Android 2.0).
I tried creating an integer to represent the SDK version and then only override the transition when in Android 1.6 or less via a simple if statement.
int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
if(sdkVersion>=5)
overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.fade_out);
Eclipse gives me a LINT warning stating "Call requires API level 5 (current min is 3): android.app.Activity#overridePendingTransition"
If I suppress this error and run it anyway it crashes on Android 1.6 or lower.
What is wrong with my code and how can I fix it? Any suggestions would be very appreciated!
In your android manifest file you have this ...
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="latest version" />
Change the min sdk version to 5 like show below
<uses-sdk
android:minSdkVersion="5"
android:targetSdkVersion="latest version" />
While running my application i am getting the below given warning and application went force close.
[2011-10-17 12:09:09 - LunarLander] WARNING: Application does not specify an API level requirement!
[2011-10-17 12:09:09 - LunarLander] Device API version is 9 (Android 2.3.1)
How to resolve this. I created another emulator with API level 10, then also i am getting the same error.
I am sure you forget to define the API level inside the AndroidManifest.xml file, define it as:
<uses-sdk android:minSdkVersion="5"
android:maxSdkVersion="10"
android:targetSdkVersion="8"/>
You should define the API level of your application in manifest file. I think you forgot to that. Launch the application according to that.
Just looking at that error you need to specify an API level for your application:
http://developer.android.com/guide/appendix/api-levels.html