我正在尝试添加 mikepenz的Material Drawer 作为第三方项目。我想将它添加为项目的原因(而不仅仅是编译为依赖项),以便我可以根据我的要求修改抽屉的UI。但是我无法成功同步我的gradle并收到以下错误:
无法解决:project:Library:materialDrawer
这是我的项目结构:
-> root
->app
->Library
-> materialDrawer
-> app
-> build.gradle
-> settings.gradle
-> build.gradle(project)
-> settings.gradle
我试图遵循这个项目https://github.com/foragerr/android-multi-project-sample/blob/master/settings.gradle但是一脉相承。
这是我的 build.gradle(我的项目) 文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.novoda:bintray-release:0.3.4'
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
settings.gradle (我的项目)
include ':app', ':Library:materialDrawer'
build.gradle (应用:我的项目)
apply plugin: 'com.android.application'
apply plugin: 'android'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.******"
minSdkVersion 15
targetSdkVersion 25
versionCode 38
versionName "2.1.8"
generatedDensities = []
}
dexOptions {
javaMaxHeapSize "4g"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
tasks.whenTaskAdded { task ->
if (task.name.equals("lint")) {
task.enabled = false
}
}
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
/*
compile('com.mikepenz:materialdrawer:5.6.0@aar') {
transitive = true
}
*/
compile project(':Library:materialDrawer')
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:support-v4:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:cardview-v7:25.0.1'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5@aar'
compile 'com.github.ParkSangGwon:TedPermission:v1.0.12'
compile 'hanks.xyz:smallbang-library:0.1.2'
compile 'com.yalantis:ucrop:2.2.0'
compile 'com.github.clans:fab:1.6.4'
compile 'me.zhanghai.android.materialratingbar:library:1.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (项目:materialDrawer)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.novoda:bintray-release:0.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
我的Android Studio是v2.3.3 。我挠头,但找不到任何解决方案。请有人帮助我,我已经坚持了三天......
答案 0 :(得分:1)
因为您正在使用:
In [114]: issubclass(int, numbers.Real)
Out[114]: True
In [115]: issubclass(float, numbers.Real)
Out[115]: True
In [117]: issubclass(str, numbers.Real)
Out[117]: False
gradle正在该模块中寻找compile project(':Library:materialDrawer')
。
检查您的问题时,此文件存在,但它是顶级文件,而不是模块文件。
您应该以这种方式更改结构(不应将库文件夹放在另一个模块中)
build.gradle
您必须使用以下内容更改-> root
->app
-> build.gradle
->Library
-> materialDrawer
-> app
-> build.gradle
-> build.gradle
-> settings.gradle
-> build.gradle(project)
-> settings.gradle
settings.gradle
然后作为依赖使用:
include ':app', ':materialDrawer'
project(':materialDrawer').projectDir = new File('/Library/materialDrawer/app')