无法使用实时-android 库
Could not use realtime-android library
我想将这个 realtime-android 项目用作我的 Android 项目中的一个库,但是当我尝试导入这个项目时,它给了我这个 "No projects are found to import"。
那么如何将它用作图书馆呢?
谢谢您的帮助。
这是 build.gradle:
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')
}
}
根据 Maven Repo,您可以将其包含在 build.gradle
依赖项部分。
我注意到您缺少 repositories
部分,因此您可能需要添加它。例如,这是我的 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/
文件夹中。
我想将这个 realtime-android 项目用作我的 Android 项目中的一个库,但是当我尝试导入这个项目时,它给了我这个 "No projects are found to import"。
那么如何将它用作图书馆呢? 谢谢您的帮助。 这是 build.gradle:
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')
}
}
根据 Maven Repo,您可以将其包含在 build.gradle
依赖项部分。
我注意到您缺少 repositories
部分,因此您可能需要添加它。例如,这是我的 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/
文件夹中。