Articles of gradle

BSOD之后的Gradle构建错误(java.lang.NullPointerException(无错误消息)

在BSOD(蓝屏死机)之后我有下一个gradle构建错误:FAILURE:构建失败并出现exception。 出了什么问题:java.lang.NullPointerException(没有错误消息) 尝试:使用–info或–debug选项运行以获取更多日志输出。 例外情况是: java.lang.NullPointerException at org.gradle.api.internal.changedetection.state.TreeSnapshotRepository.removeTreeSnapshotUsage(TreeSnapshotRepository.java:85) at org.gradle.api.internal.changedetection.state.CacheBackedFileSnapshotRepository.remove(CacheBackedFileSnapshotRepository.java:47) at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository$1$1.run(CacheBackedTaskHistoryRepository.java:81) at org.gradle.internal.Factories$1.create(Factories.java:22) at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:192) at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175) at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106) at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187) at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:60) at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository$1.update(CacheBackedTaskHistoryRepository.java:66) at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.afterTask(DefaultTaskArtifactStateRepository.java:135) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:68) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110) at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) […]

android studio无法解析导入org.json.JSONObject

我使用libgdx来构建我的项目,我在使用JSONObject类时遇到了问题。 当我添加import org.json.JSONObject ,它说它无法解析。 如何将该库添加到我的项目中? 这是我尝试过的没有成功: 我下载了json-simple-1.1.jar并将其放在core / build / libs文件夹中。 无法使用import.org.json.simple.JSONObject 。 当在Android Studio中浏览树作为“Packages”下拉列表时,我可以在”Core -> Libraries -> org -> json”下看到我想要的类,但我无法将它们添加到我的项目中。 我得到一个“不能折射,类是在一个jar文件”错误。 有没有我还没有尝试解决这个问题? 当我尝试使用其他外部库时,我觉得我会再遇到这个问题。 谢谢。

错误:在 SherlockSpinner中,无法find属性android:popupPromptView

我的项目包含“ActionBar Sherlock Pull to refresh”并使用API​​级别21及更早版本进行编译和运行,但是当我尝试使用API​​ 22编译它时,我收到此错误: Error:In SherlockSpinner, unable to find attribute android:popupPromptView Error:Execution failed for task ‘:app:processDebugResources’. com.android.ide.common.internal.LoggedErrorException:无法运行命令:/Users/m./Android_SDK/build-tools/21.1.2/aapt package -f –no-crunch -I /Users/m./ Android_SDK / platforms / android-22 / android.jar -M /Users/m./AndroidStudioProjects/-android/android/build/intermediates/manifests/full/debug/AndroidManifest.xml-S/Users/m./AndroidStudioProjects/- android / android / build / intermediates / res / debug -A /Users/m./AndroidStudioProjects/-android/android/build/intermediates/assets/debug -m -J /Users/m./AndroidStudioProjects/-android/android/ build / generated / source / […]

打开/解压缩zip文件时出现Cordova Build Gradle Error

当我运行:cordova build,我得到了这个: Running command:/Users/tyrant/workspace/ideaProject/hello/platforms/android/cordova/build ANDROID_HOME=/Users/tyrant/software/android/android-sdk-macosx JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home Running:/Users/tyrant/workspace/ideaProject/hello/platforms/android/gradlew cdvBuildDebug -b /Users/tyrant/workspace/ideaProject/hello/platforms/android/build.gradle -Dorg.gradle.daemon=true Deleting directory /Users/tyrant/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1 Unzipping /Users/tyrant/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1-all.zip to /Users/tyrant/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b Exception in thread “main” java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file atorg.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78) at org.gradle.wrapper.Install.createDist(Install.java:47) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48) Caused by: java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:215) at java.util.zip.ZipFile.(ZipFile.java:145) at java.util.zip.ZipFile.(ZipFile.java:159) at org.gradle.wrapper.Install.unzip(Install.java:160) […]

Android Studio:“任务执行失败”:app:mergeDebugResources’“如果在驱动器C上创建项目:

