我已经成功将我的子项目lib包含到我的主项目中,但我似乎无法构建我的子项目库,所以我无法在我的脚本中导入它。
在构建所有内容后查看目录 / build / explosion-bundles /
我发现 MyAndroidProjectStickyScrollViewItemsUnspecified.aar ,与 ComActionBarSherlockAxtionBarSherlock440.aar 一起,两者都有类似的目录结构,两者都包含:
MyAndroidProject
|- .idea
|- MyAndroid
| |- build
| | |- exploded-bundles
| | | |- ComActionBarSherlockAxtionBarSherlock440.aar
| | | |- MyAndroidProjectStickyScrollViewItemsUnspecified.aar
| | | |- assets
| | | |- res
| | | |- AndroidManifest.xml
| | | |- classes.jar
| | | |- R.txt
| | |- res
| | |- sources
| |- src
| |- build.gradle
| |- MyAndroid.iml
|- gradle
|- project-lib
| |- StickyScrollViewItems
| |- build
| |- src
| | |- main
| | |- gen
| | | |- com.emilsjolander.components.stickyscrollviewitems
| | | |- BuildConfig.java
| | | |- Manifest.java
| | | |- R.java
| | |- java
| | | |- com.emilsjolander.components.stickyscrollviewitems
| | | |- StickyScrollView.java
| | |- res
| | |- AndroidManifest.xml
| |- build.gradle
| |- StickyScrollViewItems.iml
|- build.gradle
|- MyAndroidProject.iml
|- gradlew
|- gradle.bat
|- local.properties
|- settings.gradle
...
但是 ComActionBarSherlockAxtionBarSherlock440.aar 的classes.jar包含以下包:
这里是根项目的settings.gradle
include ':MyAndroid', ':StickyScrollViewItems'
project(':StickyScrollViewItems').projectDir = "$rootDir/project-lib/StickyScrollViewItems" as File
这里是MyAndroid的build.gradle
import groovy.transform.Field
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 16
targetSdkVersion 18
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.+'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.squareup.picasso:picasso:2.1.1'
compile 'com.github.snowdream.android:android-async-http:0.0.2'
compile 'de.greenrobot:greendao:1.3.2'
compile project(':StickyScrollViewItems')
}
,这是StickyScrollViewItems的build.gradle
import groovy.transform.Field
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 18
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.+'
}
我应该怎么做才能使用
import com.emilsjolander.components.stickyscrollviews.R;
答案 0 :(得分:1)
目前还不清楚你想要实现的目标,但很可能你应该使用@aar包而不是库项目:
settings.gradle
include ':MyAndroid'
\MyAndroid\build.gradle
dependencies {
compile 'se.emilsjolander:StickyScrollViewItems:1.0.0'
}
此库没有资源:
但是,如果将库添加为maven依赖项,则类不为空。请检查是否有帮助。
如果您需要修改库源,而不是更新库源,那么最近作者添加了gradle支持。