I am trying to import an unity3d project to my android project as a module. All is okay, gradle sync finish without error, but when i add unity project as dependency to my project and run gradle sync then it says:
Error:Dependency myapplication:unityproject:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: /Users/michal/Documents/Projects/myapplication/unityproject/build/outputs/apk/unityproject-release-unsigned.apk
I tried google it, but with no luck... Thanks a lot for any tips...
I am using Android Studio (if it helps)
I can build and run standalone unity3d project on mobile device, problem is only when i am trying to add it as module (dependency) to another project
In your library's gradle.build, Change the line apply plugin: com.android.application to apply plugin: com.android.library and remove the setApplicationId
In Android Studio, you can't depend on an Android Application module (which has an APK as its output). You can only depend on Java libraries (which compile to JAR) or Android Library modules (which compile to AAR).
I'm an android noob, but I was able to import a simple Unity app into Android Studio by checking "Google Android Project" in the export dialog.
Deets:
* Unity 4.6.1
* Android Studio 1.0
(note if you download A.S. "1.0", you still need to do a software update a couple times to really get it)
Related
In my React Native app, I got an error about incompatibilities with gradle 6, so I looked in my project structure to find out which version of gradle I was running in my project. I found this line in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
and this line in build.gradle
classpath("com.android.tools.build:gradle:3.4.2")
What I Want To Know: What's the difference between the reference to gradle in each of these files? In other words, how is version 5.5 being used in my project, and how is 3.4.2 being used?
distributionUrl represents Gradel Version where as classpath represents Android Gradle plugin version.
Gradel vs Android Gradle plugin: Reffer this difference between android gradle plugin and gradle
Gradle is the build system.
You can use it with a lot of plugins. One of these is the plugin for Android.
It is used to provide processes and configurable settings that are specific to building and testing Android applications.
For greater details and mapping of the above two type of versions refer the following URLs
https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
https://developer.android.com/studio/releases/gradle-plugin#updating-plugin
I hope this answer has cleared your doubts.
I am going to use the build config property "multiDexEnabled true" to break 64K methods limit following link
https://developer.android.com/studio/build/multidex.html#about
I update to use unity 5.6.1f1 and android studio 2.3.3. I set "build system" option to "Gradle(New)", which is new added from 5.5, then click "Export" to create an android project.
I open the exported project with android studio, then I get the following error
I try the two blue links, but I keep geting this same result.
For my unity project, I only create an empty project and add a button to a unity scene, then export it. I have also tried to build API directly, it works.
It is important for me to export unity project to andoid studio project, because it can help us to use additional compile options
Do any one know what I miss? Or how to export unity project correctly?
Thanks
The gradle error text, if cannot see the image link
Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I had the same issue with unity 2017.1.0b4 and Android Studio 2.3.3, gradle 3.3.
You should change android plugin for graddle version in Android studio to 2.3.3
You can specify the Android plugin for Gradle version in either the
File > Project Structure > Project menu in Android Studio, or the
top-level build.gradle file. The plugin version applies to all modules
built in that Android Studio project. The following example sets the
Android plugin for Gradle to version 2.3.3 from the build.gradle file:
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
https://developer.android.com/studio/releases/gradle-plugin.html
Check your local gradle version in directory -
C:\Users\yourname\.gradle\wrapper\dists
Modify your project gradle configuration -
project\gradle\wrapper\gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Make sure gradle-3.3-all match to your gradle version.
If you have wasted a lot of time fixing unity Gradle error but nothing worked then you tried unity internal builder but that gave "Parsing Package error"
then try this, it will not help you make your project using unity's Gradle but it will make your project without any error successfully.
Export your project from unity to a folder eg: ProjectName_Gradle.
open android studio, make sure you are connected to the internet .
close current project then select "Open Gradle, eclipse ADT, etc;" option and open ProjectName_Gradle folder.
check the version of buildTools installed in your android-SDK by opening android-SDK settings from the android studio itself.
edit "build.gradle" file under Gradle Scripts section or under your project.
and change "buildToolsVersion" to the latest version installed in your SDK.
then click "syn project with Gradle Files" from file option and let it sync.
it may ask to update Gradle version, then click update
now there should not be any errors.
now try building APK.
I have imported a module to my android project. Since I would like to have an opportunity to update my library, I did not import jar-file, but just a link.
In settings.gradle I wrote
include ':myLib'
project (':myLib').projectDir = new File('C:\\path\\to\\myLib\\')
in app > build.gradle I added:
compile project(':myLib')
After these manipulations Android Studio started to see my library module and added it to the project.
But it still does not see imported classes and cannot build. What I have done:
I started gradlew clean & gradlew build
I checked Android Plugin Version: it is equal for my app and for my imported module.
What can I do else?
So my Android Studio version is 2.1.1
My build tools version is 23.0.0
Adroid Plugin Version is 2.1.0
Gradle version is 2.10
I want reading an open source project so I select k9mail for start. The recommendation was run and reading this code in Android Studio. I import k9mail project to AS 1.2.1.1 version. I download gradle 2.4 version and added this in environment variable. When I want to run this application, but I receive some errors that I describe below:
1) When I click Run (Alt+Shift+F10), select Android Application, select my module (there is k9mail) and select USB Device, then I see a warning:
No JDK specified for module 'k-9-master'.
2) When I click on Run (Shift+F10), I faced this error in messages tab:
Gradle DSL method not found: 'android()'
Possible causes:
A)The project 'k-9-master' may be using a version of Gradle that does not contain the method.Open Gradle wrapper file
B)The build file may be missing a Gradle plugin. Apply Gradle plugin
When I updated gradle to 2.4, I changed classpath 'com.android.tools.build:gradle:1.2.3' to 'classpath 'com.android.tools.build:gradle:2.4'' from build.gradle of k9mail, but my problems were not solved.
I googled but I can't find solutions for my problems.
No jdk specified for the module.
For that you have to specify the jdk path through Project Structure.
You may also verify by looking at local.properties
For gradle related issues you just kindly update your gradle build and SDKs to latest versions.
This will minimize your gradle issues.
I am trying to import a Gradle project into Android Studio and get the following error:
This project does indeed compile when I run Gradle from the command line. I can also Open the project in Android Studio (vs Import) but then it tries to build using the Eclipse build script.
The gradle build was created by hand and not via the Eclipse export function.
My problem can be resolved in one of two ways:
1) Tell me how to force Android Studio to use Gradle instead of using the Eclipse build.
2) Help me find the reason for the Gradle import error.
I am using
Android Studio 0.2.2
Gradle 1.6 via gradlew
I finally found out why this didn't work.
There are two ways to include a project from within the settings.gradle file:
include ':..:source:compA-api'
and
include "source:compA-api"
project(':source:compA-api').projectDir = new File(settingsDir, 'source/compA/api')
I had used the second form and apparently Android Studio didn't like that :)