Android Studio 使用中 遇到的那些奇奇怪怪的问题

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/shijianduan1/article/details/81741592

---------------------------------------------------------------------------------------------------------------------------------------------------------------

转载声明:本文来自 https://blog.csdn.net/shijianduan1/article/details/81741592 

---------------------------------------------------------------------------------------------------------------------------------------------------------------

写在正文前,也是用了很久的AS了,从1.0 到3.1, gradle也一直保持着及时更新(有项目共用代码的,就不要学我了)
因为 每次更新都带来了许多坑

感觉 还是 写点总结的好。

                     持续更新ing , 欢迎相互讨论

---------------------------------------------------------------------------------------------------------------------------------------------------------------

问题十七:

错误:

分析:

解决方案:

---------------------------------------------------------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------------------------------------------------------------------

问题十六:

错误:

 java.lang.IllegalArgumentException: cipherSuite TLS_ECDHE_ECDSA_WITH_RC4_128_SHA is not supported.
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.org.conscrypt.NativeCrypto.checkEnabledCipherSuites(NativeCrypto.java:1094)
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.org.conscrypt.NativeCrypto.setEnabledCipherSuites(NativeCrypto.java:1055)
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.org.conscrypt.SSLParametersImpl.setSSLParameters(SSLParametersImpl.java:468)
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:297)
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.okhttp.Connection.upgradeToTls(Connection.java:201)
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.okhttp.Connection.connect(Connection.java:155)
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:276)
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:382)
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
10-29 11:06:55.002 W/System.err( 4870): 	at com.android.okhttp.internal.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:25)
10-29 11:06:55.002 W/System.err( 4870): 	at com.alibaba.mtl.log.e.e.a(HttpUtils.java:203)
10-29 11:06:55.002 W/System.err( 4870): 	at com.alibaba.mtl.log.a.b$a.run(GcConfigChannelMgr.java:45)
10-29 11:06:55.002 W/System.err( 4870): 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
10-29 11:06:55.002 W/System.err( 4870): 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-29 11:06:55.002 W/System.err( 4870): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-29 11:06:55.002 W/System.err( 4870): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-29 11:06:55.002 W/System.err( 4870): 	at java.lang.Thread.run(Thread.java:818)

分析: 使用SSL 认证的时候,报错了, 主要关键是 TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, 但是搜索了一遍后发现相关解释寥寥无几,

   参考一:Wireshark 抓包理解 HTTPS 请求流程 

               这篇 虽然主题不对,但是很有参考价值,文章内容将这块原理 写的很清楚,主要是下面这段

加密套件 ,客户端可以支持的密码套件列表。这些套件会根据优先级排序。每一个套件代表一个密钥规格。以 “TLS” 开头,接着是密钥交换算法,然后用 “WITH” 连接加密算法和认证算法。一个加密套件有这么几个内容:密钥交换算法、加密算法(会带有支持的最高密钥位数)、认证算法还有加密方式

……

客户端提供了 20 种密码套件供服务端选择,最终使用什么密码套件是服务端决定的。要什么密码套件会在 Server Hello 中进行反馈

……

密码套件随着密码学的发展而发展,而且根据现实应用中,可能会有某些密码被破解,从而导致密码套件可能会导致安全问题,所以一般都会使用当前最新最安全的密码套件。

在 Android 系统中,一般情况下,使用 SSLSocket进行连接的时候,会带上系统默认的支持的密码套件。但是这个有个缺点,比如某些密码套件的加密算法被破解或者出现安全漏洞,而且要跟着系统升级反应缓慢。OkHttp 在进行 SSL 握手的时候,会使用 ConnectionSpec 类中带上提供了一系列最新的密码套件。可以从注释上看,这些密码套件在 Chrome 51 和 Android 7.0 以上得到了完全支持

然后,再把这些密码套件和 Android 系统支持的密码套件取交集,提交给服务端。这样,万一哪个密码套件有问题,OkHttp 官方会下降支持。网络库 OkHttp 库会随着版本的迭代,不断地去提供比较新的密码套件,并且放弃那些不安全的密码套件。接入应用即时更新 OkHttp,就不用等待缓慢的系统更新了。

