I have to integrate the flurry ad in my android application. Can anybody provide the steps to integrate the flurry ad. I have gone through official sdk for flurry but not get any idea. I have followed the link android: Flurry Ads Banner taking Full screen
I have used the code not get any results
FlurryAgent.onStartSession(this, getString(R.string.flurry_api_key));
FlurryAds.fetchAd(this, "ANDROID_BANNER_TOP", mBanner,
FlurryAdSize.BANNER_TOP);
Prerequisites
Flurry Analytics requires a minimum Android API level 10.
Flurry Analytics uses the Android Advertising ID provided by Google Play Services and will check for and respect the user’s ad tracking preference.
Get your API Keys
Start by creating an app. Once you create the app, you’ll receive a Flurry API Key, which you’ll need when using the SDK.
Download the Flurry Android SDK
There are currently two ways of getting the Flurry Android SDK into your application:
Install via jCenter (Recommended):
The Flurry SDK is available via jCenter. You can add it to your application by including the following in your build.gradle file:
// In your top level Gradle config file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
// In your main app's Gradle config file:
dependencies {
compile 'com.flurry.android:analytics:6.3.1'
/*
* Optional library to help in monetizing your app with ads.
* If you include the ads library, you do not need to include
* the analytics library as it is a transitive dependency.
*/
// compile 'com.flurry.android:ads:6.3.1'
//... other dependencies
}
Download .jar files from Flurry Dev Portal
The downloaded archive should contain these files for use with Flurry Analytics:
FlurryAnalytics_x.y.z.jar: The library containing Flurry’s analytic collection and reporting code (where x.y.x denotes the latest version of Flurry SDK).
FlurryAds_x.y.z.jar: The optional library to incorporate Flurry’s ads into your application (where x.y.x denotes the latest version of Flurry SDK).
ProjectApiKey.txt: This file contains the name of your project and your project’s API key.
FlurryAndroidAnalyticsReadmevx.y.z.pdf: A PDF file with instructions (where x.y.x denotes the latest version of Flurry SDK).
Add the FlurryAnalytics_x.y.z.jar to your classpath¶
Using Android Studio:
If using Android Studio, you do not need to do anything further to include the Flurry SDK in your project, as long as you have installed the SDK through jCenter in your Gradle configuration.
However, if you prefer to use the downloaded .jar files, follow these procedures:
Add FlurryAnalytics-5.x.x.jar to your project’s libs folder.
Navigate to File > Project Structure > Module > Dependencies. Click the ‘+’ button in the bottom of the ‘Project Structure’ popup to add dependencies. Select ‘File dependency’ and add libs/FlurryAnalytics-5.x.x.jar.
Add Google Play Services library. If selectively compiling individual Google Play Service APIs, you should include the Google Analytics API.
Using Eclipse
Add FlurryAnalytics-5.x.x.jar to your project’s libs folder. Right-click on each JAR file and select Build Path > Add to Build Path.
Add the Google Play Service library jar file.
Configure your AndroidManifest.xml
- Have access to the Internet and allow the Flurry SDK to check state of the network connectivity.
- Specify a versionName attribute in the manifest to have data reported under that version name.
- Declare min version of that Android OS that the app supports. Flurry supports Android OS versions 10 and above.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.flurry.sample"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="21" />
<!--required permission-->
<uses-permission android:name="android.permission.INTERNET" />
<!--optional permission - highly recommended-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!--optional permission -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name=".MyApplication"
android:icon="#drawable/app_icon">
<!--your activities -->
</application>
</manifest>
Add calls to init, onStartSession and onEndSession
Follow these steps, adding these calls:
If you are shipping an app, insert a call to FlurryAgent.init(Context, String) in your Application class, passing it a reference to your application Context and your project’s API key:
//If you are shipping an app, extend the Application class if you are not already doing so:
public class MyApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
new FlurryAgent.Builder()
.withLogEnabled(false)
.build(this, FLURRY_API_KEY);
}
}
Alternatively, you may call init() just before onStartSession(). It is safe to call init() more than once, provided that you use the same API key throughout the application. You may use any type of Context you wish.
If you are writing an app and the minimum target is Ice Cream Sandwich or above (minSdkVersion is set to API level 14 or greater), session handling is completely automatic, and you may skip steps 3 and 4. If you are instrumenting another type of Context, such as a Service, or your minimum target is Gingerbread, proceed with steps 3 or 4.
Insert a call to FlurryAgent.onStartSession(Context) in the Activity’s onStart() method, passing it a reference to a Context object (such as an Activity or Service). If you are targeting Gingerbread, Flurry recommends using the onStart() method of each Activity in your app, and passing the Activity itself as the Context object. For services (or other Contexts), use the Service or the relevant Context as the Context object. Do not pass in the global Application context.
Insert a call to FlurryAgent.onEndSession(Context) in the Activity’s onStop() method, when a session is complete. If you are targeting Gingerbread, we recommend using the onStop method of each Activity in your app. For services (or other Contexts), ensure that onStop is called in each instrumented Service. Make sure to match up a call to onEndSession for each call of onStartSession, passing in the same Context object that was used to call onStartSession. Do not pass in the global Application context.
As long as there is any Context that has called onStartSession() but not onEndSession(), the session will be continued. Also, if a new Context calls onStartSession() within 10 seconds of the last Context calling onEndSession(), then the session will be resumed, instead of a new session being created. Session length, usage frequency, events and errors will continue to be tracked as part of the same session. This ensures that as a user transitions from one Activity to another in your app that they will not have a separate session tracked for each Activity, but will have a single session that spans many activities. If you want to track Activity usage, Flurry recommends using logEvent(), as described in the Custom Events section.
If you wish to change the window during which a session can be resumed, call FlurryAgent.setContinueSessionMillis(long milliseconds) before the call to FlurryAgent.init().
The Flurry SDK automatically transfers the data captured during the session once the SDK determines the session completed. In case the device is not connected, the data is saved on the device and transferred once the device is connected again. The SDK manages the entire process. Currently, there is no way for the app to schedule the data transfer.
You’re done! That’s all you need to do to begin receiving basic metric
data.
Related
App has ML Kit functionality (translation). I'm trying to reduce the app size by introducing a dynamic module feature, on demand loading.
Following this guide
Added 'com.google.mlkit:playstore-dynamic-feature-support:16.0.0-beta1' to base apk's build.gradle
com.google.mlkit:translate:16.1.2 in feature module build.gradle,
everything compiles and tries to run on emulator, but unfortunately crashes on app start with log
java.lang.RuntimeException: Unable to get provider com.google.mlkit.common.internal.MlKitInitProvider: com.google.firebase.components.MissingDependencyException: Unsatisfied dependency for component Component<[class com.google.android.gms.internal.mlkit_translate.zzxa]>{0, type=0, deps=[Dependency{anInterface=class com.google.mlkit.common.sdkinternal.SharedPrefManager, type=required, injection=direct}, Dependency{anInterface=class com.google.android.gms.internal.mlkit_translate.zzwx, type=required, injection=direct}]}: class com.google.mlkit.common.sdkinternal.SharedPrefManager
Caused by: com.google.firebase.components.MissingDependencyException: Unsatisfied dependency for component Component<[class com.google.android.gms.internal.mlkit_translate.zzxa]>{0, type=0, deps=[Dependency{anInterface=class com.google.mlkit.common.sdkinternal.SharedPrefManager, type=required, injection=direct}, Dependency{anInterface=class com.google.android.gms.internal.mlkit_translate.zzwx, type=required, injection=direct}]}: class com.google.mlkit.common.sdkinternal.SharedPrefManager
Which kind of does not make sense. Because I've added playstore-dynamic-feature-support.
Figured it out,
Step 1. disable MlKitInitProvider in app module (stops app crash)
<provider
android:name="com.google.mlkit.common.internal.MlKitInitProvider"
android:authorities="${applicationId}.mlkitinitprovider"
tools:node="remove"
/>
Step 2.
build apk and open the app manifest, find all MLKit Registrars used in your app.
Step 3.
add all found to a ComponentRegistrar array ArrayList;
Step 4.
In the dynamic feature library, call MlKitContext.initialize(context, arr); (in getProvider the service provider) prior to using mlkit functionality;
Also, only using these mlkit dependencies in app module (for split install)
api group: 'com.google.mlkit', name: 'common', version: '17.5.0'
api group: 'com.google.mlkit', name: 'playstore-dynamic-feature-support', version: '16.0.0-beta1'
If someone is still not able to figure out using #Shane Gallagher's answer I am detailing out the steps:
First as mentioned add Provider in app module to disable MlKit initialization:
<provider
android:name="com.google.mlkit.common.internal.MlKitInitProvider"
android:authorities="${applicationId}.mlkitinitprovider"
tools:node="remove"/>
Next build apk and open your merged manifest. Find all the component registrars used in your app. You can open merged manifest by clicking on merged manifest text in bottom left corner of Android Studio after opening AndroidManifest.xml
Next in your dynamic feature module add the following code as per the registrars used in your app
val registrars = listOf(CommonComponentRegistrar(), VisionCommonRegistrar(), BarcodeRegistrar())
MlKitContext.initialize(this, registrars)
To set up your dynamic module, you will need to move the mlkit translate dependency from the base app's gradle file to the dynamic module's gradle build file. You will also need to move all related usage to the dynamic module. Therefore, when app start up, it won't look for any mlkit translate dependency. Please refer to the play store on demand delivery guide for step to step set up guidance.
I have received email from google:
We recently announced that we’ll be deprecating the install_referrer intent broadcast mechanism. Because one or more of your apps uses this intent to track referrals, we wanted to ensure you make the switch before March 1, 2020. After this date, new versions of the Play Store app will no longer broadcast the install_referrer intent after app installs.
I am not using install_referrer directly, but while browsing merged manifest i discovered that some firebase service named with package name com.google.firebase.measurement use it.
My firebase dependencies updated to latest version.
Should I care about it?
From Firebase support:
This is a great catch. Thanks for bringing this to our attention.
There's no need [to take] action from your end as of now, I've created an
internal request so we could provide an alternative for the
install_referrer intent broadcast before its deprecation. As of now,
we are yet to find out any details or timelines as to when it will be
implemented. You can check our release notes from time to time for any
updates about Firebase features and its services.
Strange that Google's products are not synchronized.
However if you are not using Firebase and your app contains third party libraries that use install_referrer kindly check directly with them.
To find in which library install_referrer included, open merged manifest and search for install_referrer, check the package name of the service in which the install_referrer included.
com.google.firebase:firebase-core:17.2.1 and com.google.firebase:firebase-analytics:17.2.1 add INSTALL_REFERRER to AndroidManifest. Probably need to wait till Firebase team updates these packages to use the new API.
Various SDKs can register a receiver for the install referrer.
For developers who are unsure about which SDK added a receiver to your manifest it's useful to look at the manifest merge blame file.
Typically, in build/ there's a file intermediates/manifest_merge_blame_file/release/manifest-merger-blame-release-report.txt
In that file you'll need to find receivers that have
<action android:name="com.android.vending.INSTALL_REFERRER" />
in it's intent-filter, and the line before it will indicate what the source of that line is in your manifest.
For instance, the relevant lines for one of my apps looks like this:
44 <receiver
44-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:29:9-35:20
45 android:name="com.appbrain.ReferrerReceiver"
45-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:30:13-57
46 android:exported="true" >
46-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:31:13-36
47 <intent-filter>
47-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:32:13-34:29
48 <action android:name="com.android.vending.INSTALL_REFERRER" />
48-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:33:17-79
48-->[com.appbrain:appbrain-sdk:15.10] .../jetified-appbrain-sdk-15.10/AndroidManifest.xml:33:25-76
49 </intent-filter>
50 </receiver>
This shows that the AppBrain SDK (of which I'm one of the developers) adds a receiver for the install referrer. The following image from our blogpost explaining what exactly changes (https://medium.com/appbrain/the-google-play-referrer-api-and-the-appbrain-sdk-38cfbaa350dc) is clarifying what Google is changing:
After checking the manifest file on my builded apk, i found the install refeer broadcast used by the firebase-measurement-connector module on Firebase Core Analytics so i exclude them :
implementation ('com.google.firebase:firebase-ads:17.2.0')
{
exclude group: 'com.google.firebase', module: 'firebase-core'
exclude group: 'com.google.firebase', module: 'firebase-analytics'
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
}
And then recheck again my manifest mereged file by Analyzing APk and the Install refeer broadcast is disappeared.
On other side, if you use track analytics, Google ask to switch to the Install Referrer API https://developer.android.com/google/play/installreferrer/library.html before March 2020
I checked Firebase support agent for this issue. Firebase libraries are using install_referrer, and I got below response from Firebase support agent:
This is a great catch. Thanks for bringing this to our attention. I'm
currently in discussion with our Analytics experts and will get back
within 48 hours, or as soon as I have more information. For now, no
need for any action from your end, wait for the next update from the
Firebase team.
I believe we need to wait Firebase's next release. And Firebase team updates these packages to use the new API.
If you have used this API in your code by yourself, then you need to change it immediately as you are not depending on firebase or any other third party library provider.
There is one article on Android developer blog about this
https://android-developers.googleblog.com/2019/11/still-using-installbroadcast-switch-to.html
Also in this article they mention old implementation of install_referrer intent broadcast mechanism and provide complete information. So we can find this in our existing code.
https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#google-play-campaigns
INSTALL_REFERRER comes not only with Firebase but also withADMOB. I can confirm that Admob v3.18.3 has this permission but it is no longer coming in Admob v4.2.1. I have not tested other versions but i have heard that some previous versions like 4.2.0 & 4.1.0 also not carrying this permission.
But the question here is whether we need to remove the permission or we need to make sure that if our app is using Play Install Referrer Library then the INSTALL_REFERRER must be included. Because action required is not to remove it but migrate to it.
I am trying to integrate google_maps_flutter into an existing project.
The maps component works only when running directly the "my_flutter" project on the device (the same code).
When I try to run the flutter module from an existing app, the maps component is empty and no logs are available (or usable).
(Flutter doctor does not output any errors).
I've followed the steps for both the my_flutter/.iOS and my_flutter/.android projects and I also followed them for the projects that integrate my_flutter.
Source:
Android
Specify your API key in the application manifest
android/app/src/main/AndroidManifest.xml:
<manifest ...
<application ...
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="YOUR KEY HERE"/>
iOS
Specify your API key in the application delegate ios/Runner/AppDelegate.m:
include "AppDelegate.h"
include "GeneratedPluginRegistrant.h"
import "GoogleMaps/GoogleMaps.h"
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GMSServices provideAPIKey:#"YOUR KEY HERE"];
[GeneratedPluginRegistrant registerWithRegistry:self];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
#End
Opt-in to the embedded views preview by adding a boolean property to
the app's Info.plist file with the key
io.flutter.embedded_views_preview and the value YES.
I suspect that I what I am trying is not possible yet with the current version on the library and it may come as a new feature when the library is not in "developer preview".
Found that I had to:
GeneratedPluginRegistrant.register(with: flutterViewController.pluginRegistry());
Did you set a latitude and longitude in the Google Maps param?
If you're setting your API key and doing what it said, it should work fine
To be clear on what i am asking i will provide a real world example. take look at this and notice the following section:
Hotline - Android SDK Integration Steps Modified on: Fri, 6 Oct, 2017 at 8:21 PM
Integrate Hotline SDK (Using Gradle) Pre Requisites :
Hotline SDK clients require devices running Android 2.3 or higher
Hotline App Id and App Key from here: Where to find App ID and App Key
Android Studio and Gradle
If you have any queries during the integration, please send it to us - Submit a Query
1. Add Hotline SDK to your app
Add the maven URL to the root build.gradle (project/build.gradle)
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
Add the following dependency to your app module's build.gradle file
(project/app/build.gradle):
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.github.freshdesk:hotline-android:1.2.+'
}
1.1 Android target version supported
Hotline SDK supports apps targeting Android version 5.0+. The SDK
itself is compatible all the way down to Gingerbread (API Level 10).
When app targets Android 7.0+
When FileProvider is not configured for Hotline SDK, the following
error code is displayed
"Missing/Bad FileProvider for Hotline. Camera capture will fail in devices running Nougat or later versions of OS (error code 354)"
To fix this, please include the provider in the
AndroidManifest.xml as below and specify the authority in strings.xml.
Assuming, com.example.demoapp is the package name of your app, the
declaration would be
AndroidManifest.xml
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.demoapp.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/hotline_file_provider_paths" />
</provider>
Strings.xml
<string name="hotline_file_provider_authority">com.example.demoapp.provider</string>
When app targets Android 8.0+
When the app's target is Android 8.0 or later, and by extension includes appcompat-v7 r26.0.0.+, you'll see the following errors
E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/freshdesk/hotline/activity/InterstitialActivity;
Hotline SDK's activities extends ActionBarActivity to keep the SDK
compatible with app's targeting older Android versions/appcompat-v7
revisions. It can be resolved by adding a proxy class
(ActionBarActivity was replaced by AppCompatActivity and was proxied
by lib itself since 24.2.0 of appcomapt-v7, until it was removed in
26.0.0) manually if you are building with support library 26.x.x.
Add the following class in the appropriate package
package android.support.v7.app;
public class ActionBarActivity extends AppCompatActivity {
}
my question has nothing to do with Hotline. But after i did what they asked my package structure looks like this:
now that you have some background let me tell you what i dont understand. Does this mean that i am overriding any calls in package android.support.v7.app.ActionBarActivity ? so does this mean that for any 3rd party build i have i can override its classes this way as long as i know the package and class name ?
Basically what does it mean to put package name of something i do not own into my package structure ? what does it do ?
UPDATE: look at this article here as another example . if you read solution 3 you see we can do the same thing with facebook.login. i personally implemented this and it works. my test package structure looks like this and it overrides facebooks loginCreator etc:
even though i implemented it, i still dont get whats happening. can someone explain ?
We integrated libGoogleAnalyticsServices.jar in our app and it is working fine. By default it includes 'VERSION_CODE' from BuildConfig.java when sending messages to Google Analytics service. I'd like to include 'VERSION_NAME' instead of 'VERSION_CODE'.
1. Is there a way to get a project for libGoogleAnalyticsServices.jar?
2. Is there a way to configure libGoogleAnalyticsServices class to send version_name instead of version_code?