Android 如何将另一个库编译成库?
我有一个用Android 如何将另一个库编译成库?,android,android-gradle-plugin,android-library,android-build,Android,Android Gradle Plugin,Android Library,Android Build,我有一个用com.Android.support编译的Android库:appcompat-v7:23.1.1等等,因为该库是一个自定义视图。但当我构建库时,错误显示: Error:(8, 33) error: package android.support.v7.widget does not exist Error:(9, 33) error: package android.support.v7.widget does not exist Error:(21, 5)
com.Android.support编译的Android库:appcompat-v7:23.1.1
等等,因为该库是一个自定义视图。但当我构建库时,错误显示:
Error:(8, 33) error: package android.support.v7.widget does not exist
Error:(9, 33) error: package android.support.v7.widget does not exist
Error:(21, 5) error: cannot find symbol class RecyclerView
Error:(57, 13) error: cannot find symbol class LinearLayoutManager
Error:package R does not exist
13 warnings
:mylibrary:javadoc FAILED
Error:Execution failed for task ':mylibrary:javadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting):
'~/Documents/WorkSpace/MyLibrary/mylibrary/build/tmp/javadoc/javadoc.options'
Information:BUILD FAILED
我的库的
build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "0.1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
}
apply from: 'deploy.gradle'
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "**.**.demo"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile project(':mylibrary')
}
include ':mylibrary', ':demo'
我的主模块的
build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "0.1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
}
apply from: 'deploy.gradle'
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "**.**.demo"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile project(':mylibrary')
}
include ':mylibrary', ':demo'
我的项目的
设置。gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "0.1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
}
apply from: 'deploy.gradle'
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "**.**.demo"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile project(':mylibrary')
}
include ':mylibrary', ':demo'
似乎需要向主模块或库模块添加依赖项。@Rediska感谢您的回复。当我用我的库运行主模块时,它工作了,我只添加了我的库作为依赖项。但在构建我的库时,会出现错误。我需要将库上传到maven中心,所以它必须通过building.Post all build.gradlefiles@JaredBurrows我已经更新了问题,谢谢。发布你的settings.gradle文件