j2objc gradle plugin - Task with path 'test' not found in project app

1k Views Asked by At

I'm trying to use j2obc for gradle to port my android application to iOS, but I'm getting this error and can't seem to figure out how to fix it.

The full thing:

13:43:50.477 [ERROR] [org.gradle.BuildExceptionReporter]
13:43:50.482 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
13:43:50.489 [ERROR] [org.gradle.BuildExceptionReporter]
13:43:50.492 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
13:43:50.496 [ERROR] [org.gradle.BuildExceptionReporter] Could not determine the dependencies of     task ':app:j2objcTranslate'.
13:43:50.499 [ERROR] [org.gradle.BuildExceptionReporter] > Task with path 'test' not found in     project ':app'.
13:43:50.503 [ERROR] [org.gradle.BuildExceptionReporter]
13:43:50.506 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
13:43:50.510 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the     stack trace.
13:43:50.517 [LIFECYCLE] [org.gradle.BuildResultLogger]
13:43:50.523 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
13:43:50.529 [LIFECYCLE] [org.gradle.BuildResultLogger]
1

There are 1 best solutions below

0
On

The j2objc plugin is now fixed to work with translating an Android application project. Please note that j2objc is not designed to translate your entire application - only the business logic. Ideally this should be cleanly separated from the UI layer through good unit test and ideally a separate java project with no Android dependencies. The UI layer should be implemented in native language of each platform. To fix this, please download an updated version of the plugin:

https://gist.github.com/brunobowden/58d6e311ab96760fc371

More details here:

https://github.com/google/j2objc/blob/master/README.md

Historical Error Explanation:

The plugin depends on the "test" task from the Java plugin, so before doing the translate it will compile and test the Java code and unit tests. That's meant to ensure that your code is correct and working in Java before attempting the translation to Objective-C. This is why it's best to have a separate shared Java project without any Android dependencies and translate that alone.

The plugin isn't currently designed to translate a project when the 'com.android.application' gradle plugin is applied (this is now fixed as noted above). I will work on this to either fix it up if possible or provide a better error explanation.

To remove this dependency temporarily (though I don't know what other parts may fail), remove the dependsOn: "test" from the following part of j2objc.gradle:

tasks.create(name: "j2objcTranslate", type: J2objcTranslateTask,
        dependsOn: "test") {

I'm the author of the j2objc plugin.