【工作随笔记】SiliconLabs Android Demo 编译
作者:互联网
AndroidStudio:3.5.2
AndroidPhone:XiaoMi5 (Android 8.0)
AndroidDemo:3.1.4-44
AndroidDemo 源码路径:SimplicityStudio\v5\developer\sdks\gecko_sdk_suite\v3.2\app\bluetooth\android_application
一、修改为适合于 AndroidStdio 3.5.2 的 gradle 版本
--- android_application\gradle\wrapper\gradle-wrapper.properties
+++ android_application\gradle\wrapper\gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Fri Jul 24 14:59:38 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
--- android_application\build.gradle
+++ android_application\build.gradle
@@ -24,13 +24,13 @@
maven { url 'https://maven.google.com' }
mavenCentral()
jcenter()
google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.0.2'
+ classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'org.ajoberstar:grgit:1.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1"
}
}
二、解决长时间卡在 Gradle Resolve dependencies of:classpath 的问题
--- android_application\build.gradle
+++ android_application\build.gradle
@@ -18,14 +18,14 @@
}
buildscript {
ext.kotlin_version = '1.3.72'
ext.dagger_version = '2.21'
repositories {
- maven { url 'https://maven.google.com' }
- mavenCentral()
+// maven { url 'https://maven.google.com' }
+// mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'org.ajoberstar:grgit:1.5.0'
三、移除需要用 gradle 6.1.1 才能使用包(6.1.1需要 AndroidStudio 4.0 以上版本)
--- android_application\build.gradle
+++ android_application\build.gradle
@@ -8,13 +8,13 @@
def buildNumber = 44
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
-apply plugin: "de.mannodermaus.android-junit5"
+// apply plugin: "de.mannodermaus.android-junit5"
kapt {
generateStubs = true
}
buildscript {
@@ -27,13 +27,13 @@
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'org.ajoberstar:grgit:1.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- classpath "de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1"
+// classpath "de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1"
}
}
ext {
try {
grgit = Grgit.open(dir: '.')
@@ -146,20 +146,20 @@
kapt "com.google.dagger:dagger-compiler:$dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
// View
implementation "com.daimajia.swipelayout:library:1.2.0@aar"
//Test
def mockKotlin = 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
- testImplementation 'org.junit.jupiter:junit-jupiter'
+// testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation mockKotlin
testImplementation 'androidx.arch.core:core-testing:2.1.0'
- testImplementation 'org.mockito:mockito-inline:2.13.0'
+// testImplementation 'org.mockito:mockito-inline:2.13.0'
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.7.1"
androidTestImplementation mockKotlin
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation "org.mockito:mockito-android:2.24.5"
androidTestImplementation 'org.skyscreamer:jsonassert:1.5.0'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
四、为了支持 Android 8.0 的手机,修改最小SDK版本为 26
--- android_application\build.gradle
+++ android_application\build.gradle
@@ -54,13 +54,13 @@
}
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.siliconlabs.bluetoothmesh"
- minSdkVersion 28
+ minSdkVersion 26
targetSdkVersion 30
versionCode versionMajor * 10000000 + versionMinor * 100000 + versionPatch * 1000 + buildNumber
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
buildConfigField "Integer", "BUILD_NUMBER", "${buildNumber}"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
标签:Demo,classpath,gradle,com,org,Android,SiliconLabs,android,build 来源: https://blog.csdn.net/lovemengx/article/details/121440345