【问题标题】:Error:Already finished after gradle build错误:gradle build 后已经完成
【发布时间】:2018-08-03 07:16:18
【问题描述】:

我正在尝试从我的物理设备上的 android studio 运行应用程序。但每次我这样做时,Gradle Build 都会显示此错误

Information:Gradle tasks [:app:assembleDebug] 
Information:BUILD SUCCESSFUL in 10s 
Error:Already finished 
Information:BUILD FAILED in 10s 
Information:1 error 
Information:0 warnings 
Information:See complete output in console

我浏览了这个link 并尝试了所有答案,但错误仍然出现。另外,我注意到应用程序的文件夹包含.gradle 文件夹,我尝试将其删除,但每次Rebuild Project/Clean Project 文件夹都会自动出现。

另外,每次我创建一个新项目时,我都会遇到这个错误。

在终端运行./gradlew assembleDebug --info后,日志如下:

Initialized native services in: /home/shaloin/.gradle/native
Found daemon DaemonInfo{pid=17048, address=[fc6fb39e-af80-499f-a671-d7966fec4f29 port:33345, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], state=Idle, lastBusy=1519376060898, context=DefaultDaemonContext[uid=b05f2429-3b72-4dbb-9b66-3861bb909eee,javaHome=/usr/local/android-studio/jre,daemonRegistryDir=/home/shaloin/.gradle/daemon,pid=17048,idleTimeout=10800000,daemonOpts=-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=IN,-Duser.language=en,-Duser.variant]} however its context does not match the desired criteria.
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=/usr/lib/jvm/java-8-oracle,daemonRegistryDir=/home/shaloin/.gradle/daemon,pid=553,idleTimeout=null,daemonOpts=-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=IN,-Duser.language=en,-Duser.variant]
Actual: DefaultDaemonContext[uid=b05f2429-3b72-4dbb-9b66-3861bb909eee,javaHome=/usr/local/android-studio/jre,daemonRegistryDir=/home/shaloin/.gradle/daemon,pid=17048,idleTimeout=10800000,daemonOpts=-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=IN,-Duser.language=en,-Duser.variant]

  Looking for a different daemon...
The client will now receive all logging from the daemon (pid: 335). The daemon log file: /home/shaloin/.gradle/daemon/4.1/daemon-335.out.log
Starting 2nd build in daemon [uptime: 3 mins 8.377 secs, performance: 99%, no major garbage collections]
Using 4 worker leases.
Creating new cache for fileHashes, path /home/shaloin/AndroidStudioProjects/CodeSearch/.gradle/4.1/fileHashes/fileHashes.bin, access org.gradle.cache.internal.DefaultCacheAccess@70f708a8
Creating new cache for plugin-use-metadata, path /home/shaloin/.gradle/caches/4.1/plugin-resolution/plugin-use-metadata.bin, access org.gradle.cache.internal.DefaultCacheAccess@79864311
Creating new cache for client-status, path /home/shaloin/.gradle/caches/4.1/plugin-resolution/client-status.bin, access org.gradle.cache.internal.DefaultCacheAccess@79864311
Starting Build
Settings evaluated using settings file '/home/shaloin/AndroidStudioProjects/CodeSearch/settings.gradle'.
Projects loaded. Root project using build file '/home/shaloin/AndroidStudioProjects/CodeSearch/build.gradle'.
Included projects: [root project 'CodeSearch', project ':app']

> Configure project :
Evaluating root project 'CodeSearch' using build file '/home/shaloin/AndroidStudioProjects/CodeSearch/build.gradle'.
Creating new cache for metadata-1.1/results, path /home/shaloin/.gradle/caches/transforms-1/metadata-1.1/results.bin, access org.gradle.cache.internal.DefaultCacheAccess@740f0509
Creating new cache for metadata-2.23/module-metadata, path /home/shaloin/.gradle/caches/modules-2/metadata-2.23/module-metadata.bin, access org.gradle.cache.internal.DefaultCacheAccess@6663ad7c
Creating new cache for metadata-2.23/artifact-at-repository, path /home/shaloin/.gradle/caches/modules-2/metadata-2.23/artifact-at-repository.bin, access org.gradle.cache.internal.DefaultCacheAccess@6663ad7c

