首页 > 解决方案 > AutocompleteSupportFragment 显示我有时无法在 kotlin android 中加载搜索

问题描述

我在我的 kotlin android 应用程序中使用 AutocompleteSupportFragment 来使用地名、经度和纬度,这有时会显示错误“未找到搜索”,但有时它可以完美运行。当我阅读谷歌文档时,它要求我附加支付账户并更新 gradle 等。我已经使用这个 api 附加了支付账户,但现在它再次向我显示“未找到搜索”的错误。现在我尝试更新我的项目库和代码。当我使用下面给出的这个库时:

implementation 'com.google.android.libraries.places:places:1.0.0'

它工作得很好,但是当我用更新的库更新我的 gradle 时,即:

 implementation 'com.google.android.libraries.places:places:2.2.0'

编译器向我显示要添加的错误

tools:replace="android:appComponentFactory"

但又一次向我显示错误

Merging Errors: Error: tools:replace specified at line:14 for attribute android:appComponentFactory, but no new value specified app main manifest (this file), line 13 Error: Validation failed, exiting app main manifest (this file)

现在我可以和你分享我的文件了这是我的 manifestMerger

<?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="com.sprintsolutions.petsbuyandsell">

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>


    <application
            tools:replace="android:appComponentFactory"
            android:allowBackup="false"
            android:icon="@mipmap/icon"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/icon"
            android:usesCleartextTraffic="true"
            android:supportsRtl="true"
            android:largeHeap="true"
            android:hardwareAccelerated="false"
            android:theme="@style/AppTheme">

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


        <activity android:name="com.sprintsolutions.petsbuyandsell.ContactUsActivity"
                  android:screenOrientation="portrait"/>

        <activity
                android:name="com.sprintsolutions.petsbuyandsell.AboutUsActivity"
                android:screenOrientation="portrait">

        </activity>

        <activity android:name="com.sprintsolutions.petsbuyandsell.FullImageActivity"
                  android:screenOrientation="portrait"/>

        <activity
                android:name="com.sprintsolutions.petsbuyandsell.ForgetPasswordActivity"
                android:screenOrientation="portrait"/>
        <activity
                android:name="com.sprintsolutions.petsbuyandsell.SplashActivity"
                android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity
                android:name="com.sprintsolutions.petsbuyandsell.SignUpActivity"
                android:screenOrientation="portrait">
        </activity>
        <activity
                android:name="com.sprintsolutions.petsbuyandsell.MainActivity"
                android:screenOrientation="portrait"
                android:windowSoftInputMode="adjustPan|stateHidden"/>
        <activity
                android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
                android:theme="@style/Base.Theme.AppCompat"/>
        <activity
                android:name="com.facebook.FacebookActivity"
                android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
                android:label="@string/app_name"/>
        <activity
                android:name="com.facebook.CustomTabActivity"
                android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>

                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>

                <data android:scheme="@string/fb_login_protocol_scheme"/>
            </intent-filter>
        </activity>



        <meta-data
                android:name="com.google.android.geo.API_KEY"
                android:value="AIzaSyCLXlTj6IiZjtqjxIsemt7ZrmUJDDUww_I"/>



        <meta-data
                android:name="com.facebook.sdk.ApplicationId"
                android:value="@string/facebook_app_id"/>

        <activity
                android:name="com.sprintsolutions.petsbuyandsell.MapsActivity"
                android:label="@string/title_activity_maps"
                android:screenOrientation="portrait"/>

        <activity
                android:name="com.sprintsolutions.petsbuyandsell.LoginActivity"
                android:screenOrientation="portrait"/>


    </application>

</manifest>

现在我可以分享 gradle 文件

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'



android {

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }

    signingConfigs {
        release {

            storeFile file('/Users/HP/AndroidStudioProjects/PetMarket/upload')
            storePassword 'a@b12345678'
            keyAlias = 'upload'
            keyPassword 'a@b12345678'
        }
    }
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.sprintsolutions.petsbuyandsell"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        signingConfig signingConfigs.release
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    androidExtensions {
        experimental = true
    }

    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:exifinterface:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-places:16.0.0'
    implementation 'com.google.android.libraries.places:places:2.2.0'
    implementation 'com.karumi:dexter:5.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.nabinbhandari.android:permissions:3.8'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
    implementation 'com.makeramen:roundedimageview:2.3.0'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    api 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
    implementation 'com.tbuonomo.andrui:viewpagerdotsindicator:3.0.3'
    implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.twitter.sdk.android:twitter:3.3.0'

}

标签: androidkotlin

解决方案


您应该迁移到 androidx 以使其正常工作


推荐阅读