如果提供的所有密码套件服务端都不支持,OkHttp 有回退机制,退而求其次,选比较旧的套件。

    参考二:Unsupported ciphersuite TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256

    参考三:异常:javax.net.ssl.SSLException: Received fatal alert: protocol_version

                 上诉两篇,虽然都有解决方案,但其实并不适合android平台,能作为一个错误排查依据吧

解决方案: 结论:是Android平台 不支持该类型解析SSL(没有对应的密码套件,所以导致了),修改系统

             我的情况是 SSL证书的后台生成的,其他设备其他厂商的系统都支持,就一个客户报不支持,

    所以最后坚持的解决方案(为了兼容以前的版本)应用端不做修改,让系统层来适配。

---------------------------------------------------------------------------------------------------------------------------------------------------------------

问题十五:

错误:

java.lang.NoSuchFieldError: No static field M_username of type I in class Lcom/liblogin/R$id; or its superclasses (declaration of 'com.liblogin.R$id' appears in /data/app/split_lib_slice_6_apk.apk)

分析:  某些错误导致了R文件中找不到对应的id

解决方案:

     存在有两个名字相同layout文件,改下名字即可,(不同moudle下的 也算,一般错误信息会提示到那个R.id.a 报错的)

---------------------------------------------------------------------------------------------------------------------------------------------------------------

问题十四:

错误:

Android resource compilation failed
Output:  E:\Android_Project\NewsAPP\appsjd\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2352: error: <item> inner element must either be a resource reference or empty.
E:\Android_Project\NewsAPP\appsjd\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2353: error: <item> inner element must either be a resource reference or empty.
E:\Android_Project\NewsAPP\appsjd\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2354: error: <item> inner element must either be a resource reference or empty.
E:\Android_Project\NewsAPP\appsjd\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2355: error: <item> inner element must either be a resource reference or empty.
E:\Android_Project\NewsAPP\appsjd\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2356: error: <item> inner element must either be a resource reference or empty.

Command: C:\Users\sjd\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\5c71ea87193179d184b1fee578e1834b\aapt2-3.2.0-4818971-windows\aapt2.exe compile --legacy \
        -o \
        E:\Android_Project\NewsAPP\appsjd\build\intermediates\res\merged\debug \
        E:\Android_Project\NewsAPP\appsjd\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon:  AAPT2 aapt2-3.2.0-4818971-windows Daemon #0

    <item name="versionchecklib_failed_dialog_retry" type="id">0x67</item>
    <item name="versionchecklib_loading_dialog_cancel" type="id">0x70</item>
    <item name="versionchecklib_version_dialog_cancel" type="id">0x69</item>
    <item name="versionchecklib_version_dialog_commit" type="id">0x66</item>

分析:我也不知道 怎么就出现这个问题了, 就某次回家打开了项目就这样了(clean project 也试过了没用)

         跟进代码里,指引到res/values 资源文件,但是搜遍了全文也没有看见关键字。

          猜测一:还是更新到28导致的, 某个第三方包不兼容,报错了

          猜测二:更新到28后,原来的引用的某些资源文件 不能用了。

      参考:Gradle错(十)(存疑),看到这个Blog, 说 enableAapt2  将被去除

The option 'android.enableAapt2' is deprecated and should not be used anymore.
Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..

临时的解决方法:gradle.properties添android.enableAapt2=false

解决方案:

  错误类型一:

    真正给我 解决方案灵感的是 : android studio 3.1.1 相关问题

    这个详细说明的 错误 是将下述的  第一个 @ 符号 去除。

<item name="@android:windowExitAnimation">@anim/fade_out</item>

 错误类型二:  

参考:Gradle错(十)(存疑), 其 错误处是 赋值了 id(最后一个,白色的), 应当设置为空

<item name="statusBarUtil_fake_status_bar_view" type="id">id</item>
<item name="statusBarUtil_translucent_view" type="id">id</item>

错误类型三:

当然 我的错误不是上述, 我将 “versionchecklib_loading_dialog_cancel”(其中一个错误id)百度了下,果然 发现是我引用的一个第三方登录框架里存在的 :一个越来越强大的android版本检测更新库 (看来应该 催作者更新下~.~) 

    //检测更新
//    implementation 'com.allenliu.versionchecklib:library:2.0.0'

  引用注释掉, ok ,编译通过。 终于又可以愉快的写代码了。(附上 久违的编译成功截图)

---------------------------------------------------------------------------------------------------------------------------------------------------------------

问题十三:

