I am developing an android app with Android Studio 0.8.9. I am using Gradle to build my project.
I want to include google-play-services.jar file into my project in order to use push notification api.
I have added those statements into my gradle (application layer) file as follows:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/google-play-services.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/gson-2.2.3.jar')
compile files('libs/volley_23042014.jar')
compile 'com.google.android.gms:play-services:5.2.08'
}
but it never works. I get the following error:
Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
I've checked bunch of websites (including Stackoverflow.com). None of them has worked for me.
I have latest versions of Google Support Library, Google Support Repository, Google Play Services.
Here is my libs directory
My SDK version like:
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="20" />
What I have done wrong? If anyone has any idea please let me know.
If you're including Play Services via:
compile 'com.google.android.gms:play-services:5.2.08'
you don't need this:
compile files('libs/google-play-services.jar')
so just remove it.
Since the first line of your dependencies will make it automatically pick up any jar files you put in your libs directory:
compile fileTree(dir: 'libs', include: ['*.jar'])
make sure you remove the jars from there as well.
For that matter, there are other libraries you shouldn't include via specific jars.
Instead of this:
compile files('libs/android-support-v4.jar')
compile files('libs/gson-2.2.3.jar')
use this:
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.code.gson:gson:2.2.3
(Note that later versions of GSON are available).
Related
In android M, android support jack, and I compile the library and it is 3d.jack instead of 3d.jar.
My question is how to add 3d.jack as the library to build my app which depends on the library of 3d.
I know how to add a lib if the lib is 3d.jar. But I try to use same way, copy 3d.jack into libs folder, and change to *.jack, it doesn't work.
So anyone knows how to do it?
dependencies {
compile fileTree(dir: 'libs', include: ['*.jack'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
}
I have a workground method.
In the module where it make the .jack file, you can add
LOCAL_JACK_ENABLED := disabled
in the make file.Then it will generate .jar instead of .jack.
Then you can use the .jar as usual.
In my build gradle file I have two dependencies (appcompat-v7 and design) and then whatever externar jar files I add to the project
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
}
Is it normal to find in the project libraries (Project structure -> Libraries) the external jar files, appcompat-v7, design-22.2.1, support-v4 and support-annotations-22.2.1, I don't understand why the two last ones are being added, I think they're the cause of another issue I'm having (dexDebug).
Would anyone know if that is normal ?
Thanks
Running ./gradlew -q app:dependencies shows that com.android.support:appcompat-v7 depends on com.android.support:support-v4, so that is why it is pulled in. You will have to find a separate solution for your dex debug issue.
I've created an Android library with Studio and this library needs some 3rd libraries. The build.gradle looks like below:
dependencies {
compile fileTree(dir: 'libs', include: ['*.*'])
compile 'some library:1.3.2'
compile 'some other library:1.3.4'
}
The library can be compiled freely and finely, and then I push them in to local Maven. Everything fine!
Now I create a client application just for a sample of my library. What confusion is that I must do follow:
dependencies {
compile fileTree(dir: 'libs', include: ['*.*'])
compile 'mylibrary:1.0'
compile 'some library:1.3.2'
compile 'some other library:1.3.4'
}
Which means to include the two 3rd libraries. Otherwise I must get errors "NoClassFound" which relevant to the two libraries.
You know the
compile 'mylibrary:1.0'
is the meaning to include my library, but why should I include the other twos which were used by "mylibrary"? Could I avoid that and just -compile 'mylibrary:1.0' ?
OK, I've solved project with the help of #CommonsWare
Check out
http://www.gradle.org/docs/current/userguide/publishing_maven.html
http://maven.apache.org/pom.html
To make a pom.xml self and done.
I am having this issue and seem can't figure it out when building gradle android with proguard:
Can't read [C:\Users\xxx\dev\xyz\Xyz-nextgen\build\exploded-bundles\XyzCommonXyz_volleyUnspecified.aar\libs\android-support-v13.jar(;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [android/support/a/a/b.class == android-support-v13.jar:android/support/v13/app/FragmentCompat$FragmentCompatImpl.class])
There are 3 library projects and one app project.
All projects use only one android-support-v13.jar.
Thanks.
Andy
Open the module's gradle.build file and
In
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile files('libs/android-async-http-1.3.1.jar')
compile fileTree(dir: 'libs', include: '*.jar')
}
Change
compile 'com.android.support:support-v4:13.0.+'
To
compile 'com.android.support:support-v4:21.+'
make sure u have updated build tools in the sdk manager and let us know if that works
I am trying to move to gradle in my project and I've got problem while install admob
dependency
compile group: 'com.google.guava', name: 'guava', version: '12.0'
compile ('com.google.android.gms:play-services:4.+'){
exclude module: 'com.google.ads'
}
compile 'org.codehaus.plexus:plexus-interpolation:1.19'
compile 'de.greenrobot:eventbus:2.0.2'
compile 'com.squareup.retrofit:retrofit:1.4.1'
compile 'com.squareup.picasso:picasso:1.1.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.apache.commons:commons-lang3:3.0'
compile fileTree(dir: 'libs', include: '*.jar')
And I am geting
Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
in my libs folder only one
GoogleAdMobAdsSdk-6.4.1.jar
If your using Google Play services , then remove the GoogleAdMobAdsSdk jar from lib folder
You can also exclude the ads from play service like this, to continue with jar.
compile ('com.google.android.gms:play-services:4.3.23'){
exclude module:'gms.ads'
}
But you need to upgrade soon.
Note : Deprecated. On August 1, 2014, Google Play will stop accepting new or updated apps that use the old standalone Google Mobile Ads SDK v6.4.1 or lower. You must upgrade to the Google Play version of the Mobile Ads SDK by then.
Read these links
https://developers.google.com/mobile-ads-sdk/docs/admob/play-migration
https://developers.google.com/mobile-ads-sdk/download#downloadplay