Skip to content

Howto integrate to project

Vitaliy Petrov edited this page Apr 10, 2016 · 11 revisions

Add submodule to your project

    - mkdir $$PROJECT_ROOT/mobile
    - cd $$PROJECT_ROOT/mobile
    - git submodule add https://github.com/kafeg/adctl.git
    - git submodule update --init --recursive

And manual add Play Games C++ SDK Version 2.1 from https://developers.google.com/games/services/downloads/sdks to adctl/3rd/gpg-cpp-sdk

Move your 'android' folder to $$PROJECT_ROOT/mobile/android (for example).

Include .pri in your project

    #AdCtl: Google Analytics, AdMob, StartAD.mobi
    ANDROID_PACKAGE_SOURCE_DIR = $$PWD/mobile/android
    include(mobile/adctl/AdCtl.pri)
    android {
      OTHER_FILES += \
        $$PWD/mobile/android/AndroidManifest.xml
    }

Include in your AndroidMainifest.xml some lines

As described at this https://github.com/yevgeniy-logachev/QtAdMob or https://raw.githubusercontent.com/yevgeniy-logachev/QtAdMob/master/AndroidManifest.png)

At first string inside 'application' tag:
<!--This meta-data tag is required to use Google Play Services and AdMob.-->
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id"/>

In main activity:

<activity android:configChanges="..." android:name="ru.forsk.AdCtl.AdCtlActivity" android:label="..." android:screenOrientation="portrait" android:launchMode="singleTop">

After first activity:

        <!--Include the AdActivity configChanges and theme. -->
        <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" android:label="Тёмные истории">
            <meta-data android:name="android.app.lib_name" android:value="darkstories"/>
        </activity>

Before < / manifest >:

        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

That's all!

Gradle/And dependencies

As described here https://github.com/yevgeniy-logachev/QtAdMob add dependencies to your Gradle or Ant files.

Gradle. Make sure that you have installed Google Repository, Google Play services and Android Support Repository in android sdk. Add dependencies in build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services-ads:+'
    compile "com.android.support:support-v4:18.0.+"
}

Ant. Copy google-play-services_lib/ folders from android-sdk/extras/google/google_play_services/libproject/ directory to your AndroidManifest.xml location

Create project.properties file if not exists in your AndroidManifest.xml location and add to end of it:

android.library.reference.1=./google-play-services_lib/

Note: If you use Game Services, you must specify files:

android/res/values/gamehelper_strings.xml
android/res/values/games-ids.xml

Howto using library

By default all library features are disabled. You must enable features you want to use. Please read more in: