So all the reading I've done online says to set ndk.dir in the ANT build properties file to fix the "NDK not configured" error I'm getting from Gradle, but obviously I can't do that because I'm not using ant, I'm using Gradle+CMake.
Below is my gradle script. I'm still very new to this, I'm just trying to figure things out as I go. I got the java piece building fine in Gradle but at this point I am not able to integrate CMake.
apply plugin: 'com.android.library'
android {
compileSdkVersion 17
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 17
ndk {
moduleName "UI"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
abortOnError false
}
externalNativeBuild {
cmake {
path '../../CMakeLists.txt'
}
}
}
Where can I specify the NDK path? I have an environment variable defined named ANDROID_NDK. CMake 3.7 uses this to hunt down the location of the NDK already. Why isn't the android gradle script using it? What is the proper way since I'm not using ant?
Note: I'm trying to get things building on the command line first outside of Android Studio via gradle build command. The error I get:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':Core:UI'.
> NDK not configured.
Download it with SDK manager.)
You can specify the path to the NDK in Android Studio by selecting the File->Project Structure menu item.
You should then see the Project Structure settings dialog where you can specify the NDK location.
The value you enter here will modify the ndk.dir value in the local.properties file, which you can see in the background in the image below:
Related
Having tried to add This game to my phone via Android Studio, while trying to build the project it throws in the event log "All files are up-to-date". I've looked through the program and it was built in eclipse, with no luck converting it to Android Studios.
I've tried to "import" some of the files with no luck.
other solutions I've tried with no luck are outlined in:
Here
And
Here
Are you clicking "Build APK" in the Build drop-down menu? If not, try that! Here is a nice reference for building apps in Android Studio.
think it's an Eclipse IDE (ant) project ...
you'd need to import it to Android Studio (gradle), first.
managed to build the Android.mk with ndkBuild, after importing the project.
the build.gradle looks alike:
apply plugin: 'com.android.application'
android {
defaultConfig {
applicationId "org.jfedor.frozenbubble"
minSdkVersion 22
targetSdkVersion 26
compileSdkVersion 26
ndk {
moduleName "modplug-1.0"
}
}
externalNativeBuild {
ndkBuild {
path "src/main/cpp/Android.mk"
}
}
sourceSets {
main {
jni.srcDirs = ["src/main/cpp"]
}
}
buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled false
}
}
}
that andmodplug_PlayerThread.h needs to be dropped into the libmodplug directory, where the other headers reside (the import does not copy it, because it's in a completely unexpected location). also renamed directory jni to cpp and assigned that path to the main sourceSet.
I have two projects: library and app. I have previously uploaded library to jCentre, and library is listed as an external dependency of app in its build.gradle file. Recently I published a newer version of library and updated the dependency version code in app's build.gradle file, but when I did this Android Studio could no longer find any of the classes from library.
To test the library, I created an entirely new project and added library as a dependency. In this scenario Android Studio finds the classes just fine. I've compared every line of the build.gradle files: They have the same min and target SDK version, they have the same proguard config, they're literally identical. They projects are also using the exact same version of the android plugin and the exact same gradle version.
I also tried entirely deleting app from my machine and re-checked it out from git. This did not solve the problem. I've tried all the usual steps of cleaning the project and rebuilding the project, deleting all build files, invalidating caches, etc.
So can anyone tell me why Android Studio cannot find any of the library classes after upgrading the dependency version?
Here is the gradle.build file in the new test project:
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
minSdkVersion 11
targetSdkVersion 24
versionCode 11
versionName "3.1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.matthew-tamlin:android-utilities:2.1.0' // this is library
}
Here's the build.gradle file in the app project:
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
minSdkVersion 11
targetSdkVersion 24
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.matthew-tamlin:android-utilities:2.1.0' // this is library
}
You can see that they're virtually identical, so why can one project find the classes from the library but the other cannot?
So I never discovered why this is an issue, but I found a workaround. I created a new project in Android Studio and copied all the src directories and build.gradle files from the existing project. I also copied the hidden git folder and all git ignore files. I didn't copy the gradle wrapper, the gradle file or the generated builds. I don't know why this fixed the problem, it must be a bug in gradle or Android Studio.
So I am stuck, I am trying to import an eclipse project to Android studio, and I am getting this error.
Error:(22, 23) No resource found that matches the given name (at 'src' with value '#drawable/item').
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/joselibra/Library/Android/sdk/build-tools/22.0.1/aapt'' finished with non-zero exit value 1
I have attempted to sync project, delete build file, clean project, rebuild project, invalidate cache and restart.
I followed the direction on how to migrate to Android studio via this link among others, https://developer.android.com/sdk/installing/migrate.html.
This is what my gradle file looks like
apply plugin: 'com.android.application'
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.wtf.edu"
minSdkVersion 11
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile "com.google.android.gms:play-services:7.5.0"
}
Any help or clues would be much appreciated, thank you.
Import eclipse project in to android studio project .you can try this one
n newer versions of Android Studio, the best way to bring in an Eclipse/ADT project is to import it directly into Android Studio; we used to recommend you export it from Eclipse to Gradle first, but we haven't been updating ADT often enough to keep pace with Android Studio.
enter link description here
In any event, if you choose "Import Project" from the File menu or from the Welcome screen when you launch Android Studio, it should take you through a specialized wizard that will prompt you that it intends to copy the files into a new directory structure instead of importing them in-place, and it will offer to fix up some common things like converting dependencies into Maven-style includes and such.
It doesn't seem like you're getting this specialized flow. I think it may not be recognizing your imported project as an ADT project, and it's defaulting to the old built-into-IntelliJ behavior which doesn't know about Gradle. To get the specialized import working, the following must be true:
The root directory of the project you import must have an AndroidManifest.xml file.
Either:
The root directory must contain the .project and .classpath files from Eclipse
or
The root directoy must contain res and src directories.
If your project is complex, perhaps you're not pointing it as the root directory it wants to see for the import to succeed.
I can't seem to fix this error after I add a jar file to the project:
Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
The program runs without the jar file but when I add it, everything builds but it gives me this error when I try to run it. I have searched and tried the following solutions but nothing fixed the error.
why java.exe exit with value 1 in android studio
Error:Execution failed for task ':app:dexDebug'. > comcommand finished with non-zero exit value 2
Android java.exe finished with non-zero exit value 1
Since none of these solutions worked I thought it my be a over 65k method problem so I edited my build.gradle but the problem still exists.
https://developer.android.com/tools/building/multidex.html
This is my build.grade for my app project:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
................
minSdkVersion 15
targetSdkVersion 21
multiDexEnabled = true
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:multidex:1.0.0'
compile files('libs/xyz.jar')
}
I don't know how to fix this problem. Any help would be appreciated.
I had this error message (also only when running not building) when attempting to add a plain Java module as a dependency on an Android module. Though it only happened in Android Studio, not from the command line.
I solved it by including the following line in the plain Java module's build.gradle:
sourceCompatibility = 1.7
Note that Android Studio marks this line as not used.
Try clicking on File > Invalidate caches / Restart > Invalidate and Restart. Once it builds, run your project again. It worked for me.
I guess this has to do with the number of libraries you are including in your project. Although I am not certain this will help you could put this in your gradle file:
defaultConfig {
...
multiDexEnabled true
}
But even with that I got this error after adding another library. I was lucky that one lib was not crucial for the app, it was a library for catching memory leaks, so I removed it and then it compiled. As I am not an expert here maybe someone can add something to this topic? I will try to find out more about this 65k limit and how to overcome it and will get back to this.
I resolved this error by switching the JDK location of my android studio project. Just right click on the project root directory select Open Module Settings, under the sdk location option, browse the JDK location to a different one if you have 2 or more installation as in my case there were:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
and
/Library/Java/JavaVirtualMachines/jdk1.7.0_65.jdk/Contents/Home
For me, I open SDK Manager, and update all the package that could be updated, and restart my MacBook, then it works.
I am wondering if it relevant with my updated OSX, coz I updated it to 10.10.4 yesterday, my project was good but crashed after, anyway, try to update all the things you could do, even re-install java.
Good luck!
The error comes from you running a Java 8 SDK instead of a Java 7 SDK (which at the time of this writing seems to be required for Android Studio).
I installed Java 7 from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html and pointed Android Studio to use the Java 7 JDK by going to File > Other Settings > Default Project Structure... (Android Studio 1.3)
Now everything works just fine!
I'm trying to build my first android app using Android Studio. Unfortunately, every time I open my project, try to run it or gradle assemble it I get the following error :
Gradle 'MalipoBatteryAlarm' project refresh failed:
C:\Users\wickedQuasar\.gradle\daemon\1.10\daemon-6128.out.log
(The filename, directory name, or volume label syntax is incorrect)
What file or directory is causing the problem is unclear. I used to overcome this error by rebuilding my project, changing access rights to username.gradle folder or switching b/w using default and customizable gradle wrappers. From last two days nothing seems to fix it and I'm totally stuck. I've also tried this : Gradle: The filename, directory name, or volume label syntax is incorrect but it didn't fix it.
I've wasted tens of productive hours of my life trying to fix it so any help would be appreciated. From my research I found that this error is usually caused by "unnacceptable characters" in file names. i can't seem to find the cause in my case though.
I'm using a 32bit win 7 machine with Android Studio 0.5.5. My java env variables are set properly.
Update : The command
gradlew build --stacktrace
returns BUILD SUCCESSFUL, but not in the IDE...
Gradle build file for project root :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Module gradle build file :
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Workaround : Switched to commandline now. Assembling using gradle commandline and installing/monitoring using adb and ddms. Everything is dramatically fast now and works like a charm on a dual monitor setup. IDE is still showing the error though...