7

Hôm nay tôi đã cập nhật tất cả thư viện hỗ trợ và công cụ xây dựng của mình lên phiên bản mới nhất để hỗ trợ Android N. Khi tôi cập nhật mọi thứ và chạy ứng dụng, tôi gặp lỗi trong phương pháp thế hệ của GCM trong ứng dụng của mình. Vì vậy, tôi đã tìm kiếm và tìm thấy các giải pháp đề xuất cập nhật dịch vụ phát. Sau khi theo dõi tất cả các câu hỏi và câu trả lời của SO, tôi bị kẹt và không thể tiến lên phía trước. Chuyển trở lại thư viện hỗ trợ 23.x.x không phải là tùy chọn vì tôi muốn nhắm mục tiêu Android N.Không thể giải quyết: com.google.android.gms: play-services-measurement: 9.6.1

Sau đây là cách cấp dự án của tôi build.gradle file tìm kiếm:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.0' 
     classpath 'com.google.gms:google-services:3.0.0' 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

App mức build.gradle:

buildscript { 
    repositories { 
     mavenCentral() 
     maven { url 'https://maven.fabric.io/public' } 
//  maven { url 'http://hansel.io/maven' } 
     maven { 
      url "https://jitpack.io" 
     } 
    } 

    dependencies { 
     classpath 'io.fabric.tools:gradle:1.+' 
//  classpath 'io.hansel.preprocessor:preprocessor:1.0.+' 
    } 
} 


apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 
//apply plugin: 'io.hansel.preprocessor' 


android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.2" 
    signingConfigs { 

    } 
    defaultConfig { 
     applicationId 'com.example.android' 
     multiDexEnabled true 
     minSdkVersion 16 
     targetSdkVersion 24 
     versionCode 47 
     versionName "1.3.2" 
     renderscriptTargetApi 24 
     renderscriptSupportModeEnabled true 
    } 
    buildTypes { 
     debug { 
      applicationIdSuffix = ".dev" 
      resValue "string", "app_name", "example-debug" 
     } 
     release { 
      minifyEnabled false 
      shrinkResources false 
      resValue "string", "app_name", "example" 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    productFlavors { 
     dev { 
      // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin 
      // to pre-dex each module and produce an APK that can be tested on 
      // Android Lollipop without time consuming dex merging processes. 
      minSdkVersion 21 
     } 
     prod { 
      // The actual minSdkVersion for the application. 
      minSdkVersion 16 
     } 
    } 
    dexOptions { 
     javaMaxHeapSize "4g" 
    } 
} 

repositories { 
    mavenCentral() 
    mavenLocal() 
    jcenter() 
    maven { url 'https://maven.fabric.io/public' } 
    maven { url "https://jitpack.io" } 
// maven { url 'http://hansel.io/maven' } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:appcompat-v7:24.2.1' 
    compile 'com.android.support:support-v4:24.2.1' 
    compile 'com.android.support:support-annotations:24.2.1' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.android.support:design:24.2.1' 
    compile 'com.facebook.android:facebook-android-sdk:4.3.0' 
    compile 'com.squareup.okhttp:okhttp:2.4.0' 
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' 
    compile 'com.android.support:recyclerview-v7:24.2.1' 
    compile 'com.android.support:cardview-v7:24.2.1' 
    compile 'com.squareup.retrofit:retrofit:1.9.0' 
    compile 'com.jakewharton:butterknife:7.0.1' 
    compile 'com.github.clans:fab:1.6.1' 
    compile 'com.facebook.fresco:fresco:0.8.1+' 
    compile 'com.facebook.fresco:imagepipeline-okhttp:0.8.1+' 
    compile 'uk.co.chrisjenx:calligraphy:2.1.0' 
    compile 'com.google.android.gms:play-services-analytics:9.6.1' 
    compile 'com.google.android.gms:play-services-location:9.6.1' 
    compile 'com.google.android.gms:play-services-gcm:9.6.1' 
    compile 'com.google.android.gms:play-services-measurement:9.6.1' 
    compile 'com.github.liuguangqiang.swipeback:library:[email protected]' 
    compile 'me.imid.swipebacklayout.lib:library:1.0.0' 
    compile 'com.github.2359media:EasyAndroidAnimations:0.8' 
    compile 'com.theartofdev.edmodo:android-image-cropper:2.0.+' 
    compile 'com.wang.avi:library:1.0.1' 
    compile 'com.nineoldandroids:library:2.4.0' 
    compile 'com.mixpanel.android:mixpanel-android:4.6.4' 
    compile 'com.github.ppamorim:dragger:1.2' 
    compile 'io.reactivex:rxandroid:1.1.0' 
    compile 'io.reactivex:rxjava:1.1.3' 
    compile 'com.jakewharton.rxbinding:rxbinding:0.2.0' 
// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2' 
// releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2' 
    compile 'com.bignerdranch.android:expandablerecyclerview:2.1.1' 
    compile 'com.android.support:multidex:1.0.1' 
    compile 'com.birbit:android-priority-jobqueue:2.0.0' 
    compile 'com.squareup:otto:1.3.8' 
    compile 'com.mikhaellopez:circularprogressbar:1.1.1' 
    compile 'com.github.dotloop:aosp-exif:be25ae51ec' 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     exclude group: 'com.squareup.okhttp', module: 'okhttp' 
     transitive = true; 
    } 
} 
apply plugin: 'com.google.gms.google-services' 

