赞
踩
Android stuido是Google官方唯一推荐的Android开发IDE,但是在使用过程中,必然会遇到一些一问题,Android Studio毕竟还在完善中,在这,分享一下我在使用Android Studio的时候遇到的问题以及解决方案,希望对广大博友有所帮助。
1、
Error:A problem was found with the configuration of task ':app:packageDebug'.
> File 'E:\winjia\Android\AndroidHelperJump\app\build\intermediates\res\resources-debug-stripped.ap_' specified for property 'resourceFile' does not exist.
这个问题在国内博客里有解决方案,也是有效的解决方案:感谢欧阳鹏分享的解决方案
2、
Warning:Exception while processing task java.io.IOException: proguard.ParseException: Expecting java type before ';' in line 58 of file 'E:\winjia\Android\AndroidHelperJump\app\proguard-rules.pro'
解决方案:这个异常提示很明显,是混淆文件的问题,在proguard-rules.pro的58行,找到代码你会发现,在这行代码的最后只有一个分号,在分号前面添加一个“*”就OK了。
3、
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':transformClassesAndResourcesWithProguardForRelease'.
这个问题纠结了我两天,现在算是没这个问题了,暂时将它定位为混淆出的问题(在不混淆的情况下,不会有这个问题),但是奇怪的是,当我把新加的代码注释之后,问题就不再出现了,下面是我新加的混淆代码:
-keep class * {
public private *;
}
-keep class android.support.v4.app. { *; }
-keep class android.support.v7.app. { *; }
-keep class android.support.v13.app. { *; }
-keep interface android.support.v4.app. { *; }
-keep interface android.support.v7.app. { *; }
-keep interface android.support.v13.app. { *; }
-dontwarn android.support.v4.*
-dontwarn android.support.v7.*
-dontwarn android.support.v13.*
这是在国外网站找的解决方案:transformClassesAndResourcesWithProguardForRelease解决方案参考
4、
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
这个问题是在项目中出现了多个相同的包导致的,解决方案:在app目录下的build.gradle的defaultConfig中添加:
multiDexEnabled true
并且在dependencies里面添加:
compile 'com.android.support:multidex:1.0.1'
最后重写Application中的方法attachBaseContext,添加以下代码:
public class YouApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
参考解决方案:多包冲突解决方案
5、
Information:Gradle tasks [:app:assembleBptRelease]
Warning:library class android.webkit.WebView depends on program class android.net.http.SslCertificate
Warning:library class android.webkit.WebViewClient depends on program class android.net.http.SslError
Warning:there were 3 instances of library classes depending on program classes.
Warning:Exception while processing task java.io.IOException: Can't write [E:\winjia\Android\AndroidHelperJump\app\build\intermediates\transforms\proguard\bpt\release\jars\3\1f\main.jar] (Can't read [C:\Users\dht10\.android\build-cache\a17c8869ac8fed255c1c2a4dbe599fdcb2263317\output\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:com/tencent/bugly/a.class]))
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForBptRelease'.
> Job failed, see logs for details
这是我在集成bugly的时候出现的一个问题,在debug环境下是没有问题的,但是,一旦切换到release环境立马就报出了这个问题,什么原因呢?Duplicate zip entry [classes.jar:com/tencent/bugly/a.class],看到这句话了没,意思就是说a.class重复了,那么,我们只需要把这个jar包的引用去掉就OK了。
6、最近碰到一个很低级的问题,在做屏幕适配的时候,写了多个xml布局,但是就在写完这几个布局文件的时候,意外的事情发生了:
11-16 13:07:38.560: ERROR/AndroidRuntime(13277): java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1286) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:292) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:314) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.View.measure(View.java:12733) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1370) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1018) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.LinearLayout.onMeasure(LinearLayout.java:556) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.View.measure(View.java:12733) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.HorizontalScrollView.measureChildWithMargins(HorizontalScrollView.java:1159) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.HorizontalScrollView.onMeasure(HorizontalScrollView.java:303) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.View.measure(View.java:12733) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.View.measure(View.java:12733) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.View.measure(View.java:12733) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1370) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.LinearLayout.measureVertical(LinearLayout.java:661) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.LinearLayout.onMeasure(LinearLayout.java:554) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.View.measure(View.java:12733) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2115) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.View.measure(View.java:12733) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1069) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2447) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.os.Handler.dispatchMessage(Handler.java:99) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.os.Looper.loop(Looper.java:137) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at android.app.ActivityThread.main(ActivityThread.java:4439) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at java.lang.reflect.Method.invokeNative(Native Method) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at java.lang.reflect.Method.invoke(Method.java:511) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554) 11-16 13:07:38.560: ERROR/AndroidRuntime(13277): at dalvik.system.NativeStart.main(Native Method) 11-16 13:07:38.570: WARN/ActivityManager(302): Force finishing activity com.XX.XX/.TaskPersonActivity 11-16 13:07:38.600: VERBOSE/AudioHardwareMSM8660(135): ACDB ID Device ID=speaker_stereo_rx
这个问题在网上也有一些解决方案,但是仍没解决我的问题,嗯,是没有解决我的问题!!!!!那就只能每个文件去对比咯,是滴,就是这么做滴。对比之后发现:在我的ImageView依赖了EditView,属性为above,而我的EditView又依赖了ImageView,属性为below,所以出现了问题。
对比之后发现在同一个页面的不同布局中存在着相同控件的不同的排版方式,应该就是这个问题吧。重新排版一下布局,发现文件解决了,还有一些其他可能导致这个问题的因素:
RelativeLayout依赖规则错误
7、昨晚又出bug了,哎…
先看看什么情况吧!!!!!
java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.
或者
java.lang.IllegalStateException: stop() called on an uninitialized AudioRecord.
部分手机在使用AudioRecord进行录音的时候会抛出这个异常,不管是在调用系统api startRecording()还是stop(),一开始很疑惑,这是为什么呢?在网上查阅一些资料,从一些大神们的博客里面大概摸出了点端倪,至于为什么,目前还不是很清楚,如果有小伙伴了解,欢迎相互交流一下,在这里提供一些解决方案:java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord,仅供参考。
8、最近导入一项github上下载的项目,结果出现了以下问题:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File1: C:\Users\dht10\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.7.0\19f42c154ffc689f40a77613bc32caeb17d744e3\jackson-annotations-2.7.0.jar
File2: C:\Users\dht10\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.7.2\8b8310381b690e317f5f0574e9b2dd7034778b4c\jackson-core-2.7.2.jar
File3: C:\Users\dht10\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.7.2\84ffa765dd258dbab8695963c41308b054f3a1cb\jackson-databind-2.7.2.jar
在网上找了一下,说是jar包里有相同的文件导致的,在module的build.gradle中添加一下配置就OK:
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
感谢欧阳鹏的解决方案
9、最近Android Studio发不了3.0版本,升级之后在构建项目的时候出现一个问题:
Error:android-apt plugin is incompatible with the Android Gradle plugin. Please use 'annotationProcessor' configuration instead.
错误报告android-apt插件与Android Gradle插件不兼容,讲apt用‘annotationProcessor’替换。
注意:在替换apt插件时,还需要讲gradle配置中的apt插件的引用注释掉。
10.最近做项目出现了一个很奇怪的问题,在直接依赖module的情况下,项目可正常运行,但是当module打包成Jar时,出现了下面这个问题:
01-02 09:46:29.671 17296-17296/com.test.demo E/AndroidRuntime: FATAL EXCEPTION: main Process: com.test.demo, PID: 17296 java.lang.NoClassDefFoundError: Failed resolution of: Ltimber/log/Timber; at org.win453.sdk.Tracker.track(Tracker.java:488) at org.win453.sdk.extra.TrackHelper$BaseEvent.safelyWith(TrackHelper.java:83) at org.win453.sdk.extra.TrackHelper$Screen.safelyWith(TrackHelper.java:113) at com.test.demo.Main2Activity.onCreate(Main2Activity.java:24) at android.app.Activity.performCreate(Activity.java:6662) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) Caused by: java.lang.ClassNotFoundException: Didn't find class "timber.log.Timber" on path: DexPathList[[zip file "/data/app/com.test.demo-1/base.apk", zip file "/data/app/com.test.demo-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.test.demo-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.test.demo-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.test.demo-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.test.demo-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.test.demo-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.test.demo-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.test.demo-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.test.demo-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.test.demo-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.test.demo-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.test.demo-1/lib/x86, /system/lib, /vendor/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at org.win453.sdk.Tracker.track(Tracker.java:488) at org.win453.sdk.extra.TrackHelper$BaseEvent.safelyWith(TrackHelper.java:83) at org.win453.sdk.extra.TrackHelper$Screen.safelyWith(TrackHelper.java:113) at com.test.demo.Main2Activity.onCreate(Main2Activity.java:24) at android.app.Activity.performCreate(Activity.java:6662) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
根据错误日志内容提示,"timber.log.Timber"这个类丢失了,而这个类是Timber类库中的,在非module中我并没有引用这个库,按道理来说应该是可以使用jar中的库的。
解决这个问题,我们只需要在项目app目录下的build.gradle文件中引用Timber库,并且在清单文件中指明使用app下的Timber。
清单文件中加入下面代码:
<uses-sdk tools:overrideLibrary="timber.log"/>
关于Android studio .9图片报aapt错误问题,在网上很多博客有提到怎么去制作.9图片,在此,博主申明一下,使用Android Studio制作.9图片时,只能在图片的左边和上边描黑线,不然会爆出一下错误:
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT error: check logs for details
11.关于retrolambda库在Android Studio 3.0中上的使用:
刚从Github上下载了一个Demo来学习一下,但是,出现了IDE与类库冲突问题。
Error:Execution failed for task ':app:transformClassesWithRetrolambdaForDebug'.
> Missing javaCompileTask for variant: debug/0 from output dir: D:\Studying\gank.io-with-MVVM\app\build\intermediates\transforms\retrolambda\debug\0
大概意思是说在retrolambda勒库中找不到javaCompileTask,Android Studio 升级为3.0之后出现就会出现这样的问题,解决方案。
最近在对SDK进行打包的时候,出现了一个很奇怪的问题:
Expecting a stackmap frame at branch target 529 Exception Details: Location: com/tencent/tinker/anno/AnnotationProcessor.processDefaultLifeCycle(Ljava/util/Set;)V @13: ifeq Reason: Expected stackmap frame at this location. Bytecode: 0x0000000: 2bb9 0047 0100 4d2c b900 4401 0099 0204 0x0000010: 2cb9 0045 0100 c000 1f4e 2d12 0eb9 004d 0x0000020: 0200 c000 0e3a 042d c000 20b9 004e 0100 0x0000030: b600 2f3a 0519 0503 1905 102e b600 30b6 0x0000040: 0034 3a06 1905 1905 102e b600 3004 60b6 0x0000050: 0033 3a05 1904 b900 4001 003a 0719 0712 0x0000060: 09b6 0032 9900 19bb 0015 59b7 0035 1906 0x0000070: b600 3819 07b6 0038 b600 3a3a 0719 0703 0x0000080: 1907 102e b600 30b6 0034 3a08 1907 1907 0x0000090: 102e b600 3004 60b6 0033 3a07 1904 b900 0x00000a0: 4301 003a 0919 0912 09b6 0032 9900 19bb 0x00000b0: 0015 59b7 0035 1906 b600 3819 09b6 0038 0x00000c0: b600 3a3a 0912 0d12 0ab6 002e 3a0a bb00 0x00000d0: 1859 190a b700 3c3a 0b19 0b12 0cb6 003e 0x00000e0: b600 3d3a 0c19 0c12 0519 08b6 0031 1203 0x00000f0: 1907 b600 3112 04bb 0015 59b7 0035 1906 0x0000100: b600 3812 09b6 0038 1905 b600 38b6 003a 0x0000110: b600 3112 06bb 0015 59b7 0035 1201 b600 0x0000120: 3819 04b9 0041 0100 b600 36b6 003a b600 0x0000130: 3112 07bb 0015 59b7 0035 1201 b600 3819 0x0000140: 09b6 0038 b600 3ab6 0031 1208 bb00 1559 0x0000150: b700 3512 01b6 0038 1904 b900 4201 00b6 0x0000160: 0039 b600 3ab6 0031 3a0d 2ab4 0024 b900 0x0000170: 4a01 00bb 0015 59b7 0035 1908 b600 3812 0x0000180: 09b6 0038 1907 b600 38b6 003a 03bd 001f 0x0000190: b900 4803 003a 0e2a b400 24b9 004b 0100 0x00001a0: b200 26bb 0015 59b7 0035 120b b600 3819 0x00001b0: 0eb9 0050 0100 b600 37b6 003a b900 4903 0x00001c0: 0019 0eb9 004f 0100 3a0f bb00 1059 190f 0x00001d0: b700 293a 1019 1019 0db6 002b 1910 b600 0x00001e0: 2a19 0fb6 002c a700 0d3a 1119 0fb6 002c 0x00001f0: 1911 bfa7 001b 3a0e 2ab4 0024 b900 4b01 0x0000200: 00b2 0025 190e b600 28b9 0049 0300 a7fd 0x0000210: f9b1 Exception Handler Table: bci [458, 481] => handler: 489 bci [489, 491] => handler: 489 bci [362, 499] => handler: 502
查阅资料之后,发现JDK版本的问题,Java虚拟机在校验数据的时候出了问题,我的JDK版本是1.8,开发工具是Android Studio,按照网上的说法,需要修改JVM的参数,JDK1.8所以在启动JVM参数加: -noverify,JDK1.7在启动JVM参数加: -XX:-UseSplitVerifier。
解决的方案是正确的,但是,我在哪里添加这个参数?原本以为是在Android Studio/bin/studio.exe.vmoptions或者Android Studio/bin/studio64.exe.vmoptions添加这两个参数,添加参数之后,发现Android Studio甚至无法启动。后来才知道Android Studio修改JVM参数可以在项目根目录下的gradle.properties文件中添加参数即可:
JDK 1.8:org.gradle.jvmargs=-noverify
JDK 1.7:org.gradle.jvmargs=-XX:-UseSplitVerifier
04-22 16:00:10.645 30446 30670 E DatabaseUtils: java.lang.SecurityException: Permission Denial: reading android.support.v4.content.FileProvider uri content://com.alibaba.android.rimet.file.provider/file/DingTalk/app-dev-release(17)_143.apk from pid=1088, uid=10025 requires the provider be exported, or grantUriPermission() 04-22 16:00:10.645 30446 30670 E DatabaseUtils: at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:648) 04-22 16:00:10.645 30446 30670 E DatabaseUtils: at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:503) 04-22 16:00:10.645 30446 30670 E DatabaseUtils: at android.content.ContentProvider$Transport.enforceFilePermission(ContentProvider.java:494) 04-22 16:00:10.645 30446 30670 E DatabaseUtils: at android.content.ContentProvider$Transport.openTypedAssetFile(ContentProvider.java:422) 04-22 16:00:10.645 30446 30670 E DatabaseUtils: at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:302) 04-22 16:00:10.645 30446 30670 E DatabaseUtils: at android.os.Binder.execTransact(Binder.java:704) 04-22 16:00:10.650 1088 1163 E PackageInstaller: checkMD5Match exception: 04-22 16:00:10.650 1088 1163 E PackageInstaller: java.lang.SecurityException: Permission Denial: reading android.support.v4.content.FileProvider uri content://com.alibaba.android.rimet.file.provider/file/DingTalk/app-dev-release(17)_143.apk from pid=1088, uid=10025 requires the provider be exported, or grantUriPermission() 04-22 16:00:10.650 1088 1163 E PackageInstaller: at android.os.Parcel.readException(Parcel.java:2016) 04-22 16:00:10.650 1088 1163 E PackageInstaller: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183) 04-22 16:00:10.650 1088 1163 E PackageInstaller: at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:146) 04-22 16:00:10.650 1088 1163 E PackageInstaller: at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:698) 04-22 16:00:10.650 1088 1163 E PackageInstaller: at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1425) 04-22 16:00:10.650 1088 1163 E PackageInstaller: at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1262) 04-22 16:00:10.650 1088 1163 E PackageInstaller: at android.content.ContentResolver.openInputStream(ContentResolver.java:982) 04-22 16:00:10.650 1088 1163 E PackageInstaller: at com.android.packageinstaller.PackageInstallerActivity$11.run(Unknown Source:129) 04-22 16:00:10.650 1088 1163 E PackageInstaller: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 04-22 16:00:10.650 1088 1163 E PackageInstaller: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 04-22 16:00:10.650 1088 1163 E PackageInstaller: at java.lang.Thread.run(Thread.java:764) 04-22 16:00:10.690 32070 625 D IdProviderImpl: getOAID 04-22 16:00:10.709 32070 1325 D IdProviderImpl: getOAID 04-22 16:00:11.130 1088 1288 E InstallAppProgress: doPackageStage 04-22 16:00:11.130 1088 1288 E InstallAppProgress: java.io.FileNotFoundException: /data/user/0/com.miui.packageinstaller/cache/package2478434660415544975.apk (No such file or directory) 04-22 16:00:11.130 1088 1288 E InstallAppProgress: at java.io.FileInputStream.open0(Native Method) 04-22 16:00:11.130 1088 1288 E InstallAppProgress: at java.io.FileInputStream.open(FileInputStream.java:200) 04-22 16:00:11.130 1088 1288 E InstallAppProgress: at java.io.FileInputStream.<init>(FileInputStream.java:150) 04-22 16:00:11.130 1088 1288 E InstallAppProgress: at com.android.packageinstaller.InstallAppProgress.a(Unknown Source:19) 04-22 16:00:11.130 1088 1288 E InstallAppProgress: at com.android.packageinstaller.InstallAppProgress.a(Unknown Source:0) 04-22 16:00:11.130 1088 1288 E InstallAppProgress: at com.android.packageinstaller.InstallAppProgress$2.run(Unknown Source:8) 04-22 16:00:11.130 1088 1288 E InstallAppProgress: at android.os.Handler.handleCallback(Handler.java:794) 04-22 16:00:11.130 1088 1288 E InstallAppProgress: at android.os.Handler.dispatchMessage(Handler.java:99) 04-22 16:00:11.130 1088 1288 E InstallAppProgress: at android.os.Looper.loop(Looper.java:176) 04-22 16:00:11.130 1088 1288 E InstallAppProgress: at android.os.HandlerThread.run(HandlerThread.java:65) 04-22 16:00:11.131 1088 1088 D InstallAppProgress: Installation error code: 1 04-22 16:00:11.132 1088 1088 D InstallAppProgress: installResult statusCode : 1 returnCode: -999
通过ADB命令查看小米手机输出日志发现,在安装apk时,出现了java.lang.SecurityException: Permission Denial: reading android.support.v4.content.FileProvider uri content://com.alibaba.android.rimet.file.provider/file/DingTalk/app-dev-release(17)_143.apk from pid=1088, uid=10025 requires the provider be exported, or grantUriPermission()异常,仔细看一下,报错是在钉钉。尝试换其他社交工具,不会出现这个问题,另外,其他手机也没有出现这个问题。
通过日志抓取发现,在运行过程中只出现两个异常:
2020-04-22 22:35:08.201 9528-9528/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.google.android.gms.persistent, PID: 9528 java.lang.RuntimeException: Unable to create application com.google.android.gms.common.app.GmsApplication: java.lang.SecurityException: addOnPermissionsChangeListener: Neither user 10139 nor current process has android.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS. at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6654) at android.app.ActivityThread.-wrap2(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2084) at android.os.Handler.dispatchMessage(Handler.java:109) at android.os.Looper.loop(Looper.java:166) at android.app.ActivityThread.main(ActivityThread.java:7555) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963) Caused by: java.lang.SecurityException: addOnPermissionsChangeListener: Neither user 10139 nor current process has android.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS. at android.os.Parcel.readException(Parcel.java:2016) at android.os.Parcel.readException(Parcel.java:1962) at android.content.pm.IPackageManager$Stub$Proxy.addOnPermissionsChangeListener(IPackageManager.java:6163) at android.app.ApplicationPackageManager.addOnPermissionsChangeListener(ApplicationPackageManager.java:1551) at mfu.a(:com.google.android.gms@11522448:10) at com.google.android.gms.common.app.GmsApplication.onCreate(:com.google.android.gms@11522448:41) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1123) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6636) at android.app.ActivityThread.-wrap2(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2084) at android.os.Handler.dispatchMessage(Handler.java:109) at android.os.Looper.loop(Looper.java:166) at android.app.ActivityThread.main(ActivityThread.java:7555) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963) 2020-04-22 22:35:08.262 10106-10106/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.google.process.gapps, PID: 10106 java.lang.RuntimeException: Unable to get provider com.google.android.gsf.settings.GoogleSettingsProvider: java.lang.SecurityException: You need MANAGE_USERS permission to: get the profile parent at android.app.ActivityThread.installProvider(ActivityThread.java:7237) at android.app.ActivityThread.installContentProviders(ActivityThread.java:6721) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6618) at android.app.ActivityThread.-wrap2(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2084) at android.os.Handler.dispatchMessage(Handler.java:109) at android.os.Looper.loop(Looper.java:166) at android.app.ActivityThread.main(ActivityThread.java:7555) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963) Caused by: java.lang.SecurityException: You need MANAGE_USERS permission to: get the profile parent at android.os.Parcel.readException(Parcel.java:2016) at android.os.Parcel.readException(Parcel.java:1962) at android.os.IUserManager$Stub$Proxy.getProfileParent(IUserManager.java:1081) at android.os.UserManager.getProfileParent(UserManager.java:2025) at com.google.android.gsf.settings.GoogleSettingsProvider.onCreate(GoogleSettingsProvider.java:153) at android.content.ContentProvider.attachInfo(ContentProvider.java:1920) at android.content.ContentProvider.attachInfo(ContentProvider.java:1894) at android.app.ActivityThread.installProvider(ActivityThread.java:7234) at android.app.ActivityThread.installContentProviders(ActivityThread.java:6721) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6618) at android.app.ActivityThread.-wrap2(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2084) at android.os.Handler.dispatchMessage(Handler.java:109) at android.os.Looper.loop(Looper.java:166) at android.app.ActivityThread.main(ActivityThread.java:7555) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
但是这两个异常貌似无关紧要,不管是正常运行还是异常运行,都会有这两个异常。经过包名过滤,发现一条信息:
2020-04-22 22:35:10.268 707-2064/? E/InputDispatcher: channel '8c48011 com.qhqykj.litlife/com.qhqykj.litlife.ui.activity.splash.SplashActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2020-04-22 22:35:10.268 707-2064/? E/InputDispatcher: channel '699ea8f Toast (server)' ~ Channel is unrecoverably broken and will be disposed!
据网上网友提示,这是因为有数据流过程中没有关闭,经过排查,在页面退出的时候,确实存在一些没有关闭的对象,但不是流对象,我的解决方案是,在onStop的时候,将其关闭。
好了,关于这个问题就解决了,参考文档Expected stackmap frame at this location
项目之前使用lottie低版本的库(非androidx项目),之后出现了一些ANR的问题,想使用新版本的lottie库,但是,在集成过程中,出现了下面这个问题:
androidx.versionedparcelable.ParcelImpl
解决方案是将项目迁移到androidx。
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。