Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Implement Google Analytics for Android in Qt
Forum Updated to NodeBB v4.3 + New Features

Implement Google Analytics for Android in Qt

Scheduled Pinned Locked Moved Solved Mobile and Embedded
googleanalyticsandroid
2 Posts 1 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Attila
    wrote on 11 Apr 2016, 16:16 last edited by
    #1

    I'm trying to implement Google Analytics for Android into the native Android part of a Qt project. I'm following these instructions for Google Analytics v4.

    The instructions talk about editing the project-level and the app-level build.gradle files. My first problem is here - there is only an app-level build.gradle that I can edit in Qt. I tried anyway and put all the lines into that build.gradle file (I have to admit I had little idea of what I was doing then).

    I also generated the necessary configuration file (google-services.json), and put it into the root folder of the exported Android files.

    I also set the gradle version in gradle-wrapper.properties to gradle-2.10.

    Now when I compile, I get this error:

    Dex: Error converting bytecode to dex:
    Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
        UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
    (...)
    

    The app used to work properly so far. I'm using Qt 5.6.
    Have you had any experiences with implementing Google Analytics v4 or this issue?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Attila
      wrote on 12 Apr 2016, 13:38 last edited by
      #2

      Managed to solve this.
      The problem was that android-support-v4.jar was in the libs folder, and it was also listed as a dependency in the build.gradle, thus creating a conflict.
      Deleting the .jar file solved this error.

      Google Analytics is working now. My build.gradle looks like this:

      buildscript {
          repositories {
              jcenter()
          }
      
          dependencies {
              classpath 'com.android.tools.build:gradle:1.5.0'
              classpath 'com.google.gms:google-services:2.0.0-beta6'
          }
      }
      
      allprojects {
          repositories {
              jcenter()
          }
      }
      
      apply plugin: 'com.android.application'
      
      dependencies {
          compile fileTree(dir: 'libs', include: ['*.jar'])
          compile 'com.android.support:appcompat-v7:23.2.0'
          compile 'com.android.support:support-v4:23.2.0'
      
          compile 'com.google.android.gms:play-services-analytics:8.4.0'
      }
      
      android {
          /*******************************************************
           * The following variables:
           * - androidBuildToolsVersion,
           * - androidCompileSdkVersion
           * - qt5AndroidDir - holds the path to qt android files
           *                   needed to build any Qt application
           *                   on Android.
           *
           * are defined in gradle.properties file. This file is
           * updated by QtCreator and androiddeployqt tools.
           * Changing them manually might break the compilation!
           *******************************************************/
      
          compileSdkVersion androidCompileSdkVersion.toInteger()
      
          buildToolsVersion androidBuildToolsVersion
      
          sourceSets {
              main {
                  manifest.srcFile 'AndroidManifest.xml'
                  java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
                  aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
                  res.srcDirs = [qt5AndroidDir + '/res', 'res']
                  resources.srcDirs = ['src']
                  renderscript.srcDirs = ['src']
                  assets.srcDirs = ['assets']
                  jniLibs.srcDirs = ['libs']
             }
          }
      
          lintOptions {
              abortOnError false
          }
      }
      
      apply plugin: 'com.google.gms.google-services'
      
      1 Reply Last reply
      1

      1/2

      11 Apr 2016, 16:16

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved