找不到符号导入com.twitter.sdk.android.Twitter使用Fabric

时间:2015-05-27 19:40:58

标签: android twitter android-studio android-gradle twitter-fabric

Twitter的Fabric平台/ SDK全新。我一直试图将它整合到我现有的build.gradle中,到目前为止它一直很混乱。

当我尝试安装"使用Twitter登录"通过Fabric插件提供功能,它会更新build.gradle,然后在同步期间抛出以下错误:

Note: Resolve log file to C:\Users\Mark\AndroidStudioProjects\StarkEnglish2\app\build\generated\source\apt\androidannotations.log
Note: Initialize AndroidAnnotations 3.3.1 with options {androidManifestFile=C:\Users\Mark\AndroidStudioProjects\StarkEnglish2\app\build\intermediates\manifests\full\debug\AndroidManifest.xml}
C:\Users\Mark\AndroidStudioProjects\StarkEnglish2\app\src\main\java\com\starkenglish\app\StarkApplication.java:5: error: cannot find symbol
import com.twitter.sdk.android.Twitter;
                              ^
  symbol:   class Twitter
  location: package com.twitter.sdk.android
warning: The following options were not recognized by any processor: '[androidManifestFile]'
1 error

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

我当前的android项目build.gradle是:

apply plugin: 'com.android.application'


buildscript {
    repositories {
        mavenCentral()

        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        // replace with the current version of the Android plugin
        classpath 'com.android.tools.build:gradle:1.2.3'

        classpath 'io.fabric.tools:gradle:1.+'

        // replace with the current version of the android-apt plugin
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'



    }
}


apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'io.fabric'


repositories {
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}


def AAVersion = '3.3.1'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
    }
    defaultConfig {
        applicationId "..."
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 2
        versionName '1.0.1'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.twitter.sdk.android:twitter-core:1.3.2@aar') {
        transitive = true;
    }
    compile 'com.firebase:firebase-client-android:2.0.3'
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.google.android.gms:play-services:7.3.0'
    apt "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.daimajia.easing:library:1.0.1@aar'
    compile 'com.daimajia.androidanimations:library:1.1.3@aar'
    //compile 'com.facebook.android:facebook-android-sdk:4.1.0'
    compile 'com.github.gabrielemariotti.cards:cardslib-core:2.1.0'
    compile 'com.github.gabrielemariotti.cards:cardslib-cards:2.1.0'
    compile 'com.github.gabrielemariotti.cards:cardslib-recyclerview:2.1.0'
}


apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        // if you have multiple outputs (when using splits), you may want to have other index than 0

        // You can set optional annotation processing options here, like these commented options:
        // logLevel 'INFO'
        // logFile '/var/log/aa.log'
    }

}

不知何故Fabric的SDK部分加载,但是当我尝试导入任何com.twitter.sdk.android.Twitter时,我收到了#34;无法解析Twitter符号"错误。

我有:

  • 清理并重建项目
  • 无效的缓存并重新启动Android Studio
  • 重新启动计算机

任何想法为什么它只会部分加载?这些带插件的庞大SDK开始让我疯狂: - /

任何帮助/指导都将不胜感激。

1 个答案:

答案 0 :(得分:5)

在下面的这一行中替换twitter-core

compile('com.twitter.sdk.android:twitter-core:1.3.2@aar') {
        transitive = true;
    }
用推特开发 所以它看起来像这样

compile('com.twitter.sdk.android:twitter:1.3.2@aar') {
        transitive = true;
    }