> Configure project :app
Evaluating project ':app' using build file '/home/shaloin/AndroidStudioProjects/CodeSearch/app/build.gradle'.
Creating configuration androidTestUtil
Creating configuration compile
Creating configuration apk
Creating configuration provided
Creating configuration api
Creating configuration implementation
Creating configuration runtimeOnly
Creating configuration compileOnly
Creating configuration wearApp
Creating configuration annotationProcessor
Creating configuration androidTestCompile
Creating configuration androidTestApk
Creating configuration androidTestProvided
Creating configuration androidTestApi
Creating configuration androidTestImplementation
Creating configuration androidTestRuntimeOnly
Creating configuration androidTestCompileOnly
Creating configuration androidTestWearApp
Creating configuration androidTestAnnotationProcessor
Creating configuration testCompile
Creating configuration testApk
Creating configuration testProvided
Creating configuration testApi
Creating configuration testImplementation
Creating configuration testRuntimeOnly
Creating configuration testCompileOnly
Creating configuration testWearApp
Creating configuration testAnnotationProcessor
Creating configuration debugCompile
Creating configuration debugApk
Creating configuration debugProvided
Creating configuration debugApi
Creating configuration debugImplementation
Creating configuration debugRuntimeOnly
Creating configuration debugCompileOnly
Creating configuration debugWearApp
Creating configuration debugAnnotationProcessor
Creating configuration androidTestDebugCompile
Creating configuration androidTestDebugApk
Creating configuration androidTestDebugProvided
Creating configuration androidTestDebugApi
Creating configuration androidTestDebugImplementation
Creating configuration androidTestDebugRuntimeOnly
Creating configuration androidTestDebugCompileOnly
Creating configuration androidTestDebugWearApp
Creating configuration androidTestDebugAnnotationProcessor
Creating configuration testDebugCompile
Creating configuration testDebugApk
Creating configuration testDebugProvided
Creating configuration testDebugApi
Creating configuration testDebugImplementation
Creating configuration testDebugRuntimeOnly
Creating configuration testDebugCompileOnly
Creating configuration testDebugWearApp
Creating configuration testDebugAnnotationProcessor
Creating configuration releaseCompile
Creating configuration releaseApk
Creating configuration releaseProvided
Creating configuration releaseApi
Creating configuration releaseImplementation
Creating configuration releaseRuntimeOnly
Creating configuration releaseCompileOnly
Creating configuration releaseWearApp
Creating configuration releaseAnnotationProcessor
Creating configuration testReleaseCompile
Creating configuration testReleaseApk
Creating configuration testReleaseProvided
Creating configuration testReleaseApi
Creating configuration testReleaseImplementation
Creating configuration testReleaseRuntimeOnly
Creating configuration testReleaseCompileOnly
Creating configuration testReleaseWearApp
Creating configuration testReleaseAnnotationProcessor
Parsing the SDK, no caching allowed
SDK initialized in 17 ms
Using incremental javac compilation for :app debug.
Using incremental javac compilation for :app debugUnitTest.
Using incremental javac compilation for :app release.
Using incremental javac compilation for :app releaseUnitTest.
Using incremental javac compilation for :app debugAndroidTest.

