Why getting this error transformClassesWithDexForDebug while building apk? - android

While building apk I am getting this error:
Error Image
This is my gradle Image: gradle image
Note:- I started getting this error after including android-support-v4.jar to project
If anyone know this so please tell me why I am getting this error and how to solve It.

Your last line has a dependency of support-v4 using a jar file in your lib folder that you might have placed.
Either remove the file and the last line or remove the support-v4 dependency that you have highlighted.
Add the following to your project level build.gradle file if not already present
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Add the support-v4 dependency as follows to your app level build.gradle:
compile 'com.android.support:support-v4:24.2.1'
Remove the following along with the jar file:
compile files('libs/support-v4.jar')
Now your gradle will use the dependency and download the aar on it's own from the maven repository and not use the jar file that you have added.

Related

Third Party Android Library Format

I have downloaded a lot of libraries from Github. When I want to add it in android studio, there's no .jar file in every library I have. Why is it that it has no jar file ? How do I add those libraries in android studio?
Whenever possible, you should find the correct line to add to the dependencies block in your build.gradle file. For example, look at the README for the Boom Menu library which you mentioned in your comment. Under the heading Gradle & Maven, you see
compile 'com.nightonke:boommenu:2.1.0'
Add this line to the dependencies block in build.gradle, sync Android Studio, and then use the library as you wish.
libraries from GitHub... Example is the Boom Menu library
This one? ... Well, you're just not reading the documentation
Otherwise, if there isn't a BinTray dependency.
This is exactly what JitPack is for
To get a Git project into your build:
Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.User:Repo:Tag'
}
Regarding your questions
Why is it that it has no jar file ?
Because GitHub isn't meant for storing (potentially large) binaries of compiled code, and many Android libraries prefer BinTray over GitHub releases.
How do I add those libraries in android studio?
You could clone them directly into your project
app/
build.gradle
library/
build.gradle
settings.gradle
build.gradle
In settings.gradle
include :app, :library
In app/build.gradle
dependencies {
compile project(":library")
}

failed to resolve com.android.support.constraint:constraint-layout:2.0.0-alpha4

I imported a project from my work-space. After this some errors were shown which I can't solve.
The message
Install Repository and sync project
was shown as a link, but clicking on it didn't solve my problem.
Add ConstraintLayout to your project.
To use ConstraintLayout in your project, proceed as follows:
Ensure you have the "maven.google.com" repository declared in your
module-level build.gradle file:
repositories {
maven {
url 'https://maven.google.com'
}
}
Add the library as a dependency in the same build.gradle file:
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
In the toolbar or sync notification, click Sync Project with Gradle Files.
The constraintLayout is not available yet on any stable relase of Android Studio. You have to download the latest Android Studio Preview to use it.

Cannot add external library to android studio project

I am trying to add https://github.com/jkwiecien/EasyImage to my Android studio project. When i add the line:
compile 'com.github.jkwiecien:EasyImage:1.2.1'
to my app's build.gradle file, it gives me:
Error(33, 13) Failed to resolve.
Add this line to your root build.gradle
repositories {
maven { url "https://jitpack.io" }
}
https://jitpack.io/#jkwiecien/EasyImage/1.3.1
If you're using gradle, you need two steps:
1. adding jitpack repository to the root build file
2. add your dependency to the EasyImage library to the app build file.
Please try Latest one
dependencies {
compile 'com.github.jkwiecien:EasyImage:1.2.3'
}
I found this answer here: https://android-arsenal.com/details/1/2725#package

getting issues while adding other gradle project as library

actually i have been trying to import another gradle project as library from github and i know that there are two ways to do that
1)by adding url to dependencies in build.gradle file
this method gave lot of errors
2)manually download library and import it as module, then add dependencies
and i somehow succeeded by using second method ..
after that gradle sync worked correctly but while running application it gives some bizzare errors like
Error:(23, 0) Gradle DSL method not found: 'ompile()'
Possible causes:The project 'AppIntro' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
and the github link is as follows
https://github.com/PaoloRotolo/AppIntro
i imported folder called as library in that....
You can add this library in many ways:
Add a simple dependency in your build.gradle file
Just use:
dependencies {
compile 'com.github.paolorotolo:appintro:3.4.0'
}
Use the jitpack plugin
Just add this repo to your build.gradle
repositories {
// ...
maven { url "https://jitpack.io" }
}
And the dependency:
dependencies {
compile 'com.github.User:Repo:Tag'
}
download the module (the library folder) locally.

Android Studio : Failed to resolve <github dependency>

Let me first start of by saying that I just recently migrated to Android Studio and being totally honest I didn't like it. Now there is this git I am trying to import into my project - https://github.com/ongakuer/CircleIndicator
Although the compile statement which the owner has asked to put creates the error.
I added it into the dependency{} in my build.gradle file.
compile 'me.relex:circleindicator:1.1.5#aar'
Failed to resolve: me.relex:circleindicator:1.1.5#aar
You probably had forgotten this line under your gradle :
allprojects {
repositories {
jcenter()
}
}
Edit the root gradle located in root/build.gradle
I'll just explain a little :
When you add this line : compile 'repository or jar url', it prompts your gradle that it should find the repository (or the jar) and add it to your source.
But where should it search for this particular repository ? That is the purpose of this line, to declare a location from where the gradle should search from. In most of the cases it is - jcenter
(see this link)
Just open build.gradle(Module:app) and copy pase on your dependencies
dependencies {
compile 'me.relex:circleindicator:1.1.5#aar'
}

Categories

Resources