我在当前项目中添加了Google Play服务作为依赖项。 如果我将项目保存在C:驱动器上,则在同步项目时会出现以下错误: Error: Execution failed for task ‘:app:mergeDebugResources’. > Error: Failed to run command: C:\Program Files (x86)\Android\android-studio\sdk\build-tools\android-4.4.2\aapt.exe s -i C:\Users\ashokp\Desktop\Studio\AndroidV2SDK_AndroidStudioFormat\Google Play Services\SampleApplication\AndroidV2SDKSampleApp_GooglePlayServices\app\build\exploded-aar\com.google.android.gms\play-services\4.3.23\res\drawable-hdpi\common_signin_btn_text_focus_light.9.png -o C:\Users\ashokp\Desktop\Studio\AndroidV2SDK_AndroidStudioFormat\Google Play Services\SampleApplication\AndroidV2SDKSampleApp_GooglePlayServices\app\build\res\all\debug\drawable-hdpi\common_signin_btn_text_focus_light.9.png Error Code: 42 仅当项目保存在C:驱动器上时才会发生这种情况。 如果我将它保存到其他驱动器,它可以完美地工作。 还有其他人面临这个问题吗? 是什么导致这个? 我该如何解决/规避这个问题?

为什么Android会在Gradle依赖项中将“编译”更改为“实现”配置?

如在Android Studio 3.0(canary 3.0)中所见,我们现在通过声明implementation而不是compile配置来添加depedencies 。 // Before compile ‘com.android.support:appcompat-v7:25.3.1’ // Currently implementation ‘com.android.support:appcompat-v7:25.3.1’ 我们仍然可以使用compile ,但我想了解: implementation和compile配置有什么区别? 为什么Android Gradle构建更改以将implementation用作默认值?

如何在Gradle中更改libs目录?

我想将Zbar集成到我的应用程序中,但似乎无法弄清楚如何使用新的Android Studio实现这一目标。 我已经查看了示例并已复制代码而没有任何问题。 我遇到的问题是将libs添加到我的项目中我似乎无法弄清楚如何做到这一点。 有人可以带我走过吗?

Android – 如何获得Flavor的ApplicationId

我正在构建一个具有不同构建变体风格的应用程序。 口味是“免费”和“付费”。 我想在我的java类上创建一些逻辑,只有在应用程序为“付费”时才会触发。 因此,我需要一种方法来在gradle构建过程中设置“applicationId”,如下所示: gradle.build productFlavors { free { applicationId “com.example.free” resValue “string”, “app_name”, “Free App” versionName “1.0-free” } paid { applicationId “com.example.paid” resValue “string”, “app_name”, “Paid App” versionName “1.0-paid” } 一旦我有了应用程序ID,我就可以这样做: if(whateverpackageid.equals(“paid”)) { // Do something or trigger some premium functionality. } 我是否正确地说,在gradle构建过程中,“applicationId”最终会在应用程序编译后成为“包名”? 如果是这样,获得“应用程序ID”或“包名称”的最佳方法是什么,以便我可以在我的java文件中实现一些与风味相关的逻辑?

Gradle sync失败:原因:打开zip文件时出错Corrupt Dependency Cache

嘿伙计我是Android Studio的新手,刚刚开始学习Udacity的这个在线课程“开发Android应用程序”。问题是我正在开发的项目与“ Sunshine ”课程保持一致,未能正确同步。 .. 这是事件日志中显示的消息.. Gradle sync失败:原因:打开zip文件时出错 日志的完整描述: **2017-03-04 08:14:32,358 [ 61978] WARN – nal.AbstractExternalSystemTask – Cause: error in opening zip file com.intellij.openapi.externalSystem.model.ExternalSystemException: Cause: **error in opening zip file** at com.android.tools.idea.gradle.project.sync.idea.ProjectImportErrorHandler.getUserFriendlyError(ProjectImportErrorHandler.java:86) at com.android.tools.idea.gradle.project.sync.idea.AndroidGradleProjectResolver.getUserFriendlyError(AndroidGradleProjectResolver.java:361) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:769) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:749) at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:227) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:112) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:72) at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.lambda$resolveProjectInfo$0(RemoteExternalSystemProjectResolverImpl.java:37) at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59) at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37) at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49) at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51) at […]

Android Studio:整合Butterknife?

我正在尝试将Butterknife实现到我的android工作室项目中。 但是,当我这样做时,我在@InjectView上收到错误“无法解析符号InjectView”。 我没有成功地实施Butterknife吗? 活动代码: package com.example.rodf.testapp; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends ActionBarActivity { @InjectView(R.id.tvHelloWorld) TextView tv1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } 布局: gradle文件: apply plugin: ‘com.android.application’ android { compileSdkVersion 21 buildToolsVersion “21.1.2” defaultConfig { applicationId “com.example.rodf.testapp” minSdkVersion 15 targetSdkVersion 21 versionCode 1 versionName […]