All projects evaluated.
Selected primary task 'assembleDebug' from project :
Creating new cache for annotation-processors, path /home/shaloin/AndroidStudioProjects/CodeSearch/.gradle/4.1/fileContent/annotation-processors.bin, access org.gradle.cache.internal.DefaultCacheAccess@72abf1bc
Tasks to be executed: [task ':app:preBuild', task ':app:preDebugBuild', task ':app:compileDebugAidl', task ':app:compileDebugRenderscript', task ':app:checkDebugManifest', task ':app:generateDebugBuildConfig', task ':app:prepareLintJar', task ':app:generateDebugResValues', task ':app:generateDebugResources', task ':app:mergeDebugResources', task ':app:createDebugCompatibleScreenManifests', task ':app:processDebugManifest', task ':app:splitsDiscoveryTaskDebug', task ':app:processDebugResources', task ':app:generateDebugSources', task ':app:javaPreCompileDebug', task ':app:compileDebugJavaWithJavac', task ':app:compileDebugNdk', task ':app:compileDebugSources', task ':app:mergeDebugShaders', task ':app:compileDebugShaders', task ':app:generateDebugAssets', task ':app:mergeDebugAssets', task ':app:transformClassesWithDexBuilderForDebug', task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug', task ':app:transformDexArchiveWithDexMergerForDebug', task ':app:mergeDebugJniLibFolders', task ':app:transformNativeLibsWithMergeJniLibsForDebug', task ':app:transformNativeLibsWithStripDebugSymbolForDebug', task ':app:processDebugJavaRes', task ':app:transformResourcesWithMergeJavaResForDebug', task ':app:validateSigningDebug', task ':app:packageDebug', task ':app:assembleDebug']
Creating new cache for resourceHashesCache, path /home/shaloin/AndroidStudioProjects/CodeSearch/.gradle/4.1/fileHashes/resourceHashesCache.bin, access org.gradle.cache.internal.DefaultCacheAccess@70f708a8
Creating new cache for fileSnapshots, path /home/shaloin/AndroidStudioProjects/CodeSearch/.gradle/4.1/taskHistory/fileSnapshots.bin, access org.gradle.cache.internal.DefaultCacheAccess@37a72cc7
Creating new cache for taskHistory, path /home/shaloin/AndroidStudioProjects/CodeSearch/.gradle/4.1/taskHistory/taskHistory.bin, access org.gradle.cache.internal.DefaultCacheAccess@37a72cc7
:app:preBuild (Thread[Task worker for ':',5,main]) started.

> Task :app:preBuild
Skipping task ':app:preBuild' as it has no actions.

:app:preBuild (Thread[Task worker for ':',5,main]) completed. Took 0.0 secs.
:app:preDebugBuild (Thread[Task worker for ':',5,main]) started.

> Task :app:preDebugBuild
Putting task artifact state for task ':app:preDebugBuild' into context took 0.0 secs.
Creating new cache for metadata-2.23/module-artifacts, path /home/shaloin/.gradle/caches/modules-2/metadata-2.23/module-artifacts.bin, access org.gradle.cache.internal.DefaultCacheAccess@6663ad7c
Skipping task ':app:preDebugBuild' as it is up-to-date (took 0.104 secs).

:app:preDebugBuild (Thread[Task worker for ':',5,main]) completed. Took 0.106 secs.
:app:compileDebugAidl (Thread[Task worker for ':' Thread 2,5,main]) started.

> Task :app:compileDebugAidl
Putting task artifact state for task ':app:compileDebugAidl' into context took 0.0 secs.
Skipping task ':app:compileDebugAidl' as it is up-to-date (took 0.012 secs).

:app:compileDebugAidl (Thread[Task worker for ':' Thread 2,5,main]) completed. Took 0.013 secs.
:app:compileDebugRenderscript (Thread[Task worker for ':' Thread 2,5,main]) started.

> Task :app:compileDebugRenderscript
Putting task artifact state for task ':app:compileDebugRenderscript' into context took 0.0 secs.
Skipping task ':app:compileDebugRenderscript' as it is up-to-date (took 0.006 secs).

:app:compileDebugRenderscript (Thread[Task worker for ':' Thread 2,5,main]) completed. Took 0.007 secs.
:app:checkDebugManifest (Thread[Task worker for ':' Thread 3,5,main]) started.

> Task :app:checkDebugManifest
Putting task artifact state for task ':app:checkDebugManifest' into context took 0.0 secs.
Skipping task ':app:checkDebugManifest' as it is up-to-date (took 0.001 secs).

:app:checkDebugManifest (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.001 secs.
:app:generateDebugBuildConfig (Thread[Task worker for ':' Thread 3,5,main]) started.

> Task :app:generateDebugBuildConfig
Putting task artifact state for task ':app:generateDebugBuildConfig' into context took 0.0 secs.
Skipping task ':app:generateDebugBuildConfig' as it is up-to-date (took 0.004 secs).

:app:generateDebugBuildConfig (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.004 secs.
:app:prepareLintJar (Thread[Daemon worker Thread 2,5,main]) started.

> Task :app:prepareLintJar
Putting task artifact state for task ':app:prepareLintJar' into context took 0.0 secs.
Skipping task ':app:prepareLintJar' as it is up-to-date (took 0.005 secs).

:app:prepareLintJar (Thread[Daemon worker Thread 2,5,main]) completed. Took 0.005 secs.
:app:generateDebugResValues (Thread[Daemon worker Thread 2,5,main]) started.

> Task :app:generateDebugResValues
Putting task artifact state for task ':app:generateDebugResValues' into context took 0.0 secs.
Skipping task ':app:generateDebugResValues' as it is up-to-date (took 0.001 secs).

:app:generateDebugResValues (Thread[Daemon worker Thread 2,5,main]) completed. Took 0.002 secs.
:app:generateDebugResources (Thread[Daemon worker Thread 2,5,main]) started.

> Task :app:generateDebugResources
Skipping task ':app:generateDebugResources' as it has no actions.

:app:generateDebugResources (Thread[Daemon worker Thread 2,5,main]) completed. Took 0.001 secs.
:app:mergeDebugResources (Thread[Daemon worker Thread 2,5,main]) started.

> Task :app:mergeDebugResources
Putting task artifact state for task ':app:mergeDebugResources' into context took 0.0 secs.
Skipping task ':app:mergeDebugResources' as it is up-to-date (took 0.042 secs).

:app:mergeDebugResources (Thread[Daemon worker Thread 2,5,main]) completed. Took 0.043 secs.
:app:createDebugCompatibleScreenManifests (Thread[Task worker for ':' Thread 2,5,main]) started.

> Task :app:createDebugCompatibleScreenManifests
Putting task artifact state for task ':app:createDebugCompatibleScreenManifests' into context took 0.0 secs.
Skipping task ':app:createDebugCompatibleScreenManifests' as it is up-to-date (took 0.001 secs).

:app:createDebugCompatibleScreenManifests (Thread[Task worker for ':' Thread 2,5,main]) completed. Took 0.002 secs.
:app:processDebugManifest (Thread[Task worker for ':' Thread 2,5,main]) started.

> Task :app:processDebugManifest
Putting task artifact state for task ':app:processDebugManifest' into context took 0.0 secs.
Skipping task ':app:processDebugManifest' as it is up-to-date (took 0.005 secs).

:app:processDebugManifest (Thread[Task worker for ':' Thread 2,5,main]) completed. Took 0.008 secs.
:app:splitsDiscoveryTaskDebug (Thread[Task worker for ':' Thread 2,5,main]) started.

> Task :app:splitsDiscoveryTaskDebug
Putting task artifact state for task ':app:splitsDiscoveryTaskDebug' into context took 0.0 secs.
Skipping task ':app:splitsDiscoveryTaskDebug' as it is up-to-date (took 0.001 secs).

:app:splitsDiscoveryTaskDebug (Thread[Task worker for ':' Thread 2,5,main]) completed. Took 0.001 secs.
:app:processDebugResources (Thread[Task worker for ':' Thread 2,5,main]) started.

> Task :app:processDebugResources
Putting task artifact state for task ':app:processDebugResources' into context took 0.001 secs.
Skipping task ':app:processDebugResources' as it is up-to-date (took 0.028 secs).

:app:processDebugResources (Thread[Task worker for ':' Thread 2,5,main]) completed. Took 0.029 secs.
:app:generateDebugSources (Thread[Daemon worker Thread 2,5,main]) started.

> Task :app:generateDebugSources
Skipping task ':app:generateDebugSources' as it has no actions.

:app:generateDebugSources (Thread[Daemon worker Thread 2,5,main]) completed. Took 0.0 secs.
:app:javaPreCompileDebug (Thread[Daemon worker Thread 2,5,main]) started.

> Task :app:javaPreCompileDebug
Putting task artifact state for task ':app:javaPreCompileDebug' into context took 0.0 secs.
Skipping task ':app:javaPreCompileDebug' as it is up-to-date (took 0.008 secs).

:app:javaPreCompileDebug (Thread[Daemon worker Thread 2,5,main]) completed. Took 0.009 secs.
:app:compileDebugJavaWithJavac (Thread[Task worker for ':' Thread 3,5,main]) started.

> Task :app:compileDebugJavaWithJavac
Putting task artifact state for task ':app:compileDebugJavaWithJavac' into context took 0.001 secs.
file or directory '/home/shaloin/AndroidStudioProjects/CodeSearch/app/src/debug/java', not found
Skipping task ':app:compileDebugJavaWithJavac' as it is up-to-date (took 0.009 secs).

:app:compileDebugJavaWithJavac (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.012 secs.
:app:compileDebugNdk (Thread[Task worker for ':',5,main]) started.

> Task :app:compileDebugNdk
Putting task artifact state for task ':app:compileDebugNdk' into context took 0.0 secs.
Skipping task ':app:compileDebugNdk' as it has no source files and no previous output files.

:app:compileDebugNdk (Thread[Task worker for ':',5,main]) completed. Took 0.001 secs.
:app:compileDebugSources (Thread[Task worker for ':',5,main]) started.

> Task :app:compileDebugSources
Skipping task ':app:compileDebugSources' as it has no actions.

:app:compileDebugSources (Thread[Task worker for ':',5,main]) completed. Took 0.0 secs.
:app:mergeDebugShaders (Thread[Task worker for ':',5,main]) started.

> Task :app:mergeDebugShaders
Putting task artifact state for task ':app:mergeDebugShaders' into context took 0.0 secs.
Skipping task ':app:mergeDebugShaders' as it is up-to-date (took 0.001 secs).

:app:mergeDebugShaders (Thread[Task worker for ':',5,main]) completed. Took 0.002 secs.
:app:compileDebugShaders (Thread[Task worker for ':',5,main]) started.

> Task :app:compileDebugShaders
Putting task artifact state for task ':app:compileDebugShaders' into context took 0.0 secs.
Skipping task ':app:compileDebugShaders' as it is up-to-date (took 0.001 secs).

:app:compileDebugShaders (Thread[Task worker for ':',5,main]) completed. Took 0.001 secs.
:app:generateDebugAssets (Thread[Task worker for ':',5,main]) started.

> Task :app:generateDebugAssets
Skipping task ':app:generateDebugAssets' as it has no actions.

:app:generateDebugAssets (Thread[Task worker for ':',5,main]) completed. Took 0.0 secs.
:app:mergeDebugAssets (Thread[Task worker for ':',5,main]) started.

> Task :app:mergeDebugAssets
Putting task artifact state for task ':app:mergeDebugAssets' into context took 0.0 secs.
Skipping task ':app:mergeDebugAssets' as it is up-to-date (took 0.006 secs).

:app:mergeDebugAssets (Thread[Task worker for ':',5,main]) completed. Took 0.006 secs.
:app:transformClassesWithDexBuilderForDebug (Thread[Task worker for ':',5,main]) started.

> Task :app:transformClassesWithDexBuilderForDebug
Putting task artifact state for task ':app:transformClassesWithDexBuilderForDebug' into context took 0.0 secs.
Skipping task ':app:transformClassesWithDexBuilderForDebug' as it is up-to-date (took 0.015 secs).

:app:transformClassesWithDexBuilderForDebug (Thread[Task worker for ':',5,main]) completed. Took 0.015 secs.
:app:transformDexArchiveWithExternalLibsDexMergerForDebug (Thread[Task worker for ':' Thread 3,5,main]) started.

> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug
Putting task artifact state for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' into context took 0.0 secs.
Skipping task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' as it is up-to-date (took 0.005 secs).

:app:transformDexArchiveWithExternalLibsDexMergerForDebug (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.006 secs.
:app:transformDexArchiveWithDexMergerForDebug (Thread[Task worker for ':' Thread 3,5,main]) started.

> Task :app:transformDexArchiveWithDexMergerForDebug
Putting task artifact state for task ':app:transformDexArchiveWithDexMergerForDebug' into context took 0.0 secs.
Skipping task ':app:transformDexArchiveWithDexMergerForDebug' as it is up-to-date (took 0.004 secs).

:app:transformDexArchiveWithDexMergerForDebug (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.005 secs.
:app:mergeDebugJniLibFolders (Thread[Task worker for ':' Thread 3,5,main]) started.

> Task :app:mergeDebugJniLibFolders
Putting task artifact state for task ':app:mergeDebugJniLibFolders' into context took 0.0 secs.
Skipping task ':app:mergeDebugJniLibFolders' as it is up-to-date (took 0.001 secs).

:app:mergeDebugJniLibFolders (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.003 secs.
:app:transformNativeLibsWithMergeJniLibsForDebug (Thread[Task worker for ':' Thread 3,5,main]) started.

> Task :app:transformNativeLibsWithMergeJniLibsForDebug
Putting task artifact state for task ':app:transformNativeLibsWithMergeJniLibsForDebug' into context took 0.0 secs.
Skipping task ':app:transformNativeLibsWithMergeJniLibsForDebug' as it is up-to-date (took 0.012 secs).

:app:transformNativeLibsWithMergeJniLibsForDebug (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.013 secs.
:app:transformNativeLibsWithStripDebugSymbolForDebug (Thread[Task worker for ':' Thread 3,5,main]) started.

> Task :app:transformNativeLibsWithStripDebugSymbolForDebug
Putting task artifact state for task ':app:transformNativeLibsWithStripDebugSymbolForDebug' into context took 0.0 secs.
Skipping task ':app:transformNativeLibsWithStripDebugSymbolForDebug' as it is up-to-date (took 0.011 secs).

:app:transformNativeLibsWithStripDebugSymbolForDebug (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.012 secs.
:app:processDebugJavaRes (Thread[Task worker for ':' Thread 3,5,main]) started.

> Task :app:processDebugJavaRes
Putting task artifact state for task ':app:processDebugJavaRes' into context took 0.0 secs.
Skipping task ':app:processDebugJavaRes' as it has no source files and no previous output files.

:app:processDebugJavaRes (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.002 secs.
:app:transformResourcesWithMergeJavaResForDebug (Thread[Task worker for ':' Thread 3,5,main]) started.

> Task :app:transformResourcesWithMergeJavaResForDebug
Putting task artifact state for task ':app:transformResourcesWithMergeJavaResForDebug' into context took 0.0 secs.
Skipping task ':app:transformResourcesWithMergeJavaResForDebug' as it is up-to-date (took 0.013 secs).

:app:transformResourcesWithMergeJavaResForDebug (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.015 secs.
:app:validateSigningDebug (Thread[Daemon worker Thread 2,5,main]) started.

> Task :app:validateSigningDebug
Putting task artifact state for task ':app:validateSigningDebug' into context took 0.0 secs.
Executing task ':app:validateSigningDebug' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.

:app:validateSigningDebug (Thread[Daemon worker Thread 2,5,main]) completed. Took 0.009 secs.
:app:packageDebug (Thread[Daemon worker Thread 2,5,main]) started.

> Task :app:packageDebug
Putting task artifact state for task ':app:packageDebug' into context took 0.0 secs.
Skipping task ':app:packageDebug' as it is up-to-date (took 0.023 secs).

:app:packageDebug (Thread[Daemon worker Thread 2,5,main]) completed. Took 0.027 secs.
:app:assembleDebug (Thread[Daemon worker Thread 2,5,main]) started.

> Task :app:assembleDebug
Skipping task ':app:assembleDebug' as it has no actions.

:app:assembleDebug (Thread[Daemon worker Thread 2,5,main]) completed. Took 0.001 secs.

BUILD SUCCESSFUL in 1s
26 actionable tasks: 1 executed, 25 up-to-date

谁能帮我解决这个问题?

【问题讨论】:

  • 你能执行./gradlew assembleDebug --info并发布整个日志吗?
  • @Christopher,因为我是新手,请告诉我在哪里执行命令?
  • 只是在 shell/终端/bash 中,您的项目根目录作为当前目录。
  • @Christopher,我已经更新了我的问题

标签: android gradle android-gradle-plugin build.gradle


【解决方案1】:

解决方案 1(这不是我的答案,归功于 useruser

原因原来是我在“运行/调试配置”对话框中定义了一个新的配置,并将build.gradle文件的完整路径放到Gradle项目:字段中,如下。 (我通过单击字段右侧的省略号 (...) 按钮来完成此操作,但我也可以直接输入。)

但是,我应该做的是遵循现有配置中的模式,其中 Gradle 项目:被指定为“注册项目”,方法是单击字段右侧的“文件夹”图标,在下图。在这种情况下,该字段的内容只是项目名称,并以略微不同的背景/前景颜色显示。 (我无意中发现右键这个名字会替换成包含build.gradle的文件夹的路径,但是如果你取消重新开始编辑配置,它仍然会显示为只是项目名称。)

gradle.properties 之后插入下面的行(所有功劳归于user):

org.gradle.jvmargs=-Xmx1536m
org.gradle.java.home=${path to java sdk}

你可以通过以下方式获取java sdk的路径 步骤(reference):

第 1 步

$ whereis java
java: /usr/bin/java /etc/java /usr/share/java

第 2 步

$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2009-01-15 18:34 /usr/bin/java -> 
/etc/alternatives/java

第 3 步

$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 31 2009-01-15 18:34 /etc/alternatives/java -> 
/usr/local/jre1.6.0_07/bin/java

java的实际位置:/usr/local/jre.....

在我的情况下,sdk 存在于 /usr/lib/jvm/java-1.7.0-openjdk-amd64 中,我只是将 ${path to java sdk} 替换为 /usr/lib/jvm/java-1.7.0-openjdk-amd64 就这样,我很高兴。

解决方案 2

上述解决方案对我有用,但我也尝试卸载然后重新安装 android studio。它也有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-20
    • 2019-10-18
    • 2010-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多