我想将此库导入到我的项目中 Android Studio v1.0.0 rc2:
https://github.com/navasmdc/MaterialDesignLibrary
但是有一个问题。当我将此库添加为模块时,出现此错误:
错误:依赖项 MyApplication.libraries:MaterialDesign:项目应用程序上未指定解析为不支持作为编译依赖项的 APK 存档。文件:C:\ADTBundle\StudioWorkspace\MyApplication\libraries\MaterialDesign uild\outputs pk\MaterialDesign-release-unsigned.apk
解决这个问题的分步指南是什么?或者这个库的 gradle 依赖项是什么?
https://material.io/develop/android/docs/getting-started/ 请按照此处的说明操作
上次编辑时最新的库版本是
implementation 'com.google.android.material:material:1.11.0'
更新:从这里获取最新的材料设计库 https://maven.google.com/web/index.html?q=com.google.android.material#com.google.android.material:material
对于较旧的 SDK
添加与您的appcompat-v7库相同的设计支持库版本
您可以从android开发者文档获取最新的库https://developer.android.com/topic/libraries/support-library/packages#design
implementation 'com.android.support:design:28.0.0'
build.gradle
文件中更改以下内容。
com.android.application
应用插件:
com.android.library
删除
applicationId
并设置
minSdkVersion
以匹配您的项目 minSdkVersion。
build.gradle
文件
compile project(':MaterialDesignLibrary')
,其中
MaterialDesignLibrary
是您的库项目的名称,或者您可以通过文件 -> 项目结构 -> 在模块下选择您的项目 -> 依赖项 -> 单击点击 + 添加模块。
com.google.android.material:material:1.0.0-rc01
compile 'com.android.support:design:23.2.1'
implementation 'com.google.android.material:material:<version>'
获取最新的材料设计库版本。查看官方网站github仓库。
当前版本是1.2.0。
所以,你必须补充,
implementation 'com.google.android.material:material:1.2.0'
然后,您需要通过添加将应用程序主题更改为材料主题,
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
在您的style.xml中。不要忘记在清单文件中的应用程序主题中设置相同的主题。
implementation 'com.google.android.material:material:1.2.0-alpha02'
样式.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
app:level gradle.build 中,向旧项目添加最新的库支持,如下所示
apply plugin: 'com.android.application'
android {
// rest code
dependencies {
implementation("com.squareup.okhttp3:okhttp:4.10.0")
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
}