0

首先,对不起,如果这是重复的,找不到正确的解决方案。我们在将 apk 发布到华为应用程序库时遇到问题。目前在华为 AppGalley 上可以看到支持 Google Play(早于 2019 年 5 月)的设备。我们有问题,在没有谷歌播放的较新设备上看不到相同的应用程序。什么可以解决它?尝试将 huawei repo 添加到所有项目 maven,我们添加了带有所需 deps 的 agconnect-services.json,但它不起作用。有什么建议,可能的解决方案吗?

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        google()
        maven { url 'http://developer.huawei.com/repo/' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:4.0.1'
        //android performanse
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
        classpath 'com.huawei.agconnect:agcp:1.2.0.300'


    }
}

allprojects {
    repositories {
        google()

        jcenter()

        maven {
            url "https://jitpack.io"

        }
maven { "https://maven.google.com"}
maven { url 'http://developer.huawei.com/repo/' }
  }
}

// build.gradle (app)

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'com.huawei.agconnect'


buildscript {

    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        // These docs use an open ended version so that our plugin
        // can be updated quickly in response to Android tooling updates

        // We recommend changing it to the latest version from our changelog:
        // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
        classpath 'io.fabric.tools:gradle:1.+'
    }

    ext.retrofit_version = "2.3.0"
    ext.ok_http_version = "3.9.1"
    ext.butterknife_version = "8.8.1"
    ext.dagger_version = "2.10"
    ext.timber_version = "4.5.1"
    ext.rx_java_version = "1.2.0"
    ext.rx_android_version = "1.2.1"
    ext.rx_binding_version = "3.0.0"
    ext.page_indicator_version = "0.2.0"
    ext.gson_version = "2.8.2"
    ext.glide_version = '3.7.0'
    ext.android_support_version = "28.0.0"
    ext.gsm_ads_version = "15.0.1"
    ext.firebase_perf_version = "16.0.0"
    ext.firebase_core_version = "16.0.1"
    ext.firebase_messenging_version = "17.0.0"
    ext.gsm_measurement_version = "16.0.0"
    ext.leak_cannary_version = "1.5.4"
    ext.auto_value_gson_version = "0.6.0"
    ext.auto_value_parcel_version = "0.2.5"
    ext.rx_java_proguard_version = "1.2.3.0"
    ext.javax_annotations_version = "1.0"
    ext.junit_version = "4.12"
    ext.espresso_version = "2.2.2"
    ext.hamcrest_version = "1.3"
    ext.roboelectric_version = "3.3.2"
    ext.mockito_version = "2.6.4"
    ext.job_dispatcher_version = "0.8.5"
    ext.crashanalitycs_version = "2.9.3"
    ext.autoservice_version = "1.0-rc3"
    ext.constaint_layout_version = "1.1.2"
    ext.chip_layout_manager = "0.3.7"
    ext.multidex_version = "1.0.3"
    ext.huawei_hwid_version = "4.0.0.300"
    ext.didomi_version = "1.10.9"
}


android {
    compileSdkVersion 29
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId "app package"
        minSdkVersion 22
        targetSdkVersion 29
        versionCode 29
        versionName "1.2.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    defaultConfig {
        ...
        ndk {
            abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
        }

    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildTypes {

        debug {

            ...
        }
        release {
            ...
        }
    }
    flavorDimensions "ads"

    productFlavors { ...}
    packagingOptions {
        exclude 'META-INF/proguard/androidx-annotations.pro'
    }

}

