为啥我的应用程序强制关闭?

Posted

技术标签:

【中文标题】为啥我的应用程序强制关闭?【英文标题】:Why is my application force-closing?为什么我的应用程序强制关闭? 【发布时间】:2015-04-11 02:51:18 【问题描述】:

我第一次尝试使用 google maps api,但是我的应用程序在我启动它时总是崩溃。我将它部署到我的 android 设备而不是任何模拟器。这是我使用的教程,我的代码基本相同:- Tutorials point google maps tutorial

抱歉,我无法更具体,因为我不知道出了什么问题。这是我从 logcat 复制的日志文件。

02-11 02:55:44.351: D/ActivityThread(1779): handleBindApplication:com.google.android.gms.wearable
02-11 02:55:44.351: D/ActivityThread(1779): setTargetHeapUtilization:0.75
02-11 02:55:44.351: D/ActivityThread(1779): setTargetHeapMinFree:2097152
02-11 02:55:44.531: I/MultiDex(1779): VM with version 1.6.0 does not have multidex support
02-11 02:55:44.531: I/MultiDex(1779): install
02-11 02:55:44.531: I/MultiDex(1779): MultiDexExtractor.load(/data/app/com.google.android.gms-1.apk, false)
02-11 02:55:44.551: I/MultiDex(1779): loading existing secondary dex files
02-11 02:55:44.561: I/MultiDex(1779): load found 2 secondary dex files
02-11 02:55:44.571: I/MultiDex(1779): install done
02-11 02:55:44.591: I/ProviderInstaller(1779): Insert disabled by gate 'gms:security:enable_conscrypt_in_gms_application'
02-11 02:55:44.611: D/LocationInitializer(1093): Restart initialization of location
02-11 02:55:44.631: I/dalvikvm(1779): Could not find method android.os.UserManager.getUserProfiles, referenced from method com.google.android.gms.wearable.service.y.a
02-11 02:55:44.631: W/dalvikvm(1779): VFY: unable to resolve virtual method 1110: Landroid/os/UserManager;.getUserProfiles ()Ljava/util/List;
02-11 02:55:44.631: D/dalvikvm(1779): VFY: replacing opcode 0x6e at 0x0035
02-11 02:56:48.241: D/ActivityThread(2361): handleBindApplication:com.google.android.gms
02-11 02:56:48.241: D/ActivityThread(2361): setTargetHeapUtilization:0.75
02-11 02:56:48.241: D/ActivityThread(2361): setTargetHeapMinFree:2097152
02-11 02:56:48.301: I/MultiDex(2361): VM with version 1.6.0 does not have multidex support
02-11 02:56:48.301: I/MultiDex(2361): install
02-11 02:56:48.301: I/MultiDex(2361): MultiDexExtractor.load(/data/app/com.google.android.gms-1.apk, false)
02-11 02:56:48.311: I/MultiDex(2361): loading existing secondary dex files
02-11 02:56:48.311: I/MultiDex(2361): load found 2 secondary dex files
02-11 02:56:48.321: I/MultiDex(2361): install done
02-11 02:56:48.591: I/ProviderInstaller(2361): Insert disabled by gate 'gms:security:enable_conscrypt_in_gms_application'
02-11 02:56:48.711: D/LocationInitializer(2361): Restart initialization of location
02-11 02:58:46.871: D/ActivityThread(2762): handleBindApplication:com.google.android.gms.wearable
02-11 02:58:46.881: D/ActivityThread(2762): setTargetHeapUtilization:0.75
02-11 02:58:46.881: D/ActivityThread(2762): setTargetHeapMinFree:2097152
02-11 02:58:46.911: I/MultiDex(2762): VM with version 1.6.0 does not have multidex support
02-11 02:58:46.911: I/MultiDex(2762): install
02-11 02:58:46.911: I/MultiDex(2762): MultiDexExtractor.load(/data/app/com.google.android.gms-1.apk, false)
02-11 02:58:46.921: I/MultiDex(2762): loading existing secondary dex files
02-11 02:58:46.921: I/MultiDex(2762): load found 2 secondary dex files
02-11 02:58:46.921: I/MultiDex(2762): install done
02-11 02:58:46.931: I/ProviderInstaller(2762): Insert disabled by gate 'gms:security:enable_conscrypt_in_gms_application'
02-11 02:58:46.961: D/LocationInitializer(2361): Restart initialization of location
02-11 02:58:46.971: I/dalvikvm(2762): Could not find method android.os.UserManager.getUserProfiles, referenced from method com.google.android.gms.wearable.service.y.a
02-11 02:58:46.971: W/dalvikvm(2762): VFY: unable to resolve virtual method 1110: Landroid/os/UserManager;.getUserProfiles ()Ljava/util/List;
02-11 02:58:46.971: D/dalvikvm(2762): VFY: replacing opcode 0x6e at 0x0035
02-11 02:58:48.791: W/ActivityThread(2361): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
02-11 02:58:50.701: W/GAV4(2361): Thread[Thread-2248,5,main]: Exception sending hit: HttpHostConnectException
02-11 02:58:50.701: W/GAV4(2361): Thread[Thread-2248,5,main]: Connection to https://ssl.google-analytics.com refused
02-11 02:58:50.711: W/GAV4(2361): Thread[Thread-2248,5,main]: Empty hitIds passed to deleteHits.
02-11 03:00:50.641: W/GAV4(2361): Thread[Thread-2248,5,main]: Exception sending hit: HttpHostConnectException
02-11 03:00:50.641: W/GAV4(2361): Thread[Thread-2248,5,main]: Connection to https://ssl.google-analytics.com refused
02-11 03:00:50.641: W/GAV4(2361): Thread[Thread-2248,5,main]: Empty hitIds passed to deleteHits.
02-11 03:02:15.251: I/CastSocket(2361): 19 >= 18. Adding new CastClientAuthKeyManager.
02-11 03:02:50.681: W/GAV4(2361): Thread[Thread-2248,5,main]: Exception sending hit: HttpHostConnectException
02-11 03:02:50.681: W/GAV4(2361): Thread[Thread-2248,5,main]: Connection to https://ssl.google-analytics.com refused
02-11 03:02:50.681: W/GAV4(2361): Thread[Thread-2248,5,main]: Empty hitIds passed to deleteHits.
02-11 03:04:00.431: I/EventLogService(2361): Aggregate from 1423602234108 (log), 1423602234108 (data)
02-11 03:04:00.601: W/EventLogAggregator(2361): Unknown tag: faceunlock
02-11 03:04:00.601: W/EventLogAggregator(2361): Unknown tag: snet
02-11 03:04:00.601: W/EventLogAggregator(2361): Unknown tag: snet_gcore
02-11 03:04:00.601: W/EventLogAggregator(2361): Unknown tag: snet_launch_service
02-11 03:04:50.751: W/GAV4(2361): Thread[Thread-2248,5,main]: Exception sending hit: HttpHostConnectException
02-11 03:04:50.751: W/GAV4(2361): Thread[Thread-2248,5,main]: Connection to https://ssl.google-analytics.com refused
02-11 03:04:50.751: W/GAV4(2361): Thread[Thread-2248,5,main]: Empty hitIds passed to deleteHits.
02-11 03:05:44.741: D/ActivityThread(4287): handleBindApplication:com.google.android.gms
02-11 03:05:44.741: D/ActivityThread(4287): setTargetHeapUtilization:0.75
02-11 03:05:44.751: D/ActivityThread(4287): setTargetHeapMinFree:2097152
02-11 03:05:44.921: I/MultiDex(4287): VM with version 1.6.0 does not have multidex support
02-11 03:05:44.931: I/MultiDex(4287): install
02-11 03:05:44.931: I/MultiDex(4287): MultiDexExtractor.load(/data/app/com.google.android.gms-1.apk, false)
02-11 03:05:44.951: I/MultiDex(4287): loading existing secondary dex files
02-11 03:05:44.951: I/MultiDex(4287): load found 2 secondary dex files
02-11 03:05:44.961: I/MultiDex(4287): install done
02-11 03:05:45.291: I/ProviderInstaller(4287): Insert disabled by gate 'gms:security:enable_conscrypt_in_gms_application'
02-11 03:05:45.441: D/LocationInitializer(4287): Restart initialization of location
02-11 03:06:23.581: D/LocationInitializer(4287): Restart initialization of location
02-11 03:07:45.621: W/ActivityThread(4287): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
02-11 03:07:47.521: W/GAV4(4287): Thread[Thread-2299,5,main]: Exception sending hit: HttpHostConnectException
02-11 03:07:47.521: W/GAV4(4287): Thread[Thread-2299,5,main]: Connection to https://ssl.google-analytics.com refused
02-11 03:07:47.521: W/GAV4(4287): Thread[Thread-2299,5,main]: Empty hitIds passed to deleteHits.

