简体   繁体   English

在Android Studio中添加jar文件时发生错误

[英]Error occur when i add jar file in android Studio

Error like this Information:Gradle tasks [:app:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE :app:prepareComAndroidSupportDesign2311Library UP-TO-DATE :app:prepareComAndroidSupportMediarouterV72300Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE :app:prepareComFacebookAndroidFacebookAndroidSdk420Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServices840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAds840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAnalytics840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAppindexing840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAppinvite840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAppstate840Library UP-TO-DATE :app:prepareCo 像这样的错误信息:Gradle任务[:app:assembleDebug]:app:preBuild UP-TO-DATE:app:preDebugBuild UP-TO-DATE:app:checkDebugManifest:app:preReleaseBuild UP-TO-DATE:app:prepareComAndroidSupportSupport TO-DATE:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE:app:prepareComAndroidSupportMediarouterV72300Library UP-TO-DATE:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE:app:prepareComAndroidAndroidSupportk-Date:app-app-420-Facebook-pre-Date:app-app-420 :prepareComGoogleAndroidGmsPlayServices840Library UP-TO-DATE:应用程序:prepareComGoogleAndroidGmsPlayServicesAds840Library UP-TO-DATE:应用程序:prepareComGoogleAndroidGmsPlayServicesAnalytics840Library UP-TO-DATE:应用程序:prepareComGoogleAndroidGmsPlayServicesAppindexing840Library UP-TO-DATE:应用程序:prepareComGoogleAndroidGmsPlayServicesAppinvite840Library UP-TO-DATE:应用程序:prepareComGoogleAndroidGmsPlayServicesAppstate840Library UP-TO -DATE:app:prepareCo mGoogleAndroidGmsPlayServicesAuth840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesBase840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesBasement840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesCast840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesDrive840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesFitness840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesGames840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesGcm840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesIdentity840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesLocation840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesMaps840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesMeasurement840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesNearby840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesPanorama840Library UP-TO-DATE :app:prepareComGoog mGoogleAndroidGmsPlayServicesAuth840Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesBase840Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesBasement840Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesCast840Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesDrive840Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesFitness840Library UP-TO-日期:应用:prepareComGoogleAndroidGmsPlayServicesGames840Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesGcm840Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesIdentity840Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesLocation840Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesMaps840Library UP-TO-DATE:应用:prepareComGoogleAndroidGmsPlayServicesMeasurement840Library UP-TO-DATE:app:prepareComGoogleAndroidGmsPlayServicesNearby840Library UP-TO-DATE:app:prepareComGoogleAndroidGmsPlayServicesPanorama840Library UP-TO-DATE:app:prepareComGoog leAndroidGmsPlayServicesPlus840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesSafetynet840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesVision840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesWallet840Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesWearable840Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:mergeDebugShaders UP-TO-DATE :app:compileDebugShaders UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE :app:compileDebugJavaWithJavac Note: C:\\Users\\rockstar\\Desktop\\AstroMaze\\app\\src\\main\\java\\com leAndroidGmsPlayServicesPlus840Library UP-TO-DATE:app:prepareComGoogleAndroidGmsPlayServicesSafetynet840Library UP-TO-DATE:app:prepareComGoogleAndroidGmsPlayServicesVision840Library UP-TO-DATE:app:prepareComGoogleGoogleGmsPlayServicesWallet840prepareATE-appateeappedeApplyeappateDate UP-TO-DATE:app:compileDebugRenderscript UP-TO-DATE:app:generateDebugBuildConfig UP-TO-DATE:app:mergeDebugShaders UP-TO-DATE:app:compileDebugShaders UP-TO-DATE:app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE:app:generateDebugResValues UP-TO-DATE:app:generateDebugResources UP-TO-DATE:app:mergeDebugResources UP-TO-DATE:app:processDebugManifest UP-TO-DATE:app:processDebugResources UP -TO-DATE:app:generateDebugSources UP-TO-DATE:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE:app:compileDebugJavaWithJavac注意:C:\\ Users \\ rockstar \\ Desktop \\ AstroMaze \\ app \\ src \\ main \\ java \\ com \\org\\astromaze\\MainActivityUsers.java uses or overrides a deprecated API. \\ org \\ astromaze \\ MainActivityUsers.java使用或覆盖已弃用的API。 Note: Recompile with -Xlint:deprecation for details. 注意:有关详细信息,请使用-Xlint:deprecation重新编译。 Incremental compilation of 6 classes completed in 2.053 secs. 6个课程的增量编译在2.053秒内完成。 :app:compileDebugNdk UP-TO-DATE :app:compileDebugSources :app:prePackageMarkerForDebug :app:transformClassesWithDexForDebug To run dex in process, the Gradle daemon needs a larger heap. :app:compileDebugNdk更新::app:compileDebugSources:app:prePackageMarkerForDebug:app:transformClassesWithDexForDebug要在进程中运行dex,Gradle守护程序需要更大的堆。 It currently has approximately 910 MB. 当前,它大约有910 MB。 For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB. 为了加快构建速度,请将Gradle守护程序的最大堆大小增加到2048 MB以上。 To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties. 为此,请在项目gradle.properties中设置org.gradle.jvmargs = -Xmx2048M。 For more information see https://docs.gradle.org/current/userguide/build_environment.html Error:The number of method references in a .dex file cannot exceed 64K. 有关更多信息,请参见https://docs.gradle.org/current/userguide/build_environment.html错误:.dex文件中方法引用的数量不能超过64K。 Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html :app:transformClassesWithDexForDebug FAILED Error:Execution failed for task ':app:transformClassesWithDexForDebug'. https://developer.android.com/tools/building/multidex.html:app:transformClassesWithDexForDebug FAILED上了解如何解决此问题:错误:任务':app:transformClassesWithDexForDebug'执行失败。

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\\Program Files\\Java\\jdk1.8.0_91\\bin\\java.exe'' finished with non-zero exit value 2 Information:BUILD FAILED Information:Total time: 17.268 secs Information:2 errors Information:0 warnings Information:See complete output in console com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:org.gradle.process。 internal.ExecException:处理'命令'C:\\ Program Files \\ Java \\ jdk1.8.0_91 \\ bin \\ java.exe''完成,退出值非零2信息:建立失败信息:总时间:17.268秒信息:2错误信息:0警告信息:请参阅控制台中的完整输出

Basically Your errors are :- 基本上你的错误是:

1) Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

