Reputation: 1728
I'm trying the simplest example with Android Studio to create my own backend with this tutorial.
Backend is built and it seems like it's creating the client libraries as well.
The server starts and I can access it from localhost:8080
When I try to build my android app now, the app cannot find following classes
import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.extensions.android.json.AndroidJsonFactory;
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer;
neither the client model (called Registration, as in the sample).
How do I have to setup the dependencies of the project in gradle, so that the project can find the correctly generated client libraries?
Currently:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'de.unicate.cloudchat'
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services:4.4.+'
compile 'com.android.support:support-v4:+'
}
Shouldn't that happen automatically in Android Studio?
Upvotes: 3
Views: 744
Reputation: 2119
I also encountered the same problem. I added the dependencies from this Stack Overflow Answer.
Add these dependencies:
compile ('com.google.api-client:google-api-client-android:1.17.0-rc') {
exclude module: 'httpclient'
}
compile ('com.google.http-client:google-http-client-gson:1.17.0-rc') {
exclude module: 'httpclient'
}
See this example
Upvotes: 1
Reputation: 2423
The newest version of the wizards adds the dependencies to your project automatically(as you mention), what version of android studio are you using?
The modified build.gradle file will have the extra dependency
compile project(path: ':<backend-module-name>', configuration: 'android-endpoints')
Upvotes: 0