8

I'm using Qt 5.4. I imported SDK & NDK.

enter image description here

Actually, I was trying to use multiple line notification and I used this line in java file:

customMainActivity.java:

   import android.support.v4.app.NotificationCompat;
   NotificationCompat.Builder builder = new NotificationCompat.Builder(
                        context);

I'm getting an error : package android.support.v4.app does not exist
I read it and it and added android-support-v4.jar and android-support-v7-appcompat.jar but I don't know how to fix it in Qt.

Farzan Najipour
  • 2,442
  • 7
  • 42
  • 81

2 Answers2

4
  1. Add Google's Maven repository to build.gradle https://developer.android.com/studio/build/dependencies#google-maven

    allprojects {
        repositories {
            jcenter()
            maven {
                url 'https://maven.google.com'
            }
        }
    }
    
  2. Add dependency to support-v4 library to build.gradle

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar']) 
        compile "com.android.support:support-v4:24.+" 
    }
    
Libor B.
  • 519
  • 5
  • 9
  • 1
    I post this comment in case someone like me will be in the same situation. I come from Android native world and I was looking for the build.gradle file that is located at the "app" level to add the dependency, but it seems that in Qt there is only one build.gradle file, at the project level (at least in my case). In the end I added the dependency directly in the project level build.gradle file and it works just fine ;) – Laura Jul 16 '19 at 14:56
3

You need to add the dependency to your build.gradle file (it's created and added to your project when you create android manifest via Create Templates button). Something like this:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:support-v4:23.0.+"
}
Alexander Dyagilev
  • 1,139
  • 1
  • 15
  • 43
  • It doesn't help for me: Could not find any matches for com.android.support:support-v4:23.0.+ as no versions of com.android.support:support-v4 are available. – Libor B. Dec 11 '18 at 07:43
  • how can i update build.gradle? it exists in the build folder but a remark there says: **This file is updated by QtCreator and androiddeployqt tools. Changing them manually might break the compilation!** – Lior May 20 '19 at 09:09
  • Read carefully. This note is for the gradle.properties file. – Alexander Dyagilev May 20 '19 at 18:32
  • thanks! actually i see that it is for build.gradle, but on any case, these files are located in the build folder. this folder is created by the qt creator automatically, so i dont want to change anything there. any ideas? thanks!! – Lior May 23 '19 at 08:55
  • I don't know why your build.gradle is in the build directory. Qt Creator created mine in the source directory in `android` subfolder inside project's dir. Probably it's just copied from source folder and modified while building. You need to locate your file inside source. For this you need to create android manifest first (using Qt Creator). Use "Create Templates" button for this. – Alexander Dyagilev May 23 '19 at 14:39