Android:无法正确设置build.gradle

时间:2017-07-07 07:46:05

标签: android firebase gradle firebase-cloud-messaging

我有这个bulild.gradle

 apply plugin: 'com.android.application'

 android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "my.package"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 2
    versionName "2.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

 repositories {
mavenCentral()
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'me.dm7.barcodescanner:zxing:1.8.4'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile files('libs/urlimageviewhelper-1.0.4.jar')
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5@aar'
compile 'com.github.ksoichiro:android-observablescrollview:1.6.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'


}

apply plugin: 'com.google.gms.google-services'

我收到此错误。

  Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

发现我必须更改android支持的版本,所以我做了

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "sk.weyou.matej_kosut.sowosk"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 2
    versionName "2.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

repositories {
mavenCentral()
}

 dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'me.dm7.barcodescanner:zxing:1.8.4'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile files('libs/urlimageviewhelper-1.0.4.jar')
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5@aar'
compile 'com.github.ksoichiro:android-observablescrollview:1.6.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'


 }

  apply plugin: 'com.google.gms.google-services'

现在我又收到了另一个错误

FATAL EXCEPTION: main
                                                                         Process: sk.weyou.matej_kosut.sowosk, PID: 14788
                                                                         java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.firebase.iid.zzg' (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/sk.weyou.matej_kosut.sowosk-1/base.apk)
                                                                             at com.google.firebase.iid.zzg.zzeC(Unknown Source)
                                                                             at com.google.firebase.iid.zzg.<init>(Unknown Source)
                                                                             at com.google.firebase.iid.zzg.<init>(Unknown Source)
                                                                             at com.google.firebase.iid.zzd.zzb(Unknown Source)
                                                                             at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
                                                                             at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
                                                                             at com.google.firebase.messaging.FirebaseMessaging.getInstance(Unknown Source)
                                                                             at sk.weyou.matej_kosut.sowosk.login_reg.LoginService.onPostExecute(LoginService.java:148)
                                                                             at sk.weyou.matej_kosut.sowosk.login_reg.LoginService.onPostExecute(LoginService.java:37)
                                                                             at android.os.AsyncTask.finish(AsyncTask.java:632)
                                                                             at android.os.AsyncTask.access$600(AsyncTask.java:177)
                                                                             at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                             at android.os.Looper.loop(Looper.java:194)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5550)
                                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                                             at java.lang.reflect.Method.invoke(Method.java:372)
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)

在第

行使用firebase时
 FirebaseMessaging.getInstance().subscribeToTopic(" ");

我可能会想要那些旧版本。

或者我应该改变什么?我试图从星期一算出来。

1 个答案:

答案 0 :(得分:0)

您的编译SDK版本必须与支持库匹配,请尝试此操作 变化

buildToolsVersion "23.0.2"

buildToolsVersion "25.0.2"