Qt - package android.support.v4.app does not exist - java

I'm using Qt 5.4. I imported SDK & NDK.
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.

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'
}
}
}
Add dependency to support-v4 library to build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:support-v4:24.+"
}

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.+"
}

Related

can I customize my existing LibGDX project with the gds-setup.jar?

I've created my game with Lib-GDX and I'm almost done! :D
the problem is that I forgot to include one of the Third Party feature in the initial GDX setup. Is there any way I can go back and include it, using the gds-setup.jar or any other way? Or must I go the super advanced way and create a new project and include the feature?
To be more precise I'm trying to include the libGDX cross platform Facebook support
You can just add your 3d party stuff to the build.gradle file for your case your need this :
compile "de.tomgrill.gdxfacebook:gdx-facebook-core:1.1.1"
to be added to the dependencies, there is no need of creating new project with gdx-setup.jar
check this topic in the officiel wiki for more info :
Dependency management with Gradle
I just created a new project with gdx-setup.jar and added the Third Party Ext. I wanted. Once that was complete i copied the code that called the TPE in the gradle files and added them to my original game's gradle so for Example:
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "de.tomgrill.gdxfacebook:gdx-facebook-android:1.1.1"//this is what I needed to add
compile fileTree(dir: 'libs', include: '*.jar')
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "de.tomgrill.gdxfacebook:gdx-facebook-core:1.1.1"//this was what I needed to add
compile fileTree(dir: 'libs', include: '*.jar')
}
}
this was all in the main project's gradle folder.

How do I include another project's class libraries in my jar using Gradle?

I am developing for Android, and I am trying to include another project's class files in my .jar file.
My build.gradle file for library project looks like this:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.3'
compile project(':xyz')
}
My build.gradle file for xyz project looks like this:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
}
The issue is that when I create another project that includes my jar library, it has unresolved references that exist in my xyz project. When I run that project, it complains about not being able to find a class that exists in the xyz project.
Right click on app , open module settings (F4), Dependencies, Green + and select library file. build.gradle is updated automatically :)

Building shadow jar with gradle locally

I am using shadow plugin in gradle to build jar file, I have added the build script as follows
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.2'
}
}
Instead of asking gradle to fetch shadow-1.2.2.jar from jcenter(), I want to get the shadow-1.2.2.jar from http://jcenter.bintray.com/com/github/jengelman/gradle/plugins/shadow/1.2.2/
I just want to build it locally, I have put the shadow-1.2.2.jar in libs folder and my build script is
buildscript {
//repositories { jcenter() }
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.2'
}
}
But it not working please help!
The following piece of code should work:
buildscript {
dependencies {
classpath fileTree(dir: 'libs', include: '*.jar')
}
}
There's no compile configuration for gradle buildscript dependencies.

Cannot resolve symbol in Android

I am working on integrating twitter with my android application, I am using twitter4j library to do this.
I have added the twitter4j library files and put it in a folder libs and added compile dependency in build.gradle inside app folder
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:6.5.+'
compile 'org.twitter4j:twitter4j-core:4.0.2'
}
but I am still not able to use this library
In the Gradle drawer to the right, could you hit the refresh button to see if that helps? Also, the dependencies block that you've pasted above doesn't contain a directive for twitter4j - did you happen to simply miss it out in the question, or is it really missing from the gradle.build file?
Try to add this at "repositories" on your buildscript.
repositories { mavenCentral() }

How do I include dependencies in my android library

I am writing an android sdk and I now want to distribute it but I am having problems with its dependencies. I am using gradle and android studio.
My sdk has a dependency on volley and gson and I have them added as jars with in my sdk. When ever I try to create an aar or a jar to use within a separate client app I always get a crash when ever my sdk tries to reference volley as it wasnt included in either the aar or jar.
Any ideas on how I should be doing this? I have looked into creating fat jars with out much success.
I have also tried using remote dependencies like below but even after a gradle build in the client app both volley and gson are still not included.
This is currently what I have in my sdk build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.code.gson:gson:2.3'
}
then with in the client build gradle I have
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name:'mysdk-1.0.0', ext:'aar')
}
I am using ./gradlew clean build to build the aar and jar of my sdk
Can anyone tell me the correct way to include dependencies in my own lib?
If you wish to include the transitive dependencies of your library in your client app, you'll need to create a proper maven compatible package that contains a pom.xml. This pom will describe the dependencies of your lib, so that client can pull those deps transitively when they include your lib.
See this tutorial: http://blog.blundell-apps.com/locally-release-an-android-library-for-jcenter-or-maven-central-inclusion/
You don't have to upload the artifact anywhere during development, just use your local maven repo as a target, and have mavenLocal() as a repository for your client app.
This way, you'll be able to refer to your lib as a standard maven dependency using
compile 'com.mysdk:mysdk:1.0.0'
In your client, change your dependencies block like so:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name:'mysdk-1.0.0', ext:'aar') {
transitive = true
}
}
This should pull in your transitive dependencies as well.

Categories