其他分享
首页 > 其他分享> > Gradle – 无法使用gradle依赖项在Android Studio中导入viewpagerindicator

Gradle – 无法使用gradle依赖项在Android Studio中导入viewpagerindicator

作者:互联网

所以我试图使用actionbarsherlock和viewpagerindicator,由于某种原因,viewpagerindicator库由于某种原因没有导入.任何人都有任何想法?

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.viewpagerindicator:library:2.4.0'
}

dependencies {
    compile project(':libraries:facebook')
}

此导入错误“无法解析符号viewpageindicator

import com.viewpagerindicator.TabPageIndicator;

这些是我的“消息gradle任务”

Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\android-sdk\build-tools\19.0.1\aapt.exe package -f --no-crunch -I C:\android-sdk\platforms\android-19\android.jar -M C:\myAppName\app\build\manifests\debug\AndroidManifest.xml -S C:\myAppName\app\build\res\all\debug -A C:\myAppName\app\build\assets\debug -m -J C:\myAppName\app\build\source\r\debug -F C:\myAppName\app\build\libs\app-debug.ap_ --debug-mode --custom-package com.myAppName.app --output-text-symbols C:\myAppName\app\build\symbols\debug
Error Code:
    1
Output:
    C:\myAppName\app\build\res\all\debug\values\values.xml:911: error: Error: No resource found that matches the given name: attr 'vpiTabPageIndicatorStyle'.
    C:\myAppName\app\build\res\all\debug\values\values.xml:914: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.TabPageIndicator'.
    C:\myAppName\app\build\res\all\debug\values\values.xml:934: error: Error: No resource found that matches the given name: attr 'fadeDelay'.
    C:\myAppName\app\build\res\all\debug\values\values.xml:933: error: Error: No resource found that matches the given name: attr 'fadeLength'.
    C:\myAppName\app\build\res\all\debug\values\values.xml:931: error: Error: No resource found that matches the given name: attr 'selectedColor'.


C:\myAppName\app\src\main\res\values\styles.xml
    No resource found that matches the given name: attr 'vpiTabPageIndicatorStyle'.
    Error retrieving parent for item: No resource found that matches the given name 'Widget.TabPageIndicator'.
    No resource found that matches the given name: attr 'fadeDelay'.
    No resource found that matches the given name: attr 'fadeLength'.
    No resource found that matches the given name: attr 'selectedColor'.

解决方法:

您无法通过导入ViewPagerIndicator

compile 'com.viewpagerindicator:library:2.4.0'

因为Maven工件只是Java库的一个jar,但是VPI依赖于jar中没有的Android资源.

具有AAR打包的Maven工件确实具有资源并且可以工作,但VPI不是这样打包的.它有apklib包装,但Android Gradle插件不支持.

您需要下载源代码并将其设置为android-library模块.

您没有具体说明您正在运行的Android Studio版本,但我愿意打赌您导入的问题不起作用的原因是您运行的是早于0.4.3的内容;从那时起,该区域就已经修复了错误.

标签:android,gradle,android-gradle,android-viewpager,viewpagerindicator
来源: https://codeday.me/bug/20190713/1449792.html