I want to run some groovy scripts before gradle builds debug apk in Android.
task batchTask(type: JavaExec) {
description 'running tasks'
exec {
commandLine './Batch.groovy'
}
}
added this to build.gradle(app)
apply plugin: 'groovyx.grooid.groovy-android'
android{
...
dependsOn {
batchTask
}
}
dependencies {
...
compile 'org.codehaus.groovy:groovy:2.4.0:grooid'
}
added this to build.grade(android)
dependencies {
...
classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6'
}
I keep getting the error Error:Cause: error=13, Permission denied
stack trace
15:24:22.688 [DEBUG] [org.gradle.process.internal.DefaultExecHandle]
Changing state to: STARTING 15:24:22.689 [DEBUG]
[org.gradle.process.internal.DefaultExecHandle] Waiting until process
started: command './Batch.groovy'. 15:24:22.693 [DEBUG]
[org.gradle.process.internal.DefaultExecHandle] Changing state to:
FAILED 15:24:22.693 [DEBUG]
[org.gradle.process.internal.DefaultExecHandle] Process 'command
'./Batch.groovy'' finished with exit value -1 (state: FAILED)
15:24:22.695 [DEBUG]
[org.gradle.configuration.project.BuildScriptProcessor] Timing:
Running the build script took 1.866 secs 15:24:22.798 [ERROR]
[org.gradle.BuildExceptionReporter] 15:24:22.799 [ERROR]
[org.gradle.BuildExceptionReporter] FAILURE: Build failed with an
exception. 15:24:22.799 [ERROR] [org.gradle.BuildExceptionReporter]
15:24:22.800 [ERROR] [org.gradle.BuildExceptionReporter] * What went
wrong: 15:24:22.800 [ERROR] [org.gradle.BuildExceptionReporter] A
problem occurred evaluating project ':app'. 15:24:22.800 [ERROR]
[org.gradle.BuildExceptionReporter] > A problem occurred starting
process 'command './Batch.groovy'' 15:24:22.801 [ERROR]
[org.gradle.BuildExceptionReporter] 15:24:22.801 [ERROR]
[org.gradle.BuildExceptionReporter] * Try: 15:24:22.801 [ERROR]
[org.gradle.BuildExceptionReporter] Run with --stacktrace option to
get the stack trace. 15:24:22.802 [LIFECYCLE]
[org.gradle.BuildResultLogger] 15:24:22.802 [LIFECYCLE]
[org.gradle.BuildResultLogger] BUILD FAILED
Update:
Running the task inside a Groovy shell did the trick.
task batchTask(type: JavaExec) {
description 'batchTask in progress'
new GroovyShell().run(file('Batch.groovy'))
}
Running the task inside a Groovy shell did the trick.
task batchTask(type: JavaExec) {
description 'batchTask in progress'
new GroovyShell().run(file('Batch.groovy'))
}
Related
how to proguard with intellij idea gradle intellij-plugin?
use the code can not work for me !
config build.gradle
def ideaPath = "D:/java/ideaIU-2022.1.3.win"
task proguard(type: ProGuardTask) {
// dependsOn intelli
verbose
// injars "${buildDir}/libs/xxx-1.4.8.jar"
injars "${buildDir}/classes/java/main"
outjars "${buildDir}/libs/xxx-1.4.8-obfuscatedClasses.jar"
// Automatically handle the Java version of this build.
if (System.getProperty('java.version').startsWith('1.')) {
// Before Java 9, the runtime classes were packaged in a single jar file.
libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
} else {
// As of Java 9, the runtime classes are packaged in modular jmod files.
libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${System.getProperty('java.home')}/jmods/java.sql.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${System.getProperty('java.home')}/jmods/java.desktop.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
//libraryjars "${System.getProperty('java.home')}/jmods/....."
}
// This will contain the Spring dependencies.
libraryjars sourceSets.main.compileClasspath
// libraryjars fileTree("$ideaPath/plugins/java/lib").filter { !it.name.startsWith("debugger") }.collect()
// libraryjars files("$ideaPath/lib")
dontnote 'kotlin.**'
dontnote 'kotlinx.**'
dontnote 'org.intellij.**'
dontnote 'com.intellij.**'
dontnote 'com.google.gson.**'
dontnote 'proguard.configuration.ConfigurationLogger'
dontobfuscate
optimizationpasses 10
keepclasseswithmembers 'public class * { \
public static void main(java.lang.String[]); \
}'
// Keep the main class entry point.
keep 'public class com.example.demo.DemoApplication { \
public static void main(java.lang.String[]); \
}'
keepattributes '*Annotation*'
// This simple example requires classes with #Component annotation classes
// to be kept, since otherwise components could end up with clashing names,
// if they do not set the name explicitly.
keep 'public #org.springframework.stereotype.Component class *'
// You may need to keep classes or members based on other annotations such as:
keepclassmembers 'public class * { \
#org.springframework.beans.factory.annotation.Autowired *; \
#org.springframework.beans.factory.annotation.Value *; \
}'
// After ProGuard has executed, repackage the app.
// finalizedBy tasks.repackage
}
Are there any examples that can be executed?
My idea Version: ideaIU-2022.1.3.win
Java Version:
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment JBR-11.0.15.10-2043.56-jcef (build 11.0.15+10-b2043.56)
OpenJDK 64-Bit Server VM JBR-11.0.15.10-2043.56-jcef (build 11.0.15+10-b2043.56, mixed mode)
Gralde Version: gradle-7.5.1
the error message:
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':proguard'.
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.io.IOException: Please correct the above warnings first.
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --stacktrace option to get the stack trace.
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --scan to get full insights.
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
2022-08-10T11:20:00.704+0800 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 10s
11:20:00: 'proguard --debug'。
Thks!
I've got a Maven project for a java application. The software versions I'm using are following:
Maven 3.6.3, Java 1.8.0_241.
I've got few junit tests within this Maven project, that I'm trying to run using the Maven "mvn" command. When I run the command "mvn clean test" on my Maven project to run my unit tests, I get below mentioned build failure.
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:48 min
[INFO] Finished at: 2020-02-21T09:37:00+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project Myproject-restapis: There are test failures.
[ERROR]
[ERROR] Please refer to F:\eclipseWorkspaces\my_project\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C "C:\jdk1.8.0_241\jre\bin\java -jar C:\Users\mukul\AppData\Local\Temp\surefire4895736141834565700\surefirebooter185004090178601900.jar C:\Users\mukul\AppData\Local\Temp\surefire4895736141834565700 2020-02-21T09-34-41_267-jvmRun1 surefire413243705282645614tmp surefire_01613681214173913161tmp"
[ERROR] Process Exit Code: 0
[ERROR] Crashed tests:
[ERROR] com.example.test.SampleTest
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C "C:\jdk1.8.0_241\jre\bin\java -jar C:\Users\mukul\AppData\Local\Temp\surefire4895736141834565700\surefirebooter185004090178601900.jar C:\Users\mukul\AppData\Local\Temp\surefire4895736141834565700 2020-02-21T09-34-41_267-jvmRun1 surefire413243705282645614tmp surefire_01613681214173913161tmp"
[ERROR] Process Exit Code: 0
[ERROR] Crashed tests:
[ERROR] com.example.test.SampleTest
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1183)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1011)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:857)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
I've looked a lot on web about the above mentioned issue, but haven't been able to solve this for few days now.
The command 'mvn clean install -DskipTests' runs fine for me, and I get build success.
Can anyone please try to provide solution for the above mentioned issue, with the Maven command 'mvn clean test'.
Well, I had the exactly same issue, and the way that I sorted it out was to configure log properly for my tests..
I have a multi-module project, and I added a logback-test.xml in the root my my parent project and pointed my maven-surefire-plugin to load this file. See the config bellow:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dlogback.configurationFile=${project.basedir}/../logback-test.xml</argLine>
</configuration>
</plugin>
In the logbook-test.xml I reduced a lot of the logs and added some library packages to print from WARN level.
<logger name="org.apache.solr" level="WARN" />
Important: Make sure you replace all System.out.println with log.debug
When I add import org.springframework.data.annotation.Id; to my Java file I get this error:
The import org.springframework.data cannot be resolved
My immediate thought is that I'm missing a dependency but I don't think this is the case.
Here's the dependencies from my build.gradle.
dependencies {
compile('org.springframework.boot:spring-boot-starter-webflux')
compile('org.synchronoss.cloud:nio-multipart-parser')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.springframework.boot:spring-boot-starter-data-mongodb-reactive')
compile('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('io.projectreactor:reactor-test')
}
Also, I've applied these plugins:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
Am I missing something, or how do I get past this issue?
Additional Info.
I ran ./gradlew clean build --refresh-dependencies --debug. Here is an extract from the log:
22:25:30.664 [ERROR] [system.err] /Users/me/git/learning-spring-boot/learning-spring-boot-ch2/src/main/java/com/greglturnquist/learningspringboot/learningspringboot/ImageService.java:40: error: constructor Image in class Image cannot be applied to given types;
22:25:30.664 [ERROR] [system.err] new Image(path.hashCode(),
22:25:30.664 [ERROR] [system.err] ^
22:25:30.664 [ERROR] [system.err] required: String
22:25:30.665 [ERROR] [system.err] found: int,String
22:25:30.665 [ERROR] [system.err] reason: actual and formal argument lists differ in length
22:25:30.698 [ERROR] [system.err] /Users/me/git/learning-spring-boot/learning-spring-boot-ch2/src/main/java/com/greglturnquist/learningspringboot/learningspringboot/ApiController.java:26: error: constructor Image in class Image cannot be applied to given types;
22:25:30.700 [ERROR] [system.err] new Image("1", "learning-spring-boot-cover.jpg"),
22:25:30.700 [ERROR] [system.err] ^
22:25:30.700 [ERROR] [system.err] required: String
22:25:30.700 [ERROR] [system.err] found: String,String
22:25:30.701 [ERROR] [system.err] reason: actual and formal argument lists differ in length
22:25:30.701 [ERROR] [system.err] /Users/me/git/learning-spring-boot/learning-spring-boot-ch2/src/main/java/com/greglturnquist/learningspringboot/learningspringboot/ApiController.java:27: error: constructor Image in class Image cannot be applied to given types;
22:25:30.701 [ERROR] [system.err] new Image("2", "learning-spring-boot-2nd-edition-cover.jpg"),
22:25:30.702 [ERROR] [system.err] ^
22:25:30.702 [ERROR] [system.err] required: String
22:25:30.702 [ERROR] [system.err] found: String,String
22:25:30.702 [ERROR] [system.err] reason: actual and formal argument lists differ in length
22:25:30.705 [ERROR] [system.err] /Users/me/git/learning-spring-boot/learning-spring-boot-ch2/src/main/java/com/greglturnquist/learningspringboot/learningspringboot/ApiController.java:28: error: constructor Image in class Image cannot be applied to given types;
22:25:30.706 [ERROR] [system.err] new Image("3", "bazinga.png")
22:25:30.706 [ERROR] [system.err] ^
22:25:30.706 [ERROR] [system.err] required: String
22:25:30.706 [ERROR] [system.err] found: String,String
22:25:30.707 [ERROR] [system.err] reason: actual and formal argument lists differ in length
22:25:30.713 [ERROR] [system.err] 4 errors
22:25:30.716 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Execute compile for :compileJava'
22:25:30.726 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute compile for :compileJava' completed
22:25:30.733 [DEBUG] [org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository] Fingerprinting property destinationDir (Output) for task ':compileJava'
22:25:30.737 [LIFECYCLE] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache]
22:25:30.737 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Opening cache fileHashes.bin (/Users/me/git/learning-spring-boot/learning-spring-boot-ch2/.gradle/4.10.2/fileHashes/fileHashes.bin)
22:25:30.702 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger]
22:25:30.702 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :compileJava FAILED
22:25:30.738 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
22:25:30.739 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':compileJava'
22:25:30.740 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Task :compileJava'
22:25:30.740 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Task :compileJava' completed
22:25:30.741 [INFO] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] :compileJava (Thread[Task worker for ':',5,main]) completed. Took 59.344 secs.
22:25:30.741 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Task worker for ':': released lock on :
22:25:30.742 [DEBUG] [org.gradle.internal.work.DefaultWorkerLeaseService] Worker lease root.1.13 completed (1 worker(s) in use)
22:25:30.743 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Task worker for ':': released lock on root.1.13
22:25:30.743 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Daemon worker Thread 7,5,main]] finished, busy: 0.0 secs, idle: 59.358 secs
22:25:30.744 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':',5,main]] finished, busy: 59.353 secs, idle: 0.006 secs
22:25:30.743 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 3,5,main]] finished, busy: 0.0 secs, idle: 59.358 secs
22:25:30.743 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] Task worker [Thread[Task worker for ':' Thread 2,5,main]] finished, busy: 0.0 secs, idle: 59.36 secs
22:25:30.748 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskExecutionGraph] Timing: Executing the DAG took 59.365 secs
22:25:30.748 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Run tasks'
22:25:30.748 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Run tasks' completed
22:25:30.749 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
22:25:30.750 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
22:25:30.750 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
22:25:30.750 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
22:25:30.750 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':compileJava'.
22:25:30.750 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Compilation failed; see the compiler error output for details.
22:25:30.750 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
22:25:30.750 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
22:25:30.751 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. Run with --scan to get full insights.
22:25:30.751 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
22:25:30.751 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
22:25:30.751 [WARN] [org.gradle.internal.featurelifecycle.LoggingDeprecatedFeatureHandler]
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings
22:25:30.751 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
22:25:30.751 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 1m 47s
I checked ./gradlew dependencies org.springframework.boot:spring-boot-starter-data-mongodb-reactive -> 2.2.0.BUILD-SNAPSHOT contains org.springframework.data:spring-data-mongodb:2.1.4.BUILD-SNAPSHOT which contains org.springframework:spring-context:5.1.3.RELEASE -> 5.1.4.BUILD-SNAPSHOT. Is it possible org.springframework:spring-context:5.1.3.RELEASE -> 5.1.4.BUILD-SNAPSHOT is not a compatible version?
This class org.springframework.data.annotation.Id belongs to the Spring module org.springframework.data:spring-data-commons. So if you want to import classes from this module you should add a dependency to it:
dependencies{
compile("org.springframework.data:spring-data-commons")
// others ...
}
Note you should also be able to import this class without this explicit dependency to spring-data-commons module, since this module is already part of the transitive dependencies of your project (from spring-boot-starter-data-mongodb-reactive). This means that with your current build.gradle setup, you should be able to import this class without error.
./gradlew dependencies
+--- org.springframework.boot:spring-boot-starter-data-mongodb-reactive -> 2.0.0.RELEASE
| +--- org.springframework.boot:spring-boot-starter:2.0.0.RELEASE (*)
| +--- org.springframework.data:spring-data-mongodb:2.0.5.RELEASE
| | +--- org.springframework:spring-tx:5.0.4.RELEASE
| | | +--- org.springframework:spring-beans:5.0.4.RELEASE (*)
| | | \--- org.springframework:spring-core:5.0.4.RELEASE (*)
| | +--- org.springframework:spring-context:5.0.4.RELEASE (*)
| | +--- org.springframework:spring-beans:5.0.4.RELEASE (*)
| | +--- org.springframework:spring-core:5.0.4.RELEASE (*)
| | +--- org.springframework:spring-expression:5.0.4.RELEASE (*)
| | +--- org.springframework.data:spring-data-commons:2.0.5.RELEASE (*)
| | \--- org.slf4j:slf4j-api:1.7.25
So maybe you have a synch issue in your project, try to clean/close/reopen it.
Are you sure that data is part of the imported packages? It seems to me that you need to add org.springframework.data to your gradle file. You can see here that data is different package.
When i tried to build, ide throw error: "Unresolved reference: X "
X is any Java constant (public static final) on (public) class Java
Can’t use:
android.os.Environment.DIRECTORY_DOCUMENTS
Build.VERSION_CODES.M
Etc
I have tried:
Invalidate Cache in Android Studio
gradlew cleanBuildCache
Clean / Rebuild
Clone project on other folder,
Etc
It’s a mixed project, Java & Kotlin
I can use static methods, like:
public static Uri getUriForFile from public class FileProvider
Etc
Error line:
10:38:23.053 [ERROR] [org.gradle.api.Task] e: C:\Users\User\AndroidStudioProjects\MyAndroidProject\app\src\main\kotlin\com\myapp\mypackage\android\PermissionsHelper.kt: (67, 66): Unresolved reference: M
I’m using:
Gradle Configuration
ext.kotlin_version = ‘1.3.10’
classpath ‘com.android.tools.build:gradle:3.2.1’
androidExtensions { experimental = true }
Software
Windows 10 Pro 10.0.17134 N/D Compilation 17134 x64
Android Studio 3.2.1 Build #Al-181-5540.7.32.5056338,build on Octubre 8, 2018
java version “1.8.0_162”
Java™ SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot™ 64-Bit Server VM (build 25.162-b12, mixed mode)
Stacktrace:
10:38:23.076 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
10:38:23.076 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
10:38:23.076 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
10:38:23.076 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:compileDebugKotlin'.
10:38:23.076 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Compilation error. See log for more details
10:38:23.076 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
10:38:23.076 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
10:38:23.076 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --scan to get full insights.
10:38:23.076 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
10:38:23.076 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
10:38:23.077 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugKotlin'.
10:38:23.077 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
10:38:23.077 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
10:38:23.077 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
10:38:23.077 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipCachedTaskExecuter.execute(SkipCachedTaskExecuter.java:103)
10:38:23.077 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
10:38:23.077 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
10:38:23.077 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ResolveBuildCacheKeyExecuter.execute(ResolveBuildCacheKeyExecuter.java:66)
10:38:23.077 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
10:38:23.077 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
10:38:23.077 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter
Thank you #yole and #Rod_Algonquin for the help, meanwhile i was writing the questions, and answering the questions, the Rubber duck method help me, the IDE was throwing me a error "Unresolved reference", but the problem was the annotation:
#RequiresApi(Build.VERSION_CODES.M)
Because: minSdkVersion 16
I was working on PermissionsHelper.kt, I was using Activity instead of android.support.v4.app.Fragment or ContextCompat for old versions.
Sorry guys for not post the code, and the complete gradle, i wanted to do a short post, this is my fist post.
Thank yo for all the help.
I use retrolambda a long time, but suddenly he stopped working in all my projects. I reinstalled jdk, but it didn't help. I didn't find answer in google, i hope you can help me. My gradle files:
build.gradle (app):
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "xsystem.ru.test"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.1.0'
}
build.gradle (Project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'me.tatarka:gradle-retrolambda:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle stacktrace:
19:32:51.295 [ERROR] [org.gradle.BuildExceptionReporter]
19:32:51.295 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter]
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:compileRetrolambdaDebug'.
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] > Process 'command 'C:\Program Files\Java\jdk1.8.0_121\bin\java.exe'' finished with non-zero exit value -1073740791
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter]
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileRetrolambdaDebug'.
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_121\bin\java.exe'' finished with non-zero exit value -1073740791
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:367)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:31)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.file.DefaultFileOperations.javaexec(DefaultFileOperations.java:170)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractProject.javaexec(AbstractProject.java:848)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractProject.javaexec(AbstractProject.java:844)
19:32:51.296 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.Project$javaexec$11.call(Unknown Source)
19:32:51.297 [ERROR] [org.gradle.BuildExceptionReporter] at me.tatarka.RetrolambdaTask.execute(RetrolambdaTask.groovy:69)
19:32:51.297 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
19:32:51.297 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245)
19:32:51.297 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
19:32:51.297 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232)
19:32:51.297 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
19:32:51.297 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
19:32:51.297 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
19:32:51.297 [ERROR] [org.gradle.BuildExceptionReporter] ... 14 more
19:32:51.297 [ERROR] [org.gradle.BuildExceptionReporter]
Update class path to
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
then add this to your dependencies
retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:2.3.0'
Add following code to application block
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
After this it should work.
Update:
The latest version of retrolambda till today (September 11 2017) is 3.7.0
Add this in app gradle build file before android block (on top)
//noinspection GradleCompatible
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
tasks.whenTaskAdded { task ->
if (task.name.startsWith("lint")) {
task.enabled = false
}
}
retrolambda {
jvmArgs '-noverify'
}
and I also changed my class path version from 3.4.0 to 3.2.5 and my issue resolved.
Also no need to add retroLambdaConfig
When I updated the AS project to AS 3.4.1, there were a lot of problems, and I finally got stuck on this error message. There was very little related information on the Internet, let alone the solution. In desperation, I looked at other warnings. The following warning was changed casually:
One of the plugins you are using supports Java 8 language features. To try the support built into the Android plugin, remove the following from your build.gradle
The solution is to remove the previously dependent lambda library, because after version 3.0, AS itself supports lambda
apply plugin: 'me.tatarka.retrolambda' //remove this line
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'me.tatarka:gradle-retrolambda:3.2.4' //remote this line
}
After removing this sentence, synchronize it, and miraculously compiled successfully. It seems that this plug-in library does not exist after version 3.0, and it cannot be recognized.