本文主要是介绍正确引入setupdesign和setupcompat的方式,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
正确引入setupdesign和setupcompat的方式
引入方式如下:
├── app
│ ├── app.iml
│ ├── assests
│ ├── build
│ ├── build.gradle // 配置1
│ ├── libs
│ ├── proguard-rules.pro
│ └── src
├── build.gradle
├── TESTX.iml
├── gradle
│ └── wrapper
├── gradle.properties
├── gradlew
├── gradlew.bat
├── local.properties
├── settings.gradle // 配置2
├── setupcompat
│ ├── Android.bp
│ ├── AndroidManifest.xml
│ ├── build
│ ├── build.gradle
│ ├── TESTX.setupcompat.iml
│ ├── exempting_lint_checks.txt
│ ├── LICENSE
│ ├── lint.xml
│ ├── main
│ ├── METADATA
│ ├── MODULE_LICENSE_APACHE2
│ ├── OWNERS
│ ├── partnerconfig
│ ├── proguard.flags
│ └── setupcompat.iml
├── setupdesign
│ ├── Android.bp
│ ├── build
│ ├── build.gradle
│ ├── TESTX.setupdesign.iml
│ ├── exempting_lint_checks.txt
│ ├── LICENSE
│ ├── lint.xml
│ ├── main
│ ├── METADATA
│ ├── MODULE_LICENSE_APACHE2
│ ├── NOTICE
│ ├── OWNERS
│ ├── proguard.flags
│ ├── setupdesign.iml
│ └── strings
验证环境Android R.
setupdesign和setupcompat来自aosp /external/setupcompat和/external/setupdesign,可以通过gradle引入自有工程。
配置1:
// app/build.gradle
dependencies {implementation fileTree(dir: 'libs', include: ['*.jar'])// 关键implementation project(path: ':setupcompat')implementation project(path: ':setupdesign')implementation "com.google.android.material:material:1.2.0"
}
配置2:
// settings.gracle
rootProject.name='TESTX'
include ':app'
include(':setupdesign')
project(':setupdesign').projectDir = new File(settingsDir, './setupdesign')
include(':setupcompat')
project(':setupcompat').projectDir = new File(settingsDir, './setupcompat')
主工程里边直接引用相关布局即可。
根据setupcompat 导入提示:
//TESTX/setupcompat/build.gradle
/*** Include this gradle file if you are building against this as a standalone gradle library project,* as opposed to building it as part of the git-tree. This is typically the file you want to include* if you create a new project in Android Studio.** For example, you can include the following in your settings.gradle file:* include ':setupcompat'* project(':setupcompat').projectDir = new File(PATH_TO_THIS_DIRECTORY)** And then you can include the :setupcompat project as one of your dependencies* dependencies {* implementation project(path: ':setupcompat')* }*/apply plugin: 'com.android.library'android {// Not specifying compileSdkVersion here so clients can specify it; must be at least QcompileSdkVersion 30defaultConfig {minSdkVersion 14targetSdkVersion 30}buildTypes {release {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.flags'}}sourceSets.main {manifest.srcFile 'AndroidManifest.xml'java.srcDirs = ['main/java', 'partnerconfig/java']aidl.srcDirs = ['main/aidl']res.srcDirs = ['main/res']}compileOptions {sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8}
}dependencies {implementation "androidx.annotation:annotation:1.0.0"
}
针对这个提示:
// Not specifying compileSdkVersion here so clients can specify it; must be at least Q
compileSdkVersion 30
本地测试好像不给不行,必须给; 不给sync project直接报错。
A problem occurred configuring project ':setupcompat'.
> compileSdkVersion is not specified.
这篇关于正确引入setupdesign和setupcompat的方式的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!