无法使用实时android库
我想在我的Android项目中将此项目用作库,但当我尝试导入此项目时,它会告诉我“找不到要导入的项目” 那么,如何将其用作图书馆呢? 谢谢你的帮助。 这是build.gradle:无法使用实时android库,android,import,android-library,Android,Import,Android Library,我想在我的Android项目中将此项目用作库,但当我尝试导入此项目时,它会告诉我“找不到要导入的项目” 那么,如何将其用作图书馆呢? 谢谢你的帮助。 这是build.gradle: apply plugin: 'android' dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile project(':appcompat_v7') compile project(':gridlayo
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':appcompat_v7')
compile project(':gridlayout_v7')
compile 'com.goodow.realtime:realtime-android:0.5.0'
}
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
apply插件:“安卓”
依赖关系{
编译文件树(目录:“libs”,包括:“*.jar”)
编译项目(':appcompat_v7')
编译项目(':gridlayout_v7')
编译'com.goodow.realtime:realtime android:0.5.0'
}
安卓{
编译DK20版
buildToolsVersion“20.0.0”
编译选项{
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
源集{
主要{
manifest.src文件“AndroidManifest.xml”
java.srcDirs=['src']
resources.srcDirs=['src']
aidl.srcDirs=['src']
renderscript.srcDirs=['src']
res.srcDirs=['res']
assets.srcDirs=['assets']
}
//将测试移动到tests/java、tests/res等。。。
instrumentTest.setRoot('tests'))
//将生成类型移动到生成类型/
//例如,build-types/debug/java、build-types/debug/AndroidManifest.xml。。。
//这会将它们移出src/…下的默认位置,这将
//与主源集正在使用的src/冲突。
//应同时添加新的构建类型或产品风格
//通过类似的定制。
setRoot('build-types/debug')
setRoot('build-types/release')
}
}
根据,您可以将其包含在build.gradle
依赖项部分中
我注意到您缺少存储库
部分,因此您可能需要添加该部分。例如,这是我的build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
// ... other stuff
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:23.2.1"
compile "com.android.support:design:23.2.1"
// this line
compile 'com.goodow.realtime:realtime-android:0.5.0'
}
或者您可以使用下载JAR按钮,将其放入项目的
libs/
文件夹中 您是在使用Gradle,还是将其作为JAR下载?我已经从github下载了此项目,但我无法将其导入到我的工作区,以将其作为库添加到当前项目中。为什么需要从github下载此项目?此外,您需要将其作为Maven项目导入,而不是Java项目。我在build.Gradle中包含了这一行,那我该怎么做才能让它工作呢?我已经将项目放入libs/中,但是导入仍然无法解决。您只需要使用gradle或下载JAR,而不是两者都需要。我推荐格拉德尔。另外,您要导入什么?我可以做导入com.goodow.realtime.android.AndroidPlatform代码>很好,没有错误。我添加了那一行,然后清理了项目,但导入仍然无法解决。我也在尝试导入com.goodow.realtime.android.AndroidPlatform。你能把你的问题包含在完整的build.gradle文件中吗?@SDH,这样就可以了?我认为如果您在清理后重建项目,它应该下载该库并允许您导入。