首先,注册leanCloud账号,创建自己的应用并获取SDK
1、打开根目录下的build.gradle进行如下配置
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url "http://mvn.leancloud.cn/nexus/content/repositories/public"//仓库地址
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "http://mvn.leancloud.cn/nexus/content/repositories/public"//仓库地址
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2、然后打开APP目录下的build.gradle进行如下配置:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.zs.login"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'cn.leancloud.android:avoscloud-sdk:v4.6.4'
implementation 'cn.leancloud.android:avoscloud-statistics:v4.6.4'
implementation 'cn.leancloud.android:avoscloud-feedback:v4.6.4@aar'
implementation 'cn.leancloud.android:avoscloud-sns:v4.6.4@aar'
implementation 'cn.leancloud.android:qq-sdk:1.6.1-leancloud'
implementation 'cn.leancloud.android:avoscloud-search:v4.6.4@aar'
implementation 'com.android.support:recyclerview-v7:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
下一步进行初始化:
1、首先进入 控制台 > 设置 > 应用 Key 来获取 App ID 以及 App Key。
2、