Uber SDK in android

点点圈 提交于 2019-12-25 07:15:30

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/37688976/uber-sdk-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!