I am trying to add an Uber 'request a ride' button in my android application. In my gradle build file I have added the following line:
compile 'com.uber.sdk:rides-android:0.5.0'
Automatically Android studio asks to sync the gradle files as they have changed. After this I get 500+ errors with my project but when I remove the dependency it all goes back to normal.
Could anyone please help me solve this issue?
The module gradle script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
android {
useLibrary 'org.apache.http.legacy'
}
defaultConfig {
applicationId "com.example.android.myuberapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/fonts'] } }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/android-async-http-1.4.4.jar')
compile files('libs/volley.jar')
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.github.sembozdemir:ViewPagerArrowIndicator:1.0.0'
compile 'com.google.maps.android:android-maps-utils:0.4+'
compile 'com.github.jakob-grabner:Circle-Progress-View:v1.2.9'
compile 'me.grantland:autofittextview:0.2.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.uber.sdk:rides-android:0.5.0'
}
The full set of errors:
Error file is here
It looks like you've past the 64k limit and should enable multidex.
The majority of those "errors" are actually warnings that gradle seems to be grouping together. Check the last couple lines of the error for the exact message.
In your build.gradle
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
And in your manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Separately:
Since the Uber SDK isn't that large, another suggestion to delay multidex is to only the use the Play services libraries you actually need.
For example, instead of
'com.google.android.gms:play-services:8.4.0'
You could use just cloud messaging (if that is the component used).
com.google.android.gms:play-services-gcm:8.4.0
See more here
Related
Receving this error on KitKat and lower version running perfectly on Lollipop and above
I have included all the required jars in th gradle and Firebase json file to receive GCM.
my app gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId ""
minSdkVersion 13
targetSdkVersion 23
versionCode 6
versionName "1.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
defaultConfig {
multiDexEnabled true
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':httpmime-4.2.5')
compile project(':universal-image-loader-1.9.3')
compile project(':universal-image-loader-1.9.3')
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.3'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services:9.0.0'
testCompile 'junit:junit:4.12'
}
This dependency includes the code for all of the Google Play Services APIs:
compile 'com.google.android.gms:play-services:9.0.0'
This is very likely causing your app to exceed the 65K method reference limit, requiring you to use Multidex to run on pre-Lollipop devices.
You have two choices. You can include only the Play Services APIs you actually need. The list is here in the section titled Selectively compiling APIs into your executable. Or you can enable Multidex following the instructions here. Although you have multiDexEnabled true in your build.gradle file, that is only one of the three steps required to configure Multidex. You also need to include the library as a dependency and update your manifest.
If you are using Android Studio 2.2.2, you can see how many method references are in your app using the APK Analyzer. From the menubar, select Build > Analyze APK. The APK is in folder .../app/build/outputs/apk. Select the APK file, and in the resulting window, click on classes.dex to see the number of methods and method references.
Please update the firebase dependencies
dependencies {
...
compile 'com.google.firebase:firebase-messaging:9.6.0'
...
}
apply plugin: 'com.google.gms.google-services'
Hope it helps..
All day I have a challenge with resolve update of some dependencies in my new project.
This is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com...."
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.firebase:firebase-database:9.6.1'
compile 'com.google.firebase:firebase-storage:9.6.1'
compile 'com.firebaseui:firebase-ui:0.4.3'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.android.gms:play-services:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
and error is:
Error:
"Execution failed for task: ':app:transformClassesWithDexForDebug'
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/home/bin/java" finished with non zero-exit value 2
The problem was showing when I tried to upload an image to Firebase storage. There was error with an internet connection etc. I decided to make update of libraries. After this there is an error with jdk 1.8.
Could somebody help me to resolve this challenge?
Regards
Basically you would also want to check and resolve version conflicts in your app's dependencies.
Also check if you have enabled multidex in your app.
I had a similar issue. In my app I am using guava-retrying library, which was fetching google guava library version 21. Guava version 21 requires JDK 1.8 without providing back porting support and this was causing this error in my case.
I was able to solve it by including the guava-retrying library so that it uses version 19.0 of guava library:
compile ("com.github.rholder:guava-retrying:2.0.0") {
exclude group: 'com.google.guava', module: 'guava'
}
compile 'com.google.guava:guava:19.0'
I believe you need to enable Multidex for your application.
add the Multidex library to your dependencies, then enable Multidex in defaultConfig.
Example:
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com...."
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.firebase:firebase-database:9.6.1'
compile 'com.google.firebase:firebase-storage:9.6.1'
compile 'com.firebaseui:firebase-ui:0.4.3'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.android.gms:play-services:9.6.1'
compile 'com.android.support:multidex:1.0.0'
}
Then in `AndroidManifest.xml", enable Multidex installation:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Source: https://developer.android.com/studio/build/multidex.html#mdex-gradle
How can I stop building for API23? I have many libraries, reduced probably all to API22 from API23. Still I have problems, when want to sync my gradle, it is showing errors in V23 styles.
Is there a way to disable building V23? I don't want to use API23. Don't tell me to update my project to API23 because in my app, permission checking is not necessary. It's inside company app (not for Google Play) and permission dialogs are not necessary.
This is error
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Here is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "com.pongodev.layartancepapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 2
versionName "2.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:recyclerview-v7:22.1.0'
compile('com.mikepenz:materialdrawer:4.4.6#aar') {
transitive = true
}
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
testCompile 'junit:junit:4.12'
compile 'com.mcxiaoke.volley:library:1.0.0'
compile 'com.github.mrengineer13:snackbar:1.0.0'
compile 'com.marshalchen.ultimaterecyclerview:library:0.3.18'
compile 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
compile 'com.mikepenz:google-material-typeface:2.2.0.3.original#aar'
compile 'com.github.AndroidDeveloperLB:MaterialPreferenceLibrary:1'
}
You can define compileSdkVersion and buildToolsVersion to 22 in build.gradle
compileSdkVersion = 'Google Inc.:Google APIs:22'
buildToolsVersion = "22.0.0"
These steps works for you:
1.Click build.gradle
2.Change compileSdkVersion 23 to 22
3.Change targetSdkVersion 23 to 22
follow pics
See Picture for clear understanding
I'm trying to write a youtube app in android. I tried to use this example https://developers.google.com/youtube/v3/docs/search/list#examples (Java#1). I have only used the import statements from this and when trying to compile I get a lot of errors. I wasn't sure how to import the libraries, first I tried downloading libraries from the internet but that didn't work, although the red error line moved onto further words (for example "import thing.thing2.thing3" before the red error line was under thing then moved to thing2). Then I searched mvnrepository and copy and pasted the code under the 'gradle' tab into my gradle which fixed the red error lines but now I have a lot of errors when trying to run my app (I do not have any red lines in my app as far as I can see). My gradle file looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "richardcastle324.yahoo.com.elephantyoutube"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.google.android.gms:play-services-drive:8.4.0'
compile files('libs/google-api-client-1.16.0-rc-sources.jar')
compile files('libs/google-api-services-youtube-v3-rev176-1.22.0-javadoc.jar')
compile 'com.google.android.gms:play-services:9.2.0'
compile 'com.google.apis:google-api-services-youtube:v3-rev176-1.22.0'
// https://mvnrepository.com/artifact/com.google.apis/google-api-services-youtube
compile group: 'com.google.apis', name: 'google-api-services-youtube', version: 'v3-rev176-1.22.0'
// https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client-java6
compile group: 'com.google.oauth-client', name: 'google-oauth-client-java6', version: '1.11.0-beta'
// https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client-jetty
compile group: 'com.google.oauth-client', name: 'google-oauth-client-jetty', version: '1.11.0-beta'
}
I'm not entirely sure what all those dependencies are doing, but I have a basic youtube app that is working with the following build gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.jakespeers.youtubeplayer"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files("libs/YouTubeAndroidPlayerApi.jar")
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services:8.4.0'
}
Just make sure you have the "YouTubeAndroidPlayerApi.jar" file in your libs folder. Find the libs folder by going into the apps names folder, followed by the "app" folder, then finally the "libs" folder. Make sure the file is spelt exactly the same. Also don't forget to change your applicationId. If you need more dependencies you can add them as you need them.
If this still doesn't work, please post the errors you are getting.
Here is the link to download the lib file:
https://developers.google.com/youtube/android/player/downloads/
I just updated my android studio to the latest version with the new gradle version also, running my application gives me an error class android support v4 has been already added to the output don't know what is going wrong i check if there is a jar duplicated or a library duplicated couldn't find anything. here is my app:build.gradle
enter code here
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
lintOptions
{
checkReleaseBuilds false
//abortOnError true
}
defaultConfig {
applicationId "package name"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes
{
release {
minifyEnabled true
proguardFile getDefaultProguardFile('proguard-android.txt')
}
}
dexOptions {
preDexLibraries = false
incremental true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project('Libraries:UniversalImageLoader')
compile project('Libraries:facebook')
compile project('Libraries:pull-to-refresh')
compile files('Libraries/gcm.jar')
compile files('Libraries/quickblox-android-sdk-chat-2.0.jar')
compile files('Libraries/quickblox-android-sdk-core-2.0.jar')
compile files('Libraries/quickblox-android-sdk-messages-2.0.jar')
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.google.maps.android:android-maps-utils:0.3'
compile 'com.squareup.picasso:picasso:2.4.0'
compile "com.android.support:appcompat-v7:21.0.2"
}
I took of this
compile 'com.android.support:support-v4:21.0.2'
i thought its already included in the appcompat-v7 but it did not solve my issue yet
I downgraded my Android Studio version to 0.8.6 and the "Duplicate Copies" error disappear.
It isn't a perfect solution but for now and for me it is the unique solution currently.