错误: 在AS 更新gradle 28版本的时候报错了

简易错误:

Duplicate key com.android.build.gradle.internal.api.artifact.BuildableArtifactImpl@45ce3f99

错误详细信息:

org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':libnetwork'.
	at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:94)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:89)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:70)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.access$100(LifecycleProjectEvaluator.java:34)
	at org.gradle.configuration.project.LifecycleProjectEvaluator$ConfigureProject.run(LifecycleProjectEvaluator.java:110)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:50)
	at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:667)
	at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:136)
	at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
	at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:62)
	at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
	at org.gradle.initialization.DefaultGradleLauncher$ConfigureBuild.run(DefaultGradleLauncher.java:261)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
	at org.gradle.initialization.DefaultGradleLauncher.configureBuild(DefaultGradleLauncher.java:173)
	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:132)
	at org.gradle.initialization.DefaultGradleLauncher.getConfiguredBuild(DefaultGradleLauncher.java:110)
	at org.gradle.internal.invocation.GradleBuildController$2.call(GradleBuildController.java:87)
	at org.gradle.internal.invocation.GradleBuildController$2.call(GradleBuildController.java:84)
	at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
	at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
	at org.gradle.internal.invocation.GradleBuildController.configure(GradleBuildController.java:84)
	at org.gradle.tooling.internal.provider.runner.ClientProvidedBuildActionRunner.run(ClientProvidedBuildActionRunner.java:64)
	at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
	at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
	at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
	at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
	at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
	at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:49)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:32)
	at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
	at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
	at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80)
	at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53)
	at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:57)
	at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
	at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
	at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
	at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
	at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
	at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
	at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
	at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
	at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
	at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:45)
	at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
	at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
	at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
	at org.gradle.util.Swapper.swap(Swapper.java:38)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
	at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
	at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Duplicate key com.android.build.gradle.internal.api.artifact.BuildableArtifactImpl@45ce3f99
	at com.android.build.gradle.internal.variant.BaseVariantData.lambda$getAndroidResources$2(BaseVariantData.java:605)
	at java.util.HashMap.merge(HashMap.java:1253)
	at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
	at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1376)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at com.android.build.gradle.internal.variant.BaseVariantData.getAndroidResources(BaseVariantData.java:596)
	at com.android.build.gradle.tasks.MergeResources$ConfigAction.execute(MergeResources.java:879)
	at com.android.build.gradle.tasks.MergeResources$ConfigAction.execute(MergeResources.java:774)
	at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:151)
	at com.android.build.gradle.internal.TaskFactoryImpl.create(TaskFactoryImpl.kt:50)
	at com.android.build.gradle.internal.TaskManager.basicCreateMergeResourcesTask(TaskManager.java:940)
	at com.android.build.gradle.internal.LibraryTaskManager.createMergeResourcesTasks(LibraryTaskManager.java:448)
	at com.android.build.gradle.internal.LibraryTaskManager.createTasksForVariantScope(LibraryTaskManager.java:120)
	at com.android.build.gradle.internal.VariantManager.createTasksForVariantData(VariantManager.java:633)
	at com.android.build.gradle.internal.VariantManager.lambda$createAndroidTasks$1(VariantManager.java:381)
	at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81)
	at com.android.build.gradle.internal.VariantManager.createAndroidTasks(VariantManager.java:377)
	at com.android.build.gradle.BasePlugin.lambda$createAndroidTasks$6(BasePlugin.java:800)
	at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81)
	at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:795)
	at com.android.build.gradle.BasePlugin.lambda$null$4(BasePlugin.java:690)
	at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:81)
	at com.android.build.gradle.BasePlugin.lambda$createTasks$5(BasePlugin.java:686)
	at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:91)
	at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:80)
	at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
	at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
	at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
	at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
	at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324)
	at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234)
	at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
	at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
	at com.sun.proxy.$Proxy31.afterEvaluate(Unknown Source)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:76)
	... 85 more

 

分析:

        解决了, 困扰了我两天的问题。。。

       错误原因 不详 反正有点莫名其妙,因为gradle27还是好的, 28就报错了。。。

       ╮(╯▽╰)╭

解决方案:

(放在前面,下面有评论的小伙伴说: 把 main 改成 flavor_main )

 

 如下图, 我将渠道打包的注释掉就好了(不知道是不是因为我只写了一个的原因)。

