总的build```
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin
//项目的build.gradle中添加
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url ‘https://jitpack.io’ }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
项目下的build
apply plugin: ‘com.android.application’
//添加以下apply
apply plugin: ‘com.jakewharton.butterknife’
apply plugin: ‘org.greenrobot.greendao’
android {
compileSdkVersion 28
defaultConfig {
applicationId “com.lmx.shopcar”
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName “1.0”
testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner”
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '28.0.0'
}
}
}
}
}
//添加GreenDao的配置
greendao {
schemaVersion 1//数据库版本号,必须依次增大,用来判断数据库版本,是否需要更新
daoPackage ‘com.lmx.shopcar.greendao’//设置DaoMaster、DaoSession、Dao包名
targetGenDir ‘src/main/java’//设置DaoMaster、DaoSession、Dao目录
}
dependencies {
implementation fileTree(include: [’*.jar’], dir: ‘libs’)
implementation ‘com.android.support:appcompat-v7:28.0.0’
implementation ‘com.android.support.constraint:constraint-layout:1.1.3’
testImplementation ‘junit:junit:4.12’
androidTestImplementation ‘com.android.support.test?1.0.2’
androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2’
implementation ‘cn.yipianfengye.android:zxing-library:2.2’
//导入eventBus的依赖
implementation ‘org.greenrobot:eventbus:3.1.1’
implementation ‘com.squareup.okhttp3:okhttp:3.2.0’
//ok 日志的拦截器
implementation ‘com.squareup.okhttp3:logging-interceptor:3.12.0’
implementation ‘com.google.code.gson:gson:2.8.5’
implementation ‘com.github.bumptech.glide:glide:4.9.0’
implementation ‘com.jcodecraeer:xrecyclerview:1.5.9’
//有时导一个依赖会报错 加上这个就可以了
implementation ‘com.android.support:design:28.0.0’
//导入GreenDao依赖
implementation ‘org.greenrobot:greendao:3.2.2’
implementation ‘com.jakewharton:butterknife:9.0.0-rc1’
annotationProcessor ‘com.jakewharton:butterknife-compiler:9.0.0-rc1’
//导入RetroFit依赖
implementation ‘com.squareup.okhttp3:logging-interceptor:3.11.0’
implementation ‘com.squareup.retrofit2:retrofit:2.3.0’
implementation ‘io.reactivex:rxandroid:1.2.1’
implementation ‘io.reactivex:rxjava:1.3.0’
implementation ‘com.hwangjr.rxbus:rxbus:1.0.6’
implementation ‘com.squareup.retrofit2:converter-gson:2.1.0’
implementation ‘com.squareup.retrofit2:adapter-rxjava:2.0.2’
implementation ‘com.github.xiaohaibin:XBanner:1.6.4’
//省市区
implementation ‘com.contrarywind:Android-PickerView:4.1.6’
implementation 'com.github.lovetuzitong:MultiImageSelector:1.2'
//如果使用图片加载框架,添加依赖,下面用Glide示例
implementation 'com.github.bumptech.glide:glide:3.6.1'
implementation 'com.jaikydota.imagespickers:imagespickers:1.0.6'
//Fresco图片加载框架
implementation 'com.facebook.fresco:fresco:1.12.1'
}
清单文件
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MyApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<activity android:name=".DetailsActivity" />
<activity android:name=".MoreActivity" />
<activity android:name=".viewpager.mine.Parsonal_dataActivity" />
<activity android:name=".viewpager.mine.AddressActivity" />
<activity android:name=".viewpager.mine.AddAddressActivity" />
<activity android:name=".Publishing_circlesActivity" />
<activity android:name=".CreateorderActivity" />
<activity android:name=".PaymentActivity" />
<activity android:name=".EvaluateActivity" />
<activity android:name=".viewpager.mine.FootprintActivity" />
<activity android:name=".viewpager.mine.UpdateAddressActivity" />
<activity android:name=".viewpager.mine.ConsumptionActivity" />
<activity android:name=".viewpager.mine.MineCircleActivity" />
<activity android:name=".SearchActivity"></activity>
</application>
```