Android App asking for Google Mobile services on Huawei phones

1.2k Views Asked by At

I am working on an android app that requires location and maps to be implemented in. for mobiles with Google support I was able to use the google play services and everything is working as supposed to.

Now come the problem with Huawei devices with no GMS support. I am using HMS as described and the app starts. but after a while a message saying that this app requires Google services to run and the app stops responding (app running in the background but no buttons can be pressed even if I force kill the app and restart it.

I started using the "Check API Availability" function in GMS it returned false and that is how I go to HMS.

So I tried another approach by creating a separate app for the Huawei devices and remove any GMS requirements. Yet again I am also getting that the app requires GMS.

I am attaching my build.gradle and manifest:

gradle file:

apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'  // HUAWEI agconnect Gradle plugin


android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "******"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 2
        versionName "1.1"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++14"
            }
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    signingConfigs {
        release {
            storeFile file('***.jks')
            keyAlias '***'
            keyPassword '***'
            storePassword '***'
            v2SigningEnabled true
        }
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug {
            signingConfig signingConfigs.release
            debuggable true
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = [
                    "src/main/cppLibs/Poco/lib"
            ]
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.2.2'
    implementation 'androidx.navigation:navigation-ui:2.2.2'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'com.android.support:design:29.1.0'

    implementation 'com.huawei.hms:maps:5.0.1.300'
    implementation 'com.huawei.hms:location:4.0.3.301'

    implementation 'org.apache.commons:commons-io:1.3.2'
    implementation 'com.yinglan.shadowimageview:shadowimageview:1.0.4'
    implementation 'com.github.kenglxn.QRGen:android:2.6.0'
    implementation 'org.altbeacon:android-beacon-library:2.16.+'
    implementation 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'

}

and my manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="***">



    <uses-feature
        android:name="android.hardware.bluetooth_le"
        android:required="true" />
    <uses-feature android:name="android.hardware.location.gps" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA" />


    <application
        android:name=".Application"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:requestLegacyExternalStorage="true"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <uses-library
            android:name="org.apache.http.legacy"
            android:required="false" />

       .
       .
       .
       Bunch of Activities
       .
       .
       .
        <service
            android:name="*****"
            android:enabled="true"
            android:exported="true" />

       
        <activity
            android:name=".MainActivity"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver
            android:name=".Service.RebootReceiver"
            android:enabled="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
                <action android:name="android.intent.action.REBOOT" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

I even used Huawei HMS toolkit plugin to convert and it told me there is no GMS. where is that message coming from and why it is blocking my UI.

---EDIT----

Added the Project gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'http://developer.huawei.com/repo/' }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files




classpath 'com.huawei.agconnect:agconnect-apms-plugin:1.3.1.300'
classpath 'com.huawei.agconnect:agcp:1.3.1.300'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'http://developer.huawei.com/repo/' }
        maven { url "https://jitpack.io" }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

-----EDIT 2------ Following m0skit0 advice i did dependency check and this is the result

.
.
.

