无法启动 activity ComponentInfo{com.app.test,myapp/com.google.android.libraries.places.widget.AutocompleteActivity}
Unable to start activity ComponentInfo{com.app.test,myapp/com.google.android.libraries.places.widget.AutocompleteActivity}
根据 google intimation,我最近迁移了新的 Places SDK。之后无法导航自动完成Activity。下面是我的开始 Activity 电话。
List<Place.Field> fields = Arrays.asList(Place.Field.values());
Intent autocompleteIntent =
new Autocomplete.IntentBuilder(AutocompleteActivityMode.FULLSCREEN, fields)
.build(this);
startActivityForResult(autocompleteIntent, 101);
这是我的 gradle
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.app.test.myapp"
minSdkVersion 16
targetSdkVersion 28
versionCode 52
versionName "4.2"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
}
debug {
minifyEnabled false
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
useLibrary 'org.apache.http.legacy'
}
}
dependencies {
implementation project(':appupdater')
implementation "commons-codec:commons-codec:$rootProject.commonCodecVersion"
implementation "com.mcxiaoke.volley:library:$rootProject.volleyVersion"
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.supportLibraryVersion"
implementation "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-vector-drawable:$rootProject.supportLibraryVersion"
implementation "com.android.support.constraint:constraint-layout:$rootProject.constraintLayoutVersion"
implementation "com.google.android.gms:play-services-maps:$rootProject.googlePlayServiceVersion"
implementation "com.google.android.gms:play-services-location:$rootProject.googlePlayServiceVersion"
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
implementation 'com.google.android.libraries.places:places:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-messaging:17.6.0'
implementation "com.google.code.gson:gson:$rootProject.gsonVersion"
implementation "me.dm7.barcodescanner:zxing:$rootProject.zxingVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
configurations{
all*.exclude group: 'com.android.volley'
}
}
每当我调用启动自动完成Activity时,我都会遇到以下异常
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.test.myapp/com.google.android.libraries.places.widget.AutocompleteActivity}: java.lang.IllegalStateException: Places must be initialized.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2974)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3059)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: java.lang.IllegalStateException: Places must be initialized.
at com.google.android.libraries.places.internal.go.b(PG:22)
at com.google.android.libraries.places.widget.AutocompleteActivity.onCreate(PG:2)
at android.app.Activity.performCreate(Activity.java:7258)
at android.app.Activity.performCreate(Activity.java:7249)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1222)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3059)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
希望AutocompleteActivity不需要包含在Manifeast中。
使用 Places.initialize(getApplicationContext(), apiKey);
初始化了 Places SDK
根据 google intimation,我最近迁移了新的 Places SDK。之后无法导航自动完成Activity。下面是我的开始 Activity 电话。
List<Place.Field> fields = Arrays.asList(Place.Field.values());
Intent autocompleteIntent =
new Autocomplete.IntentBuilder(AutocompleteActivityMode.FULLSCREEN, fields)
.build(this);
startActivityForResult(autocompleteIntent, 101);
这是我的 gradle
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.app.test.myapp"
minSdkVersion 16
targetSdkVersion 28
versionCode 52
versionName "4.2"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
}
debug {
minifyEnabled false
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
useLibrary 'org.apache.http.legacy'
}
}
dependencies {
implementation project(':appupdater')
implementation "commons-codec:commons-codec:$rootProject.commonCodecVersion"
implementation "com.mcxiaoke.volley:library:$rootProject.volleyVersion"
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.supportLibraryVersion"
implementation "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-vector-drawable:$rootProject.supportLibraryVersion"
implementation "com.android.support.constraint:constraint-layout:$rootProject.constraintLayoutVersion"
implementation "com.google.android.gms:play-services-maps:$rootProject.googlePlayServiceVersion"
implementation "com.google.android.gms:play-services-location:$rootProject.googlePlayServiceVersion"
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
implementation 'com.google.android.libraries.places:places:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-messaging:17.6.0'
implementation "com.google.code.gson:gson:$rootProject.gsonVersion"
implementation "me.dm7.barcodescanner:zxing:$rootProject.zxingVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
configurations{
all*.exclude group: 'com.android.volley'
}
}
每当我调用启动自动完成Activity时,我都会遇到以下异常
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.test.myapp/com.google.android.libraries.places.widget.AutocompleteActivity}: java.lang.IllegalStateException: Places must be initialized.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2974)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3059)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: java.lang.IllegalStateException: Places must be initialized.
at com.google.android.libraries.places.internal.go.b(PG:22)
at com.google.android.libraries.places.widget.AutocompleteActivity.onCreate(PG:2)
at android.app.Activity.performCreate(Activity.java:7258)
at android.app.Activity.performCreate(Activity.java:7249)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1222)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3059)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
希望AutocompleteActivity不需要包含在Manifeast中。
使用 Places.initialize(getApplicationContext(), apiKey);
初始化了 Places SDK