编译Firebase和Google?

时间:2017-09-13 12:26:11

标签: java android facebook firebase

我想让谷歌日历工作,我很不确定我是否需要FIrebase和Google API。

我正在尝试测试此代码`

Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials).setApplicationName("applicationName").build();
    // Retrieve an event
    Event event = service.events().get('primary', "eventId").execute();

    System.out.println(event.getSummary());
    texty = (TextView)findViewById(R.id.texty1);
    Button b2 = (Button)findViewById(R.id.button2);

    b2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            new doit().execute();

        }
    });

但即使我同时使用Firebase和Google API,我也无法导入所需的库。这是我的build.gradle文件:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.ticketApp.myName.ticketApp"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials).setApplicationName("applicationName").build();

    // Retrieve an event
    Event event = service.events().get('primary', "eventId").execute();

android {
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
})

//Extra dependecies


compile 'com.google.android.gms:play-services:11.2.2'

//androidTestCompile 'com.google.code.findbugs:jsr305:3.0.1'


//Google firebase
compile 'com.google.firebase:firebase-core:11.2.2'




//compile 'com.android.support:appcompat-v7:26.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'



//Jsoup för kalendern
compile 'org.jsoup:jsoup:1.10.3'

testCompile 'junit:junit:4.12'
compile 'junit:junit:4.12'

}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

有什么想法吗?它说它无法解析符号'Builder',无论是方法'events'还是'getSummary'。

真诚的安卓。

1 个答案:

答案 0 :(得分:1)

要解决此问题,请打开build.gradle文件(Module:app)并在依赖关系之前添加Maven Central Repository,如下所示:

repositories {
    mavenCentral()
}

然后改变这行代码:

compile 'com.facebook.android:facebook-android-sdk:[4,5)'

compile 'com.facebook.android:facebook-android-sdk:4.+'