Java 库无法解析R.symbol

Java 库无法解析R.symbol,java,android,gradle,Java,Android,Gradle,我尝试添加外部库“ViewPagerIndicator” 我将build.gradle添加到库中并编译它。 库中有几个类无法导入支持库,但我的应用程序的build.gradle中有它 import android.support.v4.view.MotionEventCompat; 它给了我错误:(28,31)错误:包android.support.v4.view不存在。库无法解析R.符号 然后我尝试在ViewPagerIndicator库中添加支持库 这是应用程序/ViewPagerIndi

我尝试添加外部库“ViewPagerIndicator

我将
build.gradle
添加到库中并编译它。 库中有几个类无法导入支持库,但我的应用程序的
build.gradle
中有它

import android.support.v4.view.MotionEventCompat;
它给了我
错误:(28,31)错误:包android.support.v4.view不存在
。库无法解析
R.
符号

然后我尝试在ViewPagerIndicator库中添加支持库

这是
应用程序/ViewPagerIndicator/build.gradle

    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.android.support:support-v4:22.1.1'
}
apply plugin: 'com.android.library'  //Tells the build this is a library project

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'  //Where to find specific parts of the project
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
        instrumentTest.setRoot('tests')
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
它给了我
gradledsl方法未找到的“compile()”
错误

请告诉我怎么修

更新

我把
dependencies
放在
android
下面

apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'com.android.library'  //Tells the build this is a library project

android {
    compileSdkVersion 21
    buildToolsVersion '21.1.2'

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 22
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'  //Where to find specific parts of the project
            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')
    }
}
configurations {
    // Used for correct javadoc generation
    javadoc.extendsFrom compile
}
dependencies {
     compile fileTree(include: ['*.jar'], dir: 'libs')
     compile 'com.android.support:appcompat-v7:22.1.1'
     compile 'com.android.support:support-v4:22.1.1'
}
apply插件:“maven”
应用插件:“签名”
apply plugin:'com.android.library'//告诉构建这是一个库项目
安卓{
编译DK21版
buildToolsVersion'21.1.2'
默认配置{
明斯克版本9
targetSdkVersion 22
}
源集{
主要{
manifest.srcFile“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')
}
}
配置{
//用于正确生成javadoc
javadoc.extendsfromcompile
}
依赖关系{
编译文件树(包括:['*.jar'],目录:“libs”)
编译'com.android.support:appcompat-v7:22.1.1'
编译'com.android.support:support-v4:22.1.1'
}
它起作用了,但一点也不起作用

库仍然无法解析
R.
符号