Imported classes are not visible - android

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

Related

Build time error in navigation component direction generated classes after updating android studio to chipmunk

I'm getting "Unresolved reference: R" build time error after updating android studio to chipmunk version in all "Direction" classes that are generated by navigation component.
R class is not imported in that classes, though I can import it manually but classes will be regenerated without import in next build
android gradle plugin version = 7.2.0
gradle wrapper version = 7.3.3-all
any solutions?
Had this same issue, I was able to fix it by updating this dependency in my Module build.grade
buildscript {
dependencies {
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0-rc01")
}
}
I also made sure my Android Gradle Plugin Version and Gradle Version were both set to the latest versions. (in the Project Structure->Project)

gradle error in unity exported android project

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.

Android Plugin for Gradle 2.2.2 and Gradle version 2.14.1 together failed to download android support v4

Android application build fails with Android Plugin for Gradle 2.2.2 and Gradle version 2.14.1.
But build successful with Android Plugin for Gradle 1.2.3 and Gradle version 2.3
Expected Behavior:
Android application should successfully build in command line with Android Plugin for Gradle 2.2.2 and Gradle version 2.14.1
Current Behavior:
Android application build fails with Android Plugin for Gradle 2.2.2 and Gradle version 2.14.1. Because it fails to find a symbol in the com.android.support:support-v4:23.2.1.
Also build fails in the Android Studio with the same reason.
Context:
I had to updated the Android Studio to 2.2.2(Latest) and this must use at least Android Plugin for Gradle 2.2.2. Therefore I had to update gradle as well. (Tried both gradle 2.14.1 and gradle 3.2) But build fails with the same reason.
Steps to Reproduce
Have the following settings in the application gradle.build file
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
Also
dependencies {
compile 'com.android.support:support-v4:23.2.1'
}
Android SDK is uptodate
enter image description here
enter image description here
And run the gradle build.
Build fails and out put's following errors
error: cannot find symbol
import android.support.v4.app.DialogFragment;
^
error: cannot find symbol
import android.support.v4.app.FragmentActivity;
When you try to update Gradle by yourself sometimes does not work, the best way y let android studio do it.
Step 1:
Close Your project
Step 2:
Reopen your project.
Step 3:
Click on update button
Step 4:
Wait update
Thats all!
Have you try to Invalidate Caches of Android Studio after upgrade gradle?
To do that you have to go:
File -> Invalidate caches / restart... -> Invalidate and Restart

Unity project as dependency in Gradle

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)

How to include RxAndroid in project?

I'm using Android Studio. How can I include RxAndroid in my project as a subproject? I want to build it from the sourcecode.
What I've tried:
-Include it as a git submodule.
-included it in my projects settings.gradle file, "include ':rxandroid', ':app'"
Then I get: Error:Unable to find module with Gradle path ':rxandroid'.
Edit
My folder structure is as follows.
Project
-app
-rxandroid
Edit 2
I changed the folder name from rxandroid to RxAndroid. I also changed the name in the projects settings.gradle, but I still get the same error.
According to http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Multi-project-setup it should simply work by changing settings.gradle to:
include ':app', ':RxAndroid'
And it does work for me. My setup is
Android Studio 0.8.13
RxAndroid cloned from https://github.com/ReactiveX/RxAndroid
My project is using com.android.tools.build:gradle:0.12.+
EDIT:
I should mention that I'm still running Gradle 1.12. I created a new blank project in Android Studio, added RxAndroid to settings.gradle, and a build error appeared:
Error:Cause: startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/path/spock-core/0.7-groovy-1.8/3a677d19e8d3acf3bd296c4023356256d55da5a3/spock-core-0.7-groovy-1.8.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception org.spockframework.util.IncompatibleGroovyVersionException: The Spock compiler plugin cannot execute because Spock 0.7.0-groovy-1.8 is not compatible with Groovy 2.3.6. For more information, see http://versioninfo.spockframework.org
Spock location: file:/path/spock-core-0.7-groovy-1.8.jar
Groovy location: file:/path/gradle-2.1/lib/groovy-all-2.3.6.jar
It seems RxAndroid depends on Spock 0.7-groovy-1.8 which won't work with Groovy 2.3.6 of Gradle 2.1. And the latest com.android.tools.build (0.13.x) requires Gradle 2.1.
So I did the following:
in the top level build.gradle (not the app one) change the project's dependency on com.android.tools.build back to 0.12.+
change the Gradle version in gradle-wrapper.properties back to 1.12
Now the project built successfully.

Categories

Resources