Adding itextg to gradle - android

I want to add itextg via gradle to avoid having to maintain a set of library jars. Maybe it's me but I can't find the correct gradle compile statement anywhere.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.itextg:itextg:5.4.3'
}
Regular itext works just fine but I'm trying to do stuff with images.
compile 'com.itextpdf:itextpdf-5.5.6'

I think that's because we released iText as a jar on Maven Central (which Gradle also uses as a repository) and also as a download from various sites (GitHub, SourceForge); but iTextG only as a download on various sites, not on Maven Central. iTextG uses the same namespace as iText: com.itextpdf:itextpdf so having it on Maven Central too would create conflicts. Something like com.itextg:itextg simply does not exist (as far as I know - and I am supposed to know because I am QA Engineer at iText Software).
In fact, the main difference between iText and iTextG, is that we have stripped all AWT dependencies from iTextG. For the rest they are exactly the same codebase.
So, to finally answer your question after all this background information: you'll have to download the iTextG jar and manually add it to your libs folder.
As of iText 5.5.9, you can add this to your Gradle file:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.itextpdf:itextg:5.5.9'
}

Related

Android studio 3.0 error, how can I get rid of it?

I just update my android studio to 3.0 now, but when I try to build apk on my project, it's shows following error:
Project depends on com.google.android.support:wearable:2.0.0, so it must also depend (as a provided dependency) on com.google.android.wearable:wearable:2.0.0
My build.gradle is like that:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':lpd')
compile 'com.google.android.support:wearable:2.0.0-alpha2'
compile 'com.google.android.gms:play-services-wearable:9.4.0'
compile files('libs/zxing_2.3.0.jar')
compile(name: 'hwwearableservice-release', ext: 'aar')
compile 'com.google.android.gms:play-services-appindexing:9.4.0'
}
Anything wrong with it?
As per the new gradle dependency instruction the compile has been deprecated so for libraries use api and use the latest stable lib version as 2.1.0
and since the version is a stable release so
api 'com.google.android.support:wearable:2.1.0'
or it's better to use
implementation 'com.google.android.support:wearable:2.1.0'
implementation
if an implementation dependency changes its API, Gradle recompiles
only that dependency and the modules that directly depend on it. Most
app and test modules should use this configuration.
api
When a module includes an api dependency, it's letting Gradle know
that the module wants to transitively export that dependency to other
modules, so that it's available to them at both runtime and compile
time. This configuration behaves just like compile (which is now
deprecated), and you should typically use this only in library
modules. That's because, if an api dependency changes its external
API, Gradle recompiles all modules that have access to that dependency
at compile time

Android Firebase Email and password authentication does not work

I am trying to create accounts in an Android app using Firebase. When I add the following dependencies in the app build.grade file -
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.firebaseui:firebase-ui:1.0.1'
compile 'com.google.firebase:firebase-auth:10.0.0'//added also tried 10.0.1
testCompile 'junit:junit:4.12'
}
I get the following cryptic build error (btw I'm not using any Twitter SDKs or anything to the best of my knowledge):
Error:Failed to resolve: com.twitter.sdk.android:twitter:2.2.0
When I change the dependecies to:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.firebaseui:firebase-ui:0.6.2'//changed
compile 'com.google.firebase:firebase-auth:9.8.0'//changed
testCompile 'junit:junit:4.12'
}
the app build and compiles fine, but when I try to create the account, I get the following error:
Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/
I am at a loss as to what I should do because I think I'm using the latest version of the Firebase SDK.
Some more information is that I have used both mFirebaseRef.createUser() and mAuth.createUserWithEmailAndPassword with no success.
I used this link to change the dependencies.
Any help will be deeply appreciated.
You are mixing the legacy SDK:
compile 'com.firebase:firebase-client-android:2.5.2'
with the new SDK:
compile 'com.google.firebase:firebase-auth:10.0.0'
This will cause a number of problems and is the reason for this error message:
Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/
For new development, you should use only the new SDK. Delete this line from your dependencies:
compile 'com.firebase:firebase-client-android:2.5.2'
The latest versions of FirebaseAuth require additional repositories. Make this change to your project (top-level) build.gradle file:
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
mavenLocal()
}
}
The change is excerpted from the Firebase Sample project. It will eliminate this error:
Error:Failed to resolve: com.twitter.sdk.android:twitter:2.2.0
you should use the correct firebase authentication version from Google:
compile 'com.google.firebase:firebase-auth:10.0.1'
And you have to setup Firebase as it is described in the official documentation

Resolve Gradle Dependency into local JAR in Android Studio

Currently, my Android app project compiles against a local library project like so:
// build.gradle
dependencies {
compile project(':Library-Project')
compile files('libs/library.jar') // Resolve into this if Library-Project is not available
}
The local library project builds into library.jar and is placed in the libs folder.
Is there a way to fallback on the library.jar artifact if the local project is not present without commenting compile project(':Library-Project') in lieu of compiling against the jar?
Used a more dynamic approach for which dependency should actually get compiled.
dependencies {
// Check if the local project exists, and compile against that if it does
if ( new File("/Library-Project").exists() )
{
compile project(':Library-Project')
}
// Local project DNE, compile against JAR file
else
{
compile files('libs/library.jar')
}
}
Another way to automatically compile all JAR files in the /libs folder is by adding the following line within your dependencies block:
compile fileTree(include: ['*.jar'], dir: 'libs')

error: package com.facebook.android does not exist in android studio project

I am new to android studio.I am developing an app which uses Facebook SDK.I have downloaded Facebbok SDK and imported it as a module to my android project.I am using latest version of android studio.So I simply imported it and did not make any change in other files for this.First I am trying to use facebook login functionality.But when I build the app I am getting following error.
error: package com.facebook.android does not exist
I could see one solution as an answer to someone's question. But i could not understand it.Please somebody help me.
check you build.gradle
it should got this dependency
if you got library project:
dependencies {
compile project(':facebook');
}
if you got jar files in libs folder:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
}
or just add maven central dependency to:
dependencies {
compile 'com.github.asne.facebook:facebook:3.17.2'
}
You need to add dependencies on your gradle file :-
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
above is path you need to add dependencies {} like below :-
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
Is the facebook library is jar file or library project?
If is jar file, you just need to add jar file in libs folder and dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
} in build.gradle.
If is library project, you should modify your setting.gradle and build.gradle files.
Adding this line of code to the dependencies in the build.gradle file helped me get rid of the same error.
dependencies {
...
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
}
From platform=android facebook developers
-the last line of the section "Add Facebook SDK to Your Project")

Android Ormlite: java.lang.NoClassDefFoundError

I am using ormlite in an Android project from Android Studio. I have configured Gradle to use it from Maven, like so:
dependencies {
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
However, when I launch the app it's giving NoClassDefFoundError for all ormlite classes. The same works if it is done by copying the jars to "libs/" folder.
Any idea why adding them from Maven doesn't work?
Try this on build.gradle:
dependencies {
compile 'com.j256.ormlite:ormlite-android:4.48'
...
}
The ormlite-core is a dependency that gradle will resolve by it's self. After editing, sync and rebuild you app, it should work.
If you want to put jar files in you libs folder, than your dependecies line from build.gradle will look like this:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
...
}

Categories

Resources