根目录下build.gradle代码:
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() // flatDir { // dirs 'libs' // } maven { url "http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories/" } } } task clean(type: Delete) { delete rootProject.buildDir }
主要是添加一个mave
app下的build.gradle代码:
apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion "26.0.3" defaultConfig { applicationId "com.ft.tbdemo" minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" //如果jdk版本不同需要加上下面的除外还要打开jack 否则会报错 jackOptions { enabled true } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } //如果jdk版本不同需要加上这一句 compileOptions{ sourceCompatibility org.gradle.api.JavaVersion.VERSION_1_8 targetCompatibility org.gradle.api.JavaVersion.VERSION_1_8 } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' // compile(name: 'alisdk-hotfix-2.0.9', ext: 'aar') //基础安全组件 // compile 'com.taobao.android:securityguardaar3:5.4.171@aar' // compile 'com.taobao.android:securitybodyaar3:5.4.99@aar' // compile 'com.taobao.android:avmpaar3:5.4.36@aar' // compile 'com.taobao.android:sgmiddletieraar3:5.4.9@aar' // //mtop // compile 'com.taobao.android:mtopsdk_allinone_open:3.1.2.5@jar' // //登录授权 // compile 'com.ali.auth.sdk:alibabauth_core:2.0.0.6@aar' // compile 'com.ali.auth.sdk:alibabauth_ui:2.0.0.6@aar' // compile 'com.ali.auth.sdk:alibabauth_ext:2.0.0.6@aar' // //appLink // compile 'com.alibaba.sdk.android:alibc_link_partner:4.1.6@aar' // //基础电商组件 // compile 'com.alibaba.sdk.android:AlibcTradeCommon:4.0.0.0@aar' // compile 'com.alibaba.sdk.android:AlibcTradeBiz:4.0.0.0@aar' // compile 'com.alibaba.sdk.android:nb_trade:4.0.0.0@aar' //支付宝(可选) compile 'com.alipay.android.app.cashier:standardcashier-single:15.6.5@aar' // compileOnly 'com.alipay.mobile.android.securitysdk:apsecuritysdk-all:3.3.0' testCompile 'com.alipay.mobile.android.securitysdk:apsecuritysdk-all:3.3.0' //登陆 compile 'com.ali.auth.sdk:alibabauth_core:2.0.0.6@aar' compile 'com.ali.auth.sdk:alibabauth_ui:2.0.0.6@aar' compile 'com.ali.auth.sdk:alibabauth_ext:2.0.0.6@aar' //安全组件 compile 'com.taobao.android:securityguardaar3:5.4.171@aar' compile 'com.taobao.android:securitybodyaar3:5.4.99@aar' compile 'com.taobao.android:avmpaar3:5.4.36@aar' compile 'com.taobao.android:sgmiddletieraar3:5.4.9@aar' //Mtop compile 'com.taobao.android:mtopsdk_allinone_open:3.1.2.5@jar' //applink compile 'com.alibaba.sdk.android:alibc_link_partner:4.1.6@aar' //ut compile 'com.taobao.android:utdid4all:1.1.5.3_proguard' compile 'com.alibaba.mtl:app-monitor-sdk:2.6.4.5_for_bc' // 电商基础组件 compile 'com.alibaba.sdk.android:AlibcTradeCommon:4.0.0.0@aar' compile 'com.alibaba.sdk.android:AlibcTradeBiz:4.0.0.0@aar' compile 'com.alibaba.sdk.android:nb_trade:4.0.0.0@aar' compile 'com.alibaba:fastjson:1.2.41' }
//初始化
AlibcTradeSDK.asyncInit(this, new AlibcTradeInitCallback() { @Override public void onSuccess() { Toast.makeText(getApplicationContext(), "初始化成功", Toast.LENGTH_SHORT).show(); } @Override public void onFailure(int code, String msg) { Toast.makeText(getApplicationContext(), "初始化失败", Toast.LENGTH_SHORT).show(); } });