当前位置: 首页 > 知识库问答 >
问题:

在华为手机上请求谷歌移动服务的Android应用

毛勇
2023-03-14

我在附上我的建筑。gradle和manifest:

分级文件:

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'

}

和我的清单文件:

<?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>
// 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
}
.
.
.

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 (*)
.
.
.
.

我可以看到很多google依赖项,但没有提到google play(主要在QR生成库中)这可能是原因吗?与谷歌不在华为工作有关吗?

共有1个答案

孔茂
2023-03-14

当我们使用您提供的Gradle依赖项执行测试时,我们没有被要求使用GMS。我们认为:

>

  • 我们的测试没有调用项目中的库来生成QR码,但这些库可能依赖于GMS。您可以使用华为扫描套件生成二维码。它不依赖于HMS或GMS,可以在任何设备上运行。

    在libs文件夹中可能有其他本地依赖项,或者一些C++SDK依赖于GMS。您可以删除它们,然后再试一次。

  •  类似资料:
    • 我已经升级了我的应用程序以支持SDK26,现在Google Analytics在Android Oreo上运行时会导致崩溃: 致命异常:java.lang.RuntimeException:无法启动接收方com.google.android.gms.analytics.analyticsReceiver:java.lang.IllegalStateException:不允许启动服务意图{act=c

    • 我们使用Google登录来获取GoogleAccountCredential,因为我们调用了Drive/Sheets API: 哪些是可以使用前面提到的API安装在新的华为设备中(没有谷歌Play服务)并获得必要的凭据的替代方案?

    • 在GAE中,我只使用默认域名:https://*。appspot。com,所以我不需要生成自签名证书。 谷歌应用程序引擎文档指定应用程序的运行方式。yaml应配置为服务于SSL连接: https://cloud.google.com/appengine/docs/standard/go/config/appref#handlers_secure 但为了在Go中提供HTTPS连接,我编写了以下代码示

    • 我正在尝试用新的Android Studio测试Google Play服务。我有一个依赖于google_play_服务的项目。罐子但是,当我尝试重建项目时,会出现以下错误: 它似乎有两个BuildConfig文件和两个R类。我如何解决这个问题? 编辑: 我注意到编译器编译了两个R.java文件:一个在我的项目文件夹中,另一个在文件夹%USERPROFILE%中。AndroidStudioPrevi

    • 最终解决方案 我只是个白痴。增加版本后的真正问题是,我已经应用了插件而不是在文件末尾。检查这个主题,我之前搜索得很糟糕 原始问题 我从来都不明白Gradle是怎么工作的,很抱歉问了一些愚蠢的问题。 我正面临一个问题,我不知道问题出在哪里,也不知道现在该怎么办。我有GCM的应用程序,一切都很好,直到我们添加了第二语言的应用程序。 然后我得到一个错误,即< code>google_app_id没有被翻

    • 我正在获取一条消息,通过gmail API获取完整消息: 我正在传递一条有效的消息。Id号 谷歌。GoogleApiException:“谷歌。API。请求。请求错误 找不到[404] 谷歌。应用程序。请求。请求错误未找到[404]错误[消息[未找到]位置[-]原因[未找到]域[全局]] 这里还有一个问题 有人遇到过这个吗?