lintClassPath - The lint embedded classpath
\--- com.android.tools.lint:lint-gradle:26.5.3
     +--- com.android.tools:sdk-common:26.5.3
     |    +--- com.android.tools:sdklib:26.5.3
     |    |    +--- com.android.tools.layoutlib:layoutlib-api:26.5.3
     |    |    |    +--- com.android.tools:common:26.5.3
     |    |    |    |    +--- com.android.tools:annotations:26.5.3
     |    |    |    |    +--- com.google.guava:guava:27.0.1-jre
     |    |    |    |    |    +--- com.google.guava:failureaccess:1.0.1
     |    |    |    |    |    +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
     |    |    |    |    |    +--- com.google.code.findbugs:jsr305:3.0.2
     |    |    |    |    |    +--- org.checkerframework:checker-qual:2.5.2
     |    |    |    |    |    +--- com.google.errorprone:error_prone_annotations:2.2.0
     |    |    |    |    |    +--- com.google.j2objc:j2objc-annotations:1.1
     |    |    |    |    |    \--- org.codehaus.mojo:animal-sniffer-annotations:1.17
     |    |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50
     |    |    |    |         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50
     |    |    |    |         |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50
     |    |    |    |         |    \--- org.jetbrains:annotations:13.0
     |    |    |    |         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50
     |    |    |    |              \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
     |    |    |    +--- net.sf.kxml:kxml2:2.3.0
     |    |    |    +--- com.android.tools:annotations:26.5.3
     |    |    |    \--- org.jetbrains:annotations:13.0
     |    |    +--- com.android.tools:dvlib:26.5.3
     |    |    |    \--- com.android.tools:common:26.5.3 (*)
     |    |    +--- com.android.tools:repository:26.5.3
     |    |    |    +--- com.android.tools:common:26.5.3 (*)
     |    |    |    +--- com.sun.activation:javax.activation:1.2.0
     |    |    |    +--- org.apache.commons:commons-compress:1.12
     |    |    |    +--- org.glassfish.jaxb:jaxb-runtime:2.2.11
     |    |    |    |    +--- org.glassfish.jaxb:jaxb-core:2.2.11
     |    |    |    |    |    +--- javax.xml.bind:jaxb-api:2.2.12-b140109.1041
     |    |    |    |    |    +--- org.glassfish.jaxb:txw2:2.2.11
     |    |    |    |    |    \--- com.sun.istack:istack-commons-runtime:2.21
     |    |    |    |    +--- org.jvnet.staxex:stax-ex:1.7.7
     |    |    |    |    \--- com.sun.xml.fastinfoset:FastInfoset:1.2.13
     |    |    |    +--- com.google.jimfs:jimfs:1.1
     |    |    |    |    \--- com.google.guava:guava:18.0 -> 27.0.1-jre (*)
     |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 (*)
     |    |    +--- com.google.code.gson:gson:2.8.5
     |    |    +--- org.apache.commons:commons-compress:1.12
     |    |    +--- org.apache.httpcomponents:httpmime:4.5.6
     |    |    |    \--- org.apache.httpcomponents:httpclient:4.5.6
     |    |    |         +--- org.apache.httpcomponents:httpcore:4.4.10
     |    |    |         +--- commons-logging:commons-logging:1.2
     |    |    |         \--- commons-codec:commons-codec:1.10
     |    |    \--- org.apache.httpcomponents:httpcore:4.4.10
     |    +--- com.android.tools.build:builder-test-api:3.5.3
     |    |    \--- com.android.tools.ddms:ddmlib:26.5.3
     |    |         +--- com.android.tools:common:26.5.3 (*)
     |    |         \--- net.sf.kxml:kxml2:2.3.0
     |    +--- com.android.tools.build:builder-model:3.5.3
     |    |    \--- com.android.tools:annotations:26.5.3
     |    +--- com.android.tools.ddms:ddmlib:26.5.3 (*)
     |    +--- com.android.tools.analytics-library:shared:26.5.3
     |    |    +--- com.android.tools.analytics-library:protos:26.5.3
     |    |    |    \--- com.google.protobuf:protobuf-java:3.4.0
     |    |    +--- com.android.tools:annotations:26.5.3
     |    |    +--- com.android.tools:common:26.5.3 (*)
     |    |    +--- com.google.guava:guava:27.0.1-jre (*)
     |    |    +--- com.google.code.gson:gson:2.8.5
     |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 (*)
     |    +--- org.bouncycastle:bcpkix-jdk15on:1.56
     |    |    \--- org.bouncycastle:bcprov-jdk15on:1.56
     |    +--- org.bouncycastle:bcprov-jdk15on:1.56
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 (*)
     |    +--- org.jetbrains.kotlin:kotlin-reflect:1.3.50
     |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
     |    +--- com.google.protobuf:protobuf-java:3.4.0
     |    +--- javax.inject:javax.inject:1
     |    +--- org.jetbrains.trove4j:trove4j:20160824
     |    \--- com.android.tools.build:aapt2-proto:0.4.0
     |         \--- com.google.protobuf:protobuf-java:3.4.0
     +--- com.android.tools.build:builder:3.5.3
     |    +--- com.android.tools.build:builder-model:3.5.3 (*)
     |    +--- com.android.tools.build:builder-test-api:3.5.3 (*)
     |    +--- com.android.tools:sdklib:26.5.3 (*)
     |    +--- com.android.tools:sdk-common:26.5.3 (*)
     |    +--- com.android.tools:common:26.5.3 (*)
     |    +--- com.android.tools.build:manifest-merger:26.5.3
     |    |    +--- com.android.tools:common:26.5.3 (*)
     |    |    +--- com.android.tools:sdklib:26.5.3 (*)
     |    |    +--- com.android.tools:sdk-common:26.5.3 (*)
     |    |    +--- com.google.code.gson:gson:2.8.5
     |    |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 (*)
     |    |    \--- net.sf.kxml:kxml2:2.3.0
     |    +--- com.android.tools.ddms:ddmlib:26.5.3 (*)
     |    +--- com.android.tools.analytics-library:protos:26.5.3 (*)
     |    +--- com.android.tools.analytics-library:tracker:26.5.3
     |    |    +--- com.android.tools:annotations:26.5.3
     |    |    +--- com.android.tools:common:26.5.3 (*)
     |    |    +--- com.android.tools.analytics-library:protos:26.5.3 (*)
     |    |    +--- com.android.tools.analytics-library:shared:26.5.3 (*)
     |    |    +--- com.google.protobuf:protobuf-java:3.4.0
     |    |    +--- com.google.guava:guava:27.0.1-jre (*)
     |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 (*)
     |    +--- com.android.tools.build:apksig:3.5.3
     |    +--- com.android.tools.build:apkzlib:3.5.3
     |    |    +--- com.google.code.findbugs:jsr305:1.3.9 -> 3.0.2
     |    |    +--- com.google.guava:guava:23.0 -> 27.0.1-jre (*)
     |    |    +--- org.bouncycastle:bcpkix-jdk15on:1.56 (*)
     |    |    +--- org.bouncycastle:bcprov-jdk15on:1.56
     |    |    \--- com.android.tools.build:apksig:3.5.3
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 (*)
     |    +--- com.squareup:javawriter:2.5.0
     |    +--- org.bouncycastle:bcpkix-jdk15on:1.56 (*)
     |    +--- org.bouncycastle:bcprov-jdk15on:1.56
     |    +--- org.ow2.asm:asm:6.0
     |    +--- org.ow2.asm:asm-tree:6.0
     |    |    \--- org.ow2.asm:asm:6.0
     |    +--- javax.inject:javax.inject:1
     |    +--- org.ow2.asm:asm-commons:6.0
     |    |    \--- org.ow2.asm:asm-tree:6.0 (*)
     |    +--- org.ow2.asm:asm-util:6.0
     |    |    \--- org.ow2.asm:asm-tree:6.0 (*)
     |    +--- it.unimi.dsi:fastutil:7.2.0
     |    +--- net.sf.jopt-simple:jopt-simple:4.9
     |    \--- com.googlecode.json-simple:json-simple:1.1
     +--- com.android.tools.build:builder-model:3.5.3 (*)
     +--- com.android.tools.external.com-intellij:intellij-core:26.5.3
     |    \--- org.jetbrains.trove4j:trove4j:20160824
     +--- com.android.tools.external.com-intellij:kotlin-compiler:26.5.3
     +--- com.android.tools.external.org-jetbrains:uast:26.5.3
     +--- com.android.tools.build:manifest-merger:26.5.3 (*)
     +--- com.android.tools.lint:lint:26.5.3
     |    +--- com.android.tools.lint:lint-checks:26.5.3
     |    |    +--- com.android.tools.lint:lint-api:26.5.3
     |    |    |    +--- com.android.tools:sdk-common:26.5.3 (*)
     |    |    |    +--- com.android.tools.build:builder-model:3.5.3 (*)
     |    |    |    +--- com.google.guava:guava:27.0.1-jre (*)
     |    |    |    +--- com.android.tools.external.com-intellij:intellij-core:26.5.3 (*)
     |    |    |    +--- com.android.tools.external.com-intellij:kotlin-compiler:26.5.3
     |    |    |    +--- com.android.tools.external.org-jetbrains:uast:26.5.3
     |    |    |    +--- com.android.tools.build:manifest-merger:26.5.3 (*)
     |    |    |    +--- org.ow2.asm:asm:6.0
     |    |    |    +--- org.ow2.asm:asm-tree:6.0 (*)
     |    |    |    +--- org.jetbrains.kotlin:kotlin-reflect:1.3.50 (*)
     |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 (*)
     |    |    +--- com.google.guava:guava:27.0.1-jre (*)
     |    |    +--- com.android.tools.external.com-intellij:intellij-core:26.5.3 (*)
     |    |    +--- com.android.tools.external.com-intellij:kotlin-compiler:26.5.3
     |    |    +--- com.android.tools.external.org-jetbrains:uast:26.5.3
     |    |    \--- org.ow2.asm:asm-analysis:6.0
     |    |         \--- org.ow2.asm:asm-tree:6.0 (*)
     |    +--- com.google.guava:guava:27.0.1-jre (*)
     |    +--- com.android.tools.external.org-jetbrains:uast:26.5.3
     |    +--- com.android.tools.external.com-intellij:kotlin-compiler:26.5.3
     |    +--- com.android.tools.build:manifest-merger:26.5.3 (*)
     |    +--- com.android.tools.analytics-library:shared:26.5.3 (*)
     |    +--- com.android.tools.analytics-library:protos:26.5.3 (*)
     |    +--- com.android.tools.analytics-library:tracker:26.5.3 (*)
     |    +--- org.jetbrains.kotlin:kotlin-reflect:1.3.50 (*)
     |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 (*)
     +--- com.android.tools.lint:lint-gradle-api:26.5.3
     |    +--- com.android.tools:sdklib:26.5.3 (*)
     |    +--- com.android.tools.build:builder-model:3.5.3 (*)
     |    +--- com.android.tools.build:gradle-api:3.5.3
     |    |    +--- com.android.tools.build:builder-model:3.5.3 (*)
     |    |    +--- com.android.tools.build:builder-test-api:3.5.3 (*)
     |    |    +--- com.google.guava:guava:27.0.1-jre (*)
     |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 (*)
     |    +--- org.jetbrains.kotlin:kotlin-reflect:1.3.50 (*)
     |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 (*)
     |    \--- com.google.guava:guava:27.0.1-jre (*)
     +--- org.codehaus.groovy:groovy-all:2.4.15
     +--- org.jetbrains.kotlin:kotlin-reflect:1.3.50 (*)
     \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50 (*)
.
.
.
.

I can see many google dependencies but non mentioned as google play (mainly in the QR generation library.) might those be the reason? is anything related to google not working on huawei?

1

There are 1 best solutions below

0
On

When we performed a test using the Gradle dependencies that you provided, we were not asked for GMS. We think that:

  1. Our test did not call the libraries in your project for generating QR codes but these libraries may depend on GMS. You can use HUAWEI Scan Kit to generate QR codes. It does not depend on HMS or GMS and can run on any devices.

  2. You may have other local dependencies in the libs folder, or some C++ SDKs depend on GMS. You can remove them and try again.