That would be great.
Building works on macOS, building on Windows gave errors, I’ll see how is it and try to resolve it if it’s still fails, maybe I’ll manage this time.
Works ok. I just tested extension as dependcies on Windows PC.
Yay! Thank you. It’s time to celebrate.
@sergey.lerg
Got a crash when istalling .apk to device.
Builded with Defold version: 1.2.154
Exception: Unable to instantiate receiver com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver: java.lang.ClassNotFoundException: Didn’t find class “com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver”
logcat:
2019-06-15 21:36:51.572 26708-26708/com.dragosha.hamster E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dragosha.hamster, PID: 26708
java.lang.RuntimeException: Unable to instantiate receiver com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver" on path: DexPathList[[zip file "/data/app/com.dragosha.hamster-1/base.apk"],nativeLibraryDirectories=[/data/app/com.dragosha.hamster-1/lib/arm, /data/app/com.dragosha.hamster-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3021)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1561)
at android.os.Handler.dispatchMessage(Handler.java:102)
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.measurement.AppMeasurementInstallReferrerReceiver" on path: DexPathList[[zip file "/data/app/com.dragosha.hamster-1/base.apk"],nativeLibraryDirectories=[/data/app/com.dragosha.hamster-1/lib/arm, /data/app/com.dragosha.hamster-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3016)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1561)
at android.os.Handler.dispatchMessage(Handler.java:102)
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)
Final AndroidMaifest.xml as merge of builtins manifest (1.2.154) and admob manifest:
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dragosha.hamster"
android:installLocation="auto"
android:versionCode="70"
android:versionName="0.997" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="26" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- For GCM (push) -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:hasCode="true"
android:icon="@drawable/icon"
android:label="LookYourLoot" >
<!-- For Local Notifications -->
<receiver android:name="com.defold.push.LocalNotificationReceiver" >
</receiver>
<!-- For Google Play Services -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<!-- Disable Firebase Analytics -->
<meta-data
android:name="firebase_analytics_collection_deactivated"
android:value="true" />
<!-- For Facebook -->
<meta-data
android:name="com.facebook.sdk.ApplicationName"
android:value="LookYourLoot" />
<activity
android:name="com.dynamo.android.DefoldActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="LookYourLoot"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<meta-data
android:name="android.app.lib_name"
android:value="LookYourLoot" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.dynamo.android.DispatcherActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="LookYourLoot"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name="com.defold.iap.IapGooglePlayActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="IAP"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
</activity>
<!-- For local and Firebase notifications -->
<activity
android:name="com.defold.push.PushDispatchActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
<intent-filter>
<action android:name="com.defold.push.FORWARD" />
<category android:name="com.defold.push" />
</intent-filter>
</activity>
<!-- For Firebase Cloud Messaging -->
<service
android:name="com.defold.push.FirebaseMessagingService"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name="com.google.firebase.messaging.FirebaseMessagingService"
android:exported="true" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name="com.google.firebase.components.ComponentDiscoveryService"
android:exported="false" >
<meta-data
android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.defold.adtest" />
</intent-filter>
</receiver>
<!-- For IAC Invocations -->
<activity
android:name="com.defold.iac.IACActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.dragosha.hamster" />
</intent-filter>
</activity>
<!-- For Amazon IAP -->
<receiver android:name="com.amazon.device.iap.ResponseReceiver" >
<intent-filter>
<action
android:name="com.amazon.inapp.purchasing.NOTIFY"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
</intent-filter>
</receiver>
<!-- ********************* firebase ********************* -->
<!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
<activity
android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
android:theme="@style/Theme.IAPTheme" />
<activity
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true"
android:exported="false" >
</receiver>
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
android:enabled="true"
android:permission="android.permission.INSTALL_PACKAGES" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false" />
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="com.defold.adtest.firebaseinitprovider"
android:exported="false"
android:initOrder="100" />
<!-- Internal (not exported) receiver used by the app to start its own exported services without risk of being spoofed. -->
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
android:exported="false" />
<!-- FirebaseInstanceIdService performs security checks at runtime, no need for explicit permissions despite exported="true" -->
<service
android:name="com.google.firebase.iid.FirebaseInstanceIdService"
android:exported="true" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
</application>
</manifest> <!-- END_INCLUDE(manifest) -->
What can be wrong with manifest?
The crash only happens when the app is installed from the Play Store and not over adb or installing the APK on the device locally - the crash is also seems to only happen on the first open.
I’ve pushed build to production (missed this crash when tested because just replaced old apk through adb on testing devices) and found lot of crashes in console
App works fine on device (ads shows), but crashes when installing.
At first sight, removing one reciver in manifest solve this issue.
Just commented it, compiled and have a smoth installing app through Android Studio without crash. Ads shows. What is it? Excess piece?
<!--<receiver
android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
android:enabled="true"
android:permission="android.permission.INSTALL_PACKAGES" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>-->
Looks like I need to add another module from google play services into the extension. Will do tomorrow. For now, commenting this piece is enough. I am not sure what benefit it provides.
EXTENSION UPDATE
Updated Google Services on Android to the latest versions. iOS without change.
AppMeasurementInstallReferrerReceiver crash should be fixed, please test, @Dragosha.
Added information on bumping up minimum sdk version.
With the latest Defold version (1.2.157) the minimum SDK version can be changed directly in the game.project
file.
Edit: Tried to create an Android bundle on the latest version on Windows but without success
Failed building Android resources to R.java: C:\Users\david\AppData\Local\Temp\bob_bundle_tmp1673622133385913881\AndroidManifest.xml:159: error: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.IAPTheme').
I get the same error
It seems like we have some difference between Windows and MacOS bundling pipeline in 1.2.157.
I added a ticket Issue-4215
(#4215)
I’ve updated res packaging in the extension. Now it builds with facebook extension on macOS. On Windows it fails with the Theme.IAPTheme res error.
Defold version: 1.2.157. Empty project, just init and extensions. Used native extensions: AdMob and Facebook. Builded on Mac
Attempting to use both extensions at the same time creates a crash:
2019-06-30 11:42:58.407 2633-2633/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dragosha.fbtest, PID: 2633
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/FacebookActivity;
at com.facebook.internal.Validate.hasFacebookActivity(Validate.java:175)
at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:198)
....
full log attached below
Final AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dragosha.fbtest"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="26" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- For GCM (push) -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:hasCode="true"
android:icon="@drawable/icon"
android:label="fbtest" >
<!-- For Local Notifications -->
<receiver android:name="com.defold.push.LocalNotificationReceiver" >
</receiver>
<!-- For Google Play Services -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<!-- Disable Firebase Analytics -->
<meta-data
android:name="firebase_analytics_collection_deactivated"
android:value="true" />
<activity
android:name="com.dynamo.android.DefoldActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="fbtest"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<meta-data
android:name="android.app.lib_name"
android:value="fbtest" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.defold.iap.IapGooglePlayActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="IAP"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
</activity>
<!-- For local and Firebase notifications -->
<activity
android:name="com.defold.push.PushDispatchActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
<intent-filter>
<action android:name="com.defold.push.FORWARD" />
<category android:name="com.defold.push" />
</intent-filter>
</activity>
<!-- For Firebase Cloud Messaging -->
<service
android:name="com.defold.push.FirebaseMessagingService"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name="com.google.firebase.messaging.FirebaseMessagingService"
android:exported="true" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name="com.google.firebase.components.ComponentDiscoveryService"
android:exported="false" >
<meta-data
android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.dragosha.fbtest" />
</intent-filter>
</receiver>
<!-- For IAC Invocations -->
<activity
android:name="com.defold.iac.IACActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.dragosha.fbtest" />
</intent-filter>
</activity>
<!-- For Amazon IAP -->
<receiver android:name="com.amazon.device.iap.ResponseReceiver" >
<intent-filter>
<action
android:name="com.amazon.inapp.purchasing.NOTIFY"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
</intent-filter>
</receiver>
<!-- ********************* firebase ********************* -->
<!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
<activity
android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
android:theme="@style/Theme.IAPTheme" />
<activity
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true"
android:exported="false" >
</receiver>
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
android:enabled="true"
android:permission="android.permission.INSTALL_PACKAGES" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false" />
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="com.dragosha.fbtest.firebaseinitprovider"
android:exported="false"
android:initOrder="100" />
<!-- Internal (not exported) receiver used by the app to start its own exported services without risk of being spoofed. -->
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
android:exported="false" />
<!-- FirebaseInstanceIdService performs security checks at runtime, no need for explicit permissions despite exported="true" -->
<service
android:name="com.google.firebase.iid.FirebaseInstanceIdService"
android:exported="true" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.facebook.sdk.ApplicationName"
android:value="fbtest" />
<activity
android:name="com.defold.facebook.FacebookActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="fbtest"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
</application>
</manifest> <!-- END_INCLUDE(manifest) -->
Test project for reproduce:
fbtest.zip (73.6 KB)
logcat.txt (24.9 KB)
works ok if used only AdMob or Fb.
The problem on Admob extension side: it excludes internal Google Play Services and replaces them with own GPS. It seems like some of jar
files wasn’t added or new GPS removed some of the deprecated methods that used in old facebook versions.
I’ve tried to add my jars in Admob NE extension instead of some Admob jar - and it works fine (it’s dirty version, I added a lot of unneeded jars, just for fast testing, pls don’t use the same set of jars in production):
I hope it helps @sergey.lerg to find the reason and fix it.
Thanks to @AGulev I noticed that Google Play Services have been updated inside Defold, so I can try the normal approach of just adding the missing parts instead of replacing everything.
But Defold fails to build the extension. @Mathias_Westerdahl @sven can you please look at it?
The new extension is on a new branch https://github.com/Lerg/extension-admob/tree/dev
Here is the full error message
warning: [options] bootstrap class path not set in conjunction with -source 1.6
I created an issue about uninformative error message when the extension jar
files have conflicts: Issue-#3182
(#3182 , old tracking number: DEF-3878
)
In this case, instead of play-services-measurement-sdk-16.5.0.jar
and play-services-measurement-sdk-api-16.5.0.jar
use com-google-android-gms-play-services-measurement-sdk-api-play-services-measurement-sdk-api-16.3.0.jar
How I found where the problem (maybe it would be useful for somebody)…
We can’t be sure, that here we have a full list of dependency because of Gradle download all dependencies. How to check them:
- Download pompom script by @britzl (Thanks!)
- From the list of includedlibraries for Android I took the main dependencies (I hope so:) ):
com.google.android.gms:play-services-base:16.0.1
andcom.google.firebase:firebase-core:16.0.7
- Download them using
pompom
:
python pompom.py --pom https://maven.google.com/com/google/android/gms/play-services-base/16.0.1/play-services-base-16.0.1.pom --out play_services poms
python pompom.py --out play_services -apv 28 deps
python pompom.py --pom https://maven.google.com/com/google/firebase/firebase-core/16.0.7/firebase-core-16.0.7.pom --out firebase poms
python pompom.py --out firebase -apv 28 deps
- Download dependency for AdMob:
python pompom.py --pom https://maven.google.com/com/google/android/gms/play-services-ads/17.2.1/play-services-ads-17.2.1.pom --out ads poms
python pompom.py --out ads -apv 28 deps
- Check what we already have in the engine (folder
firebase
andplay_services
) and what we need to add to the extension:
It looks terrible right now (it is), but for now (before we exclude GPG from the engine) it’s the one way I know, if somebody knows better, pls share with me.
EXTENSION UPDATE
Fixed conflicts with other extensions.
Now you don’t need to specify App Manifest
file in game.project
. Remove it.
At the moment, bundling for Android is not working on Windows due to resource bundling bug in Defold. It’s being worked on.