I imported a project from one pc to another and my gradle files are all screwed up. It is complaining that my res folder isn't at the right path. I already use the following line for the manifest file:
sourceSets {
main {
manifest.srcFile 'app\\src\\main\\AndroidManifest.xml'
}
}
Can I set the overall source directory (for java files and res files) somehow? Or set them individually?
Note: It appears that the path gradle is trying to use is missing the 'app'
For Reference, here is the error:
C:\MyProject\build\intermediates\manifests\debug\AndroidManifest.xml
Error:(24, 23) No resource found that matches the given name (at 'icon' with value '#drawable/ic_launcher').
Error:(25, 24) No resource found that matches the given name (at 'label' with value '#string/app_name').
Error:(26, 24) No resource found that matches the given name (at 'theme' with value '#style/AppTheme').
Error:(29, 28) No resource found that matches the given name (at 'label' with value '#string/app_name').
Solution which I found 2 minutes later. Guess I shouldn't code late at night.
sourceSets {
main {
java.srcDirs 'app\\src\\main\\java'
res.srcDirs 'app\\src\\main\\res'
manifest.srcFile 'app\\src\\main\\AndroidManifest.xml'
}
}
Related
I'm trying to create groovydoc using gradle. I have created the below task :
The groovy classes are present in - src/integration-test/groovy/com/x/folders/*.groovy
This is my sourcesets :
sourceSets {
integrationTestCompile {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDirs = ['src/integration-test/groovy']
}
resources.srcDir file('src/integration-test/resources')
}
}
groovydoc {
source = sourceSets.integrationTestCompile.java.srcDirs
classpath = configurations.compile
include '**/com/x/common/controllers/*'
}
I get the below message :
> Task :groovydoc NO-SOURCE
Skipping task ':groovydoc' as it has no source files and no previous output files.
I may have wrongly entered the sourcesets, but I have tried different ways but still getting the very same error message.
I am setting some local variables for build type signing configs, and it seems to be working. However Intellij (Android Studio) seems to think these variables in my local.properties file are unused.
Is this just one of those "turn off the linter" problems, or is there actually a way to solve this and tell the linter to do it's job correctly?
Example of usage:
local.properties:
storeFile=/home/user/dir/file # <-- says it's unused
storePass=pass1234 # <-- unused
# ...
build.gradle
android {
Properties properties = new Properties()
properties.load(project.rootProject.file("local.properties").newDataInputStream())
signingConfigs {
'release (signed)' {
storeFile file(properties.getProperty('storeFile'))
storePassword properties.getProperty('storePass')
keyAlias properties.getProperty('keyAlias')
keyPassword properties.getProperty('keyPass')
}
}
}
i'm trying to integrate the ndkBuild functionality into an existing android studio project, using the new android studio 2.2 , in order to enable c++ debugging etc.
i have tried out one of the ndk example projects which android studio 2.2 offers, which works perfectly fine. However, when i try to run the gradle commands in my own project, i get this error message:
Error:(73, 0) Could not find method externalNativeBuild() for arguments [build_c6heui1f67l8o1c3ifgpntw6$_run_closure2$_closure9#4329c1c9] on project ':core' of type org.gradle.api.Project.
By following this description
http://tools.android.com/tech-docs/external-c-builds
i ended up with a gradle script which includes the following commands:
externalNativeBuild{
ndkBuild{
path "$projectDir/jni/Android.mk"
}
}
externalNativeBuild {
ndkBuild {
arguments "NDK_APPLICATION_MK:=$projectDir/jni/Application.mk"
abiFilters "armeabi-v7a", "armeabi","arm64-v8a","x86"
cppFlags "-frtti -fexceptions"
}
}
Did i perhaps miss out on something here with the project setup?
I have set the Android NDK location properly under
File -> Project Structure ... -> SDK Location -> Android NDK location
in my android studio.
Anything else i might have forgotton?
Has anyone run into a similar problem before?
Advice would be much appreciated =)
Just had this error myself. In your root build.gradle, make sure that gradle is set to at least version 2.2.0:
So you should have the following in buildscript {...}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
}
Suggested by Kun Ming Xies answer, I have separated my cmake part in two to get rid of the annoying error:
Could not find method arguments() for arguments [-DREVISION=1.3.1] on object of type com.android.build.gradle.internal.dsl.CmakeOptions.
The first part in defaultConfig contains the configuration (command line arguments for CMake and C++ flags), and the second contains the path to CMakeLists.txt:
def revision = "1.3.1"
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
versionCode = ...
versionName "${revision}"
externalNativeBuild {
cmake {
arguments "-DREVISION=${revision}"
cppFlags '-fexceptions', '-frtti', '-std=c++11'
}
}
}
buildTypes { }
lintOptions { }
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}
}
android {
defaultConfig {
externalNativeBuild {
cmake {
arguments '-DANDROID_TOOLCHAIN=clang'
}
}
}
What am I doing wrong here? The ultimate goal is to download *.properties from the URL.
[ I know resolver is not needed, was just trying out to see if there was a class name issue. ]
Error:
build file '/home/awm/t/build.gradle': 13: unable to resolve class org.apache.ivy.plugins.resolver.URLResolver
# line 13, column 20.
def resolver = new org.apache.ivy.plugins.resolver.URLResolver()
^
build file '/home/awm/t/build.gradle': 14: unable to resolve class org.apache.ivy.util.url.ApacheURLLister
# line 14, column 21.
def urlLister = new org.apache.ivy.util.url.ApacheURLLister()
^
Code:
plugins {
id "de.undercouch.download" version "2.0.0"
}
import de.undercouch.gradle.tasks.download.Download
import org.apache.ivy.util.url.*
task downloadDirectory {
def dir = 'http://127.0.0.1:8081/artifactory/gradle-local/props/'
def resolver = new org.apache.ivy.plugins.resolver.URLResolver()
def urlLister = new org.apache.ivy.util.url.ApacheURLLister()
def files = urlLister.listFiles(new URL(dir))
download {
src files
dest "lib"
}
}
defaultTasks 'downloadDirectory'
From Gradle 2.0 on you need to include a build script dependency to Apache Ivy in order to make this recipe work. Put the following right at the beginning of your build script.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.apache.ivy:ivy:2.3.0'
}
}
example: https://github.com/michel-kraemer/gradle-download-task/blob/ddb384d3ee86f038c61ec4e77f21b814b1557a1a/examples/directory.gradle
another use-cases of download task: https://www.michel-kraemer.com/recipes-for-gradle-download/
I'm trying to add one more resource folder in my Android project.
I created a new folder extra-res so my project structure looks like this:
+ src
+ main
+ res
+ layout
+ ...etc...
+ extra-res
+ layout
So I added this to build.gradle:
android {
.........
sourceSets {
main {
res.srcDirs = ['res', 'extra-res']
}
}
}
But after editing the build.gradle file the build fails.
:app:processDebugResources
C:\Users\vovasoft\AndroidStudioProjects\sdbm\app\build\intermediates\manifests\full\debug\AndroidManifest.xml
Error:(13, 23) No resource found that matches the given name (at
'icon' with value '#drawable/ic_launcher').
Error:(14, 24) No resource found that matches the given name (at 'label' with value '#string/app_name').
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.internal.LoggedErrorException: Failed to run
command:
aapt.exe package -f --no-crunch -I android.jar -M \AndroidStudioProjects\sdbm\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S \AndroidStudioProjects\sdbm\app\build\intermediates\res\debug
-A \AndroidStudioProjects\sdbm\app\build\intermediates\assets\debug
-m -J C:\Users\vovasoft\AndroidStudioProjects\sdbm\app\build\generated\source\r\debug -F (at 'label' with value '#string/activity_edit_field').
Before editing build.gradle the build was successful.
I gave you some wrong information when I answered your original question in https://stackoverflow.com/a/28176489/2985303. That'll teach me about not testing an answer before posting it. You need to more fully qualify the resource directory paths, like so:
android {
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/extra-res']
}
}
}
I was getting that error beacause I forgot to include my new resource folder in build.gradle file.