allprojects {
    repositories {
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(":DotmetricsSDK.Android")
    implementation "com.android.support:multidex:$multidex_version"
    implementation "com.romandanylyk:pageindicatorview:$page_indicator_version"
    implementation "com.google.dagger:dagger:$dagger_version"
    implementation "com.jakewharton:butterknife:$butterknife_version"
    implementation "com.android.support.constraint:constraint-layout:$constaint_layout_version"
    annotationProcessor "com.jakewharton:butterknife-compiler:$butterknife_version"
    annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
    implementation "com.jakewharton.timber:timber:$timber_version"
    implementation "io.reactivex:rxandroid:$rx_android_version"
    implementation "com.jakewharton.rxbinding3:rxbinding:$rx_binding_version"
    implementation "io.reactivex:rxjava:$rx_java_version"
    implementation "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
    implementation "com.squareup.okhttp3:okhttp-urlconnection:$ok_http_version"
    implementation "com.squareup.okhttp3:logging-interceptor:$ok_http_version"
    implementation("com.squareup.retrofit2:converter-simplexml:$retrofit_version") {
        exclude group: 'xpp3', module: 'xpp3'
        exclude group: 'stax', module: 'stax-api'
        exclude group: 'stax', module: 'stax'
    }
    implementation "com.google.code.gson:gson:$gson_version"
    implementation "com.android.support:appcompat-v7:$android_support_version"
    implementation "com.android.support:design:$android_support_version"
    implementation "com.google.firebase:firebase-core:$firebase_core_version"
    implementation "com.google.firebase:firebase-messaging:$firebase_messenging_version"
    implementation "com.google.firebase:firebase-perf:$firebase_perf_version"
    implementation "com.google.android.gms:play-services-ads:$gsm_ads_version"
    testCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_cannary_version"
    debugCompile "com.squareup.leakcanary:leakcanary-android:$leak_cannary_version"
    releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_cannary_version"
    testCompile 'junit:junit:4.12'
    annotationProcessor "com.google.auto.service:auto-service:$autoservice_version"
    provided("com.ryanharter.auto.value:auto-value-gson:$auto_value_gson_version") {
        exclude group: 'com.google.auto.service', module: 'auto-service'
    }
    annotationProcessor("com.ryanharter.auto.value:auto-value-gson:$auto_value_gson_version") {
        exclude group: 'com.google.auto.service', module: 'auto-service'
    }
    annotationProcessor("com.ryanharter.auto.value:auto-value-parcel:$auto_value_parcel_version") {
        exclude group: 'com.google.auto.service', module: 'auto-service'
    }
    //Glide
    implementation "com.github.bumptech.glide:glide:$glide_version"
    //GEMIUS
    implementation(name: 'GemiusSDK_1.3.3', ext: 'aar')
    provided "javax.annotation:jsr250-api:$javax_annotations_version"
    //ProGuard rules for RxJava!
    implementation "com.artemzin.rxjava:proguard-rules:$rx_java_proguard_version"

    implementation "com.firebase:firebase-jobdispatcher:$job_dispatcher_version"

    implementation("com.crashlytics.sdk.android:crashlytics:$crashanalitycs_version@aar") {
        transitive = true
    }
    implementation "com.beloo.widget:ChipsLayoutManager:$chip_layout_manager"

    implementation "com.huawei.hms:hwid:$huawei_hwid_version"

    implementation "io.didomi.sdk:android:$didomi_version"

    testImplementation "junit:junit:$junit_version"
    // Set this dependency if you want to use Hamcrest matching
    testImplementation "org.hamcrest:hamcrest-library:$hamcrest_version"
    testImplementation "org.robolectric:robolectric:$roboelectric_version"
    testImplementation "org.mockito:mockito-core:$mockito_version"
    androidTestImplementation("com.android.support.test.espresso:espresso-core:$espresso_version", {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude(group: 'com.google.code.findbugs', module: 'jsr305')
    })
    androidTestImplementation("com.android.support.test.espresso:espresso-contrib:$espresso_version") {
        // Necessary to avoid version conflicts
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude(group: 'com.google.code.findbugs', module: 'jsr305')
        exclude module: 'recyclerview-v7'
    }
}
apply plugin: 'com.google.gms.google-services'

//AndroidManifest

<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="hr.index.indexme">
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
   <uses-permission android:name="android.permission.INTERNET" />
   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.WAKE_LOCK" />
   <!-- This is needed because of dotmetrics -->
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" tools:node="remove" />
   <application android:name=".App" android:allowBackup="true" android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:networkSecurityConfig="@xml/network_config" android:usesCleartextTraffic="true" android:theme="@style/AppTheme">
      <uses-library android:name="org.apache.http.legacy" android:required="false" />
      <activity android:name=".splash.activity.view.SplashActivity" android:screenOrientation="portrait" android:theme="@style/SplashTheme">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
      <activity android:name=".main.activity.view.MainActivity" android:launchMode="singleTask" android:screenOrientation="portrait" />
      <activity android:name=".article.activity.gallery.view.ArticleActivity" android:screenOrientation="portrait" android:launchMode="singleTop" android:taskAffinity="index.article" />
      <activity android:name=".walkthrough.activity.view.WalkthroughActivity" android:screenOrientation="portrait" />
      <activity android:name=".search.view.SearchActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysVisible|adjustPan" />
      <activity android:name=".settings.activity.view.SettingsActivity" android:screenOrientation="portrait" />
      <activity android:name=".tag.list.view.TagListActivity" android:screenOrientation="portrait" />
      <activity android:name=".terms.view.TermsActivity" android:screenOrientation="portrait" />
      <activity android:name=".contact.view.ContactActivity" android:windowSoftInputMode="adjustPan" android:screenOrientation="portrait" />
      <activity android:name=".weather.view.WeatherActivity" android:screenOrientation="portrait" />
      <activity android:name=".sendNews.activity.view.SendNewsActivity" android:screenOrientation="portrait" />
      <activity android:name=".comments.activity.view.CommentsActivity" android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize" />
      <activity android:name=".article.activity.single.view.SingleArticleActivity" android:screenOrientation="portrait" />
      <service android:name=".base.service.UploadService" />
      <service android:name=".fcm.IndexFirebaseInstanceIDService">
         <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
         </intent-filter>
      </service>
      <service android:name=".fcm.IndexFirebaseMessagingService">
         <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
         </intent-filter>
      </service>
      <service android:name=".breaking_news.service.BreakingNewsJobService" android:exported="false">
         <intent-filter>
            <action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE" />
         </intent-filter>
      </service>
      <meta-data android:name="io.fabric.ApiKey" android:value="api key" />
      <activity android:name=".tag.settings.view.TagSettingsActivity" />
      <activity android:name=".tag.search.view.TagSearchActivity" android:label="@string/title_activity_tag_search" android:theme="@style/AppTheme" />
      <activity android:name="dotmetrics.analytics.UrlCatchActivity">
         
    
         <intent-filter tools:ignore="AppLinkUrlError">
            
    
            <action android:name="android.intent.action.VIEW" />
            
    
    
            <category android:name="android.intent.category.DEFAULT" />
            
    
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:host="hr.index.indexme" android:scheme="dotmetrics" />
            
    
         </intent-filter>
      </activity>
   </application>
</manifest>
4

2 回答 2

0

这应该是您将应用发布到华为 AppGallery 时的审核政策。
如果您的应用有一些依赖于 Google Play 服务,那么它将无法在没有 Google Play 服务的华为设备上运行;它会崩溃或显示所需的 Google Play 服务对话框。

为了解决这个问题,有必要;
1- 从 HMS Core(例如 FCM 到 Huawei Push)和 AppGallery Connect(Crashlytics 到 Huawei Crash)实现相同的服务
2- 仅使用 HMS 依赖项构建一个新的独立 APK,或者在您的 APK 中实现一个包装器根据设备上的服务可用性使用 Google 的库或 HMS

或者,您可以选择不依赖 Google Play 服务的服务

于 2020-04-26T17:05:46.383 回答
0

您的应用程序仅对具有 GMS 的设备可见,因为您正在使用一些 Google 的库,这些库不适用于只有 HMS 的华为设备。

只有较旧的华为手机有 GMS。

要修复它,您必须:

  1. 实施华为的工具包(你拥有的谷歌库的替代品)。
  2. 在代码中调用谷歌函数和华为支持函数的地方设置 if-else 条件。
  3. 测试应用并提交到 AppGallery。

它是这样工作的:

  1. 应用程序在只有 HMS 的手机上运行良好吗?
    • 是的?将其标记为对具有相同 HMS 的手机可见。
    • 不?将其标记为对于具有相同 HMS 的手机不可见。
  2. 应用程序在具有 GMS 的手机上运行良好吗?
    • 是的?将其标记为对带有 GMS 的手机可见。
    • 不?拒绝该应用程序,因为它根本不起作用。

请查看这个答案:项目中同时拥有 GMS 和 HMS

于 2020-03-26T20:14:26.250 回答