【问题讨论】:

你是在模拟器还是真机上测试过!测试的是哪个 Android 版本?某些 Google 服务在模拟器或旧版 Android 中不可用 设备是红米1S。安卓 4.4.4。谷歌地图作为应用程序,在它上面运行良好。 【参考方案1】:

看起来它实际上是被拒绝的与 Google 分析的连接。

造成这种情况的一个常见原因是,如果您修改了 hosts 文件来阻止手机/设备上的广告 - 这也可能会阻止对 Google Analytics 的调用。

【讨论】:

那我该如何解决呢?因为我制作了另一个使用谷歌分析的应用程序,它运行良好。 作为第一次测试,我将禁用或注释掉 Goggle Analytics 代码并确认它确实可以解决问题。还要检查它是否可以在打开 Analytics 的情况下在另一个没有修改主机文件的非 root 设备上运行。如果两者都是,请仔细查看有问题的设备上的主机文件或其他广告软件拦截器/防病毒设置。

以上是关于为啥我的应用程序强制关闭?的主要内容,如果未能解决你的问题,请参考以下文章

强制关闭ImageButton的onClick,不知道为啥

为啥我的 iOS 应用程序强制设置设置包

为啥我的 iOS 应用程序中的变量或强制转换为空? [复制]

为啥我的 Button 文本在 Lollipop 上强制全部大写?

如何强制系统关闭底层套接字

启动屏幕后应用程序强制关闭