AndroidStudio导入github上的开源项目做为lib的问题

有个MaterialDialog的开源项目 我下到本地后却不能作为lib导入 报如下问题
Error:Dependency Test:MateriaDialog:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: D:\Text\Test\MateriaDialog\build\outputs\apk\MateriaDialog-release-地址unsigned.apk项目地址https://github.com/afollestad/material-dialogs

https://www.v2ex.com/t/105606

错误提示:依赖模块解析编译为一个APK时出现异常,其实我们只想作为一个support供app依赖使用即可,并不需要生产apk。
你看下依赖模块的gradle文件,是不是这样apply plugin: 'com.android.application'。如果是,改为apply plugin: 'com.android.library'

我用过这个dialog,直接在AS中你项目的gradle中配置compile,开发者的github上有说明,你要是下载后本地导入,你只需要使用他的library就行,不用sample,不知道我理解你的问题是否正确。

你在gradle里面导入依赖库:
//materialDialog
compile 'com.afollestad.material-dialogs:commons:0.9.1.0'

然后这样调用就可以:

        new MaterialDialog.Builder(this)
                        .title(getString(R.string.title))
                        .content(getString(R.string.msg))
                        .positiveText(getString(R.string.confirm))
                        .negativeText(getString(R.string.cancel))
                        .show();

注意,如果直接写字符串可能会乱码,建议在string.xml定义好,然后引用。

我自己测试的效果图:

dialog