I have a project that started in Eclipse over a year ago and I'm trying to import and use it within Android Studio. I've exported build.gradle from Eclipse and imported it into Android Studio. The project uses the support library, and while this didn't make it into build.gradle, I have added this line manually:
compile 'com.android.support:appcompat-v7:+'
If I run the build from the command line (./gradlew assembleDebug) it succeeds. Building from within Android Studio fails with errors that sound like it's not picking up the support library:
Error:(3, -1) android-apt-compiler: [module] /Volumes/User/Steve/src/.../android/res/menu/foo_menu.xml:3: error: No resource identifier found for attribute 'showAsAction' in package 'com.company.app'
I just updated Android Studio to the 0.5.9 release this morning. I believe I'm using a recent Gradle. There's this part in my build.gradle in the buildscript section:
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
And then this in gradle/wrapper/gradle-wrapper.properties:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
So my question is: why do I get different behavior from within the IDE than from the command line? How can I further troubleshoot what is going wrong from within Android Studio so that it runs the build exactly the same?
Related
Is it possible to add a tree of .h/.cpp files to the Android Studio editor for reference - so that they can be edited but not actually built/compiled by Android Studio?
I have JNI/NDK files which I want to build manually from the command line but I don't want Gradle/Android Studio to build these files.
There is a Gradle 'exclude' command/function which may be what I need but I cannot get it to work.
sourceSets {
main {
exclude 'jni'
//exclude ("jni/**")
//jni.srcDirs = []
}
}
I get the following error:
Error:(10, 0) Gradle DSL method not found: 'exclude()'
I didn't manage to figure this out with a vanilla Android Studio set-up but by using the Gradle Experimental Plugin I have ended up with the desired outcome. Once I got the 0.7.0 experimental plugin working (and my build.gradle configured for the new 'model' scoping), I was able to remove the sourceSets statement, successfull sync, edit within Android Studio and build from the command line via ndk-build.
Gradle sync fails in Android Studio 2.0 preview beta 2. My project used to work perfectly in older previews, but since preview 9 gradle sync fails with error:
failed to find target with hash string 'android-23'
I've tried changing compile and target SDK versions but no change.
The build classpath specifies which Java source files and resource
files in a project are considered by the Java builder and specifies
how to find types outside of the project. The Java builder compiles
the Java source files into the output folder and also copies the
resources into it. The build classpath is specified for each project.
You should use
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta2' // or beta3
}
alpha9
Sometimes this stage is referred to as a preview version. Sometimes no
more features are added after this release, but bug fixes continue.
This release comes after a pre-alpha version and before a beta
version.
The issue seems to be with gradle plugin. alpha9 is buggy.
avoid 2.0.0-alpha9
use 2.0.0-beta2
in your project gradle file.
Works with preview 9 and beta 2 versions of android studio.
Just change you build.gradle classpath with com.android.tools.build:gradle:2.0.0-beta2 like below while using Android studio 2.0 beta 2:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta2'
}
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 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)
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 :)