Và đây là lỗi Tôi nhận: enter image description here

Bất kỳ trợ giúp sẽ được đánh giá cao. Cảm ơn.

Sửa

dịch vụ google play của tôi cũng được cập nhật. enter image description here

Trả lời

2

Cuối cùng, tôi đã tự giải quyết. Dưới đây là những gì tôi đã làm:

  1. Removed compile 'com.google.android.gms:play-services-measurement:9.6.1' và sau đó biên soạn dự án
  2. Nó cung cấp cho missing api_key errorGCM đã chuyển sang Firebase và do đó các tập tin google-services.json không hoạt động
  3. Để sửa lỗi này, bạn chỉ cần cập nhật các google-services.json tệp với tệp được tạo mới sử dụng tính năng Nhắn tin qua đám mây từ Firebase
  4. Sau này, tôi đã biên dịch và có lỗi khác là thiếu @drawable/powered_by_google_dark từ dự án vì tôi đang sử dụng API Tự động hoàn thành địa điểm. Để khắc phục điều này, hãy thêm compile 'com.google.android.gms:play-services-places:9.6.0' vào các phụ thuộc
2

Bạn không có dịch vụ Google Play mới nhất, chỉ cần nhấp vào liên kết và studio android sẽ cung cấp hộp thoại để cài đặt.

+3

Tôi đã nhấp vào liên kết, không có gì đang diễn ra. –

+0

Bạn đã thử sử dụng 9.6.0 thay vì 9.6.1. Tôi không nghĩ rằng có một 9.6.1 chưa – sativa

+0

Tôi đã thử, cùng một vấn đề. –

1

Đặt tất cả phụ thuộc dịch vụ phát thành 9.6.0. 9.6.1 chưa phát hành. Nếu sự cố vẫn xảy ra, hãy cài đặt dịch vụ và kho lưu trữ google play mới nhất trong studio android của bạn.

+0

Tôi đã thay đổi tất cả các phụ thuộc thành 9.6.0 nhưng tôi vẫn gặp lỗi tương tự. Ngoài ra, dịch vụ chơi của tôi cũng được cập nhật. Xem chỉnh sửa. –

+1

cố gắng thay đổi dòng này trong cấp dự án của bạn build.gradle 'classpath 'com.google.gms: google-services: 3.0.0'' đến 'classpath 'com.google.gms: google-services: 2.1.0''. tìm thấy điều này từ tham chiếu [this] (https://github.com/googlesamples/google-services/issues/229). –

+0

Vẫn còn vấn đề tương tự. –

5

Hôm nay tôi đã có cùng một vấn đề. Điều này giải quyết được vấn đề cho tôi:

Mở trình quản lý SDK Android độc lập. Trong phần Extras, "Google Play Services" có phiên bản mới nhất, nhưng "Google Repository" sau khi cập nhật "Google Repository" từ phiên bản 33 lên 35, vấn đề đã biến mất.

+0

Tôi gặp sự cố tương tự ... đã xảy ra lỗi khi nâng cấp Android/Studio và SDK. Khi tôi quay trở lại SDK Manager, cả hai 'Google Play Services' và 'Google Repository' đều không được cài đặt. Sau khi cài đặt lại, mọi thứ hoạt động tốt. – tir38

Các vấn đề liên quan