2) Error:The number of method references in a .dex file cannot exceed 64K.

Solutions to these errors are as follows :- 这些错误的解决方案如下:-

1) add multiDexEnabled true line in your build.gradle(Module:app) inside defaultConfig 1)在defaultConfig的build.gradle(Module:app)中添加multiDexEnabled真

2) Replace the whole content of gradle.properties file with below :- 2)将gradle.properties文件的全部内容替换为以下内容:-

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

3) Go to Help > Edit Custom VM Options , if the file with extension .vmoptions opens then replace content of the file with the below content , if the file is not there then create one and then replace the content with this :- 3)转到“帮助”>“编辑自定义VM选项”,如果扩展名为.vmoptions的文件打开,则用以下内容替换文件的内容,如果该文件不存在,则创建一个,然后用以下内容替换:

# custom Android Studio VM options

#
# *DO NOT* modify this file directly. If there is a value that you would like to override,
# please add it to your user specific configuration file.
#
# See http://tools.android.com/tech-docs/configuration
#
-Xms256m
-Xmx750m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-da
-Djna.nosys=true
-Djna.boot.library.path=

-Djna.debug_load=true
-Djna.debug_load.jna=true
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-Didea.paths.selector=AndroidStudio2.1
-Didea.platform.prefix=AndroidStudio

All your errors will be resolved . 您所有的错误都会得到解决。

Good Luck . 祝好运 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM