gpt4 book ai didi

android - 不幸的是,应用程序在启动谷歌地图 Activity 时已停止

转载 作者:搜寻专家 更新时间:2023-11-01 09:32:51 24 4
gpt4 key购买 nike

我正在尝试使用 google app activity 创建一个应用程序。我刚刚按照步骤使用 Google maps activity 创建了一个 google map 应用程序,没有添加任何额外的代码。应用程序在启动时崩溃了。我在下面给出了我的 list 文件、builde.gradle(app) 和 logcat。这是我的 list 文件

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ranjit.getlocation">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


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


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

<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</manifest>

下面是build.gradle(app)文件

    apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.ranjit.getlocation"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services:10.0.1'
testCompile 'junit:junit:4.12'
}

应用程序的logcat如下

 08-12 10:50:02.947 15439-15439/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ranjit.getlocation, PID: 15439
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.example.ranjit.getlocation-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.ranjit.getlocation-1, /vendor/lib, /system/lib, /system/lib/arm]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5029)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4621)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4561)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.example.ranjit.getlocation-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.ranjit.getlocation-1, /vendor/lib, /system/lib, /system/lib/arm]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:5014)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4621) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4561) 
at android.app.ActivityThread.access$1500(ActivityThread.java:139) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:149) 
at android.app.ActivityThread.main(ActivityThread.java:5257) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
at dalvik.system.NativeStart.main(Native Method) 

最佳答案

您必须在您的应用程序中包含 multiDex。在您的 list 中,您没有包含MultiDexApplication

ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList

将其添加到您的依赖项中。

  compile 'com.android.support:multidex:1.0.1'

在你的 Gradle 中添加 multiDexEnabled true

android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true // add this line
}
...
}

在您的 list 中添加 multiDex 应用程序类。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>

避免包含完整的播放服务(compile 'com.google.android.gms:play-services:10.0.1')库。相反,请使用您需要的特定库。

为 map 包含此依赖项

com.google.android.gms:play-services-maps:11.0.4

关于android - 不幸的是,应用程序在启动谷歌地图 Activity 时已停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45640756/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com