---------------------------------------------------------------------------------------------------------------------------------------------------------------

问题十二:

错误: 带码行 左侧 有勾,数字,字母; 右侧显示白色线条, 提示:BookMark

 

分析:这个不是错误, 只是 看见带码左侧有个✔ (也有可能是 字母和数字)

解决方案:  是代码标签

                ctrl+F11  可以新增/去除

                 shift+F11 可以遍历

---------------------------------------------------------------------------------------------------------------------------------------------------------------

问题十一:

错误:  gradle-4.6-all.zip 下载慢

       昨天就存在了, 打开as后下载特别慢,一开始以为是 刚发布很多人下载导致的,所以没在意。

       今天打开as发现还是这么慢,22min 才下载6M大小,就感觉不对。

分析: 下载慢,无外乎那几种情况, 然后百度了一个方法。

         (参考: 解决AndroidStudio下载gradle慢的问题

解决方案:

写的很详细,就直接拿来用了。

这里说明下的是:

          文件路径是 :C:\Users\sjd\.gradle\wrapper\dists\gradle-4.6-all\bcst21l2brirad8k2ben1letg

    
 就这个样子,然后打开as,坐等编译结束。

---------------------------------------------------------------------------------------------------------------------------------------------------------------

问题十:

错误:


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'APP'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not download bcpkix-jdk15on.jar (org.bouncycastle:bcpkix-jdk15on:1.56): No cached version available for offline mode
   > Could not download bcprov-jdk15on.jar (org.bouncycastle:bcprov-jdk15on:1.56): No cached version available for offline mode
   > Could not download fastutil.jar (it.unimi.dsi:fastutil:7.2.0): No cached version available for offline mode
   > Could not download jimfs.jar (com.google.jimfs:jimfs:1.1): No cached version available for offline mode
   > Could not download guava.jar (com.google.guava:guava:23.0): No cached version available for offline mode
   > Could not download gson.jar (com.google.code.gson:gson:2.8.0): No cached version available for offline mode
   > Could not download httpclient.jar (org.apache.httpcomponents:httpclient:4.5.2): No cached version available for offline mode
   > Could not download httpcore.jar (org.apache.httpcomponents:httpcore:4.4.5): No cached version available for offline mode

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

CONFIGURE FAILED in 0s
Could not download bcpkix-jdk15on.jar (org.bouncycastle:bcpkix-jdk15on:1.56): No cached version available for offline mode

分析: 仅从错误上来看,还是jcenter  连接超时,导致一些jar无法下载的问题。

           不过 有点意外的是, bcpkix-jdk15on.jar 这个jar包我代码 没有引用过, 

解决方案:

        1.   删除了 .gradle  和 .idea 目录,然后重新编译了下, 成功了
     (额外操作, 虽然关系不大:小伙伴 使用的是AS测试版本,'com.android.tools.build:gradle:3.2.0-rc02',但是我这边是正式版本,所以 gradle配置不对了,找不到该版本的gradle  )

---------------------------------------------------------------------------------------------------------------------------------------------------------------

问题九:

错误:


FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':libnetwork:lintClassPath'.
> Could not resolve com.android.tools.lint:lint-gradle:26.1.4.
  Required by:
      project :libnetwork
   > No cached version of com.android.tools.lint:lint-gradle:26.1.4 available for offline mode.
   > No cached version of com.android.tools.lint:lint-gradle:26.1.4 available for offline mode.
   > No cached version of com.android.tools.lint:lint-gradle:26.1.4 available for offline mode.
   > No cached version of com.android.tools.lint:lint-gradle:26.1.4 available for offline mode.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

分析: gradle 编译报错了,离线模式下找不到gradle:26.1.4 版本的缓存,感觉 是gradle 配置那边问题

1. 网上看到说  添加google(), 但实际无法解决这个问题。

( 错误 参考: Android Studio Rebuild失败:Could not find com.android.tools.lint:lint-gradle:26.1.1.  )

 

解决方案: 

 1. 目前没有找到 针对性的解决方法, 

     初步怀疑是 网络问题(因为经常性有jar包无法下载)

2.我的操作:1) 删除了 Project根目录下面的 .gradle  /gradle 和 .idea     三个目录,
                      2)重新build项目

                      3)有些下载超时的问题,多build 几次,(

展开阅读全文

没有更多推荐了,返回首页