我正在尝试将图书馆计划(Android Studio Project)包含在另一个Android Studio项目(应用程序)中。 Library项目有一个Activity,我想从我的Application中启动它。
我在Gradle Sync中遇到错误。
我收到了这些错误:
我已经完成了其他Stackoverflow问题。
我添加了库项目 File-> New-> New Module-> Import Gradle Project。
我在我的图书馆计划中进行了以下更改。 我在库项目的build.gradle中添加了以下行。
apply plugin: 'com.android.library'
我评论了ApplicationID。
在settings.gradle中,我添加了
include ":LibraryName"
在App的build.gradle中,我添加了
compile project(":LibraryName")
我在这里缺少什么?
编辑:添加应用的Build.gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.viga.nativeapp"
minSdkVersion 22
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(":VimeoVideoPlayer")
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
}
Settings.gradle
include ':app', ':VimeoVideoPlayer'
答案 0 :(得分:0)
找到解决方案。尽管Gradle无法找到它们,但所有.aar文件都存在于VimioVideoPlayer / libs文件夹中。为了解决这个问题,我手动添加了所有缺少的依赖项。
在此更改之后,几行build.gradle的VimeoVideoPlayer。
删除以下行
compile(name: 'unitygvr', ext:'aar')
compile(name: 'gvr', ext:'aar')
compile(name: 'gvr-permissionsupport-release', ext:'aar')
compile(name: 'gvr-keyboard', ext:'aar')
compile(name: 'gvr-exoplayersupport-release', ext:'aar')
compile(name: 'exoplayer-r1.5.11', ext:'aar')
并添加这些行
compile project(':unitygvr')
compile project(':gvr')
compile project(':gvr-permissionsupport-release')
compile project(':gvr-keyboard')
compile project(':gvr-exoplayersupport-release')
compile project(':exoplayer-r1.5.11')
解决了这个问题。
答案 1 :(得分:0)
解决问题的正确方法是将lib目录添加到顶级build.gradle文件中的存储库列表中。
allprojects {
repositories {
flatDir {
dirs 'VimioVideoPlayer/libs'
}
}
}