Im using Android studio 0.4.2 (Gradle project) with AA
My gradle.build looks like below
apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
......
dependencies {
compile 'com.android.support:support-v4:19.0.0+'
compile 'com.android.support:appcompat-v7:19.0.0+'
compile 'com.googlecode.androidannotations:androidannotations-api:2.7.1'
compile 'com.googlecode.androidannotations:androidannotations:2.7.1'
compile fileTree(dir: 'libs', include: '*.jar')
}
android.applicationVariants.each { variant ->
println 'Generation dir: ' + annotationDirs
variant.javaCompile.dependsOn annotationsDir
variant.javaCompile.options.compilerArgs += [
'-processor', 'com.googlecode.androidannotations.AndroidAnnotationProcessor',
'-s', annotationDirs
]
}
in my project I just use genereted java class like replaceFragment(new RegistrationFragment_()); , this is a correct way to use annotated class and it works well when I run build task, but IDE shows me an error - 'cannot resolve symbol RegistrationFragment_'. All gen _.java files are stored in PROJECT_NAME\app\build\classes\debug\com\witness\app\RegistrationFragment_.java. How can I fix this?
Related
I am new to gradle and was wondering if I am doing something wrong or not when i try to load dependencies from the main Maven repo
this is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.github.clans:fab:1.6.2'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
and the error i get is
Error:(15, 17) Failed to resolve: com.facebook.android:facebook-android-sdk:4.7.0
Error:(14, 17) Failed to resolve: com.github.clans:fab:1.6.2
What is going on? Why am i seeing those errors? This text here is only so that stackoverflow stop complaining.
UPDATE:
This is gradle-wrapper.settings:
#Tue Nov 17 20:36:30 GMT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
Those are my dependencies in Android Studio. It even found it through the search ....
It seems, that you've forget to add the repository to your project. According to your build.script, you've added repo just in your buildscript. Just add repositories into the build.script root, before declaring dependencies, as:
repositories {
mavenCentral()
}
dependencies {...
Try with this:
apply plugin: 'com.android.application'
allprojects {
repositories {
jcenter()
mavenCentral()
}
dependencies { classpath 'com.android.tools.build:gradle:1.5.0' }
}
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.github.clans:fab:1.6.2'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}
Or try:
Gradle settings -> Then uncheck Offline work
For some unknown reason Gradle is refusing to download every dependancy that I put in my gradle.build file. I'm trying to get the 'me.dm7.barcodescanner:zbar:1.7' dependancy but every time I try to sync my gradle it just gives me the following error:
Error:(6, 13) Failed to resolve: me.dm7.barcodescanner:zbar:1.7
It's not just the zbar library either, it's every library this isn't a com.android library. I'm not in offline mode so that can't be it either. Is there something wrong in my .build file?
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile project(':MetaioSDK')
compile 'com.android.support:support-v4:22.0.0'
compile 'me.dm7.barcodescanner:zbar:1.7'
}
android {
compileSdkVersion 19
buildToolsVersion "21.1.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['../../templatesContent_crossplatform']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
Alright, managed to fix it. Added this inside the dependencies block:
repositories {
mavenCentral()
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'me.dm7.barcodescanner:zbar:1.7'
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
Put repository block independently from from other blocks
I am going to migrate to android studio.
I would like to use this lib :
https://codeload.github.com/flavienlaurent/datetimepicker/zip/master
after this tutorial :
https://www.youtube.com/watch?v=1MyBO9z7ojk
now I get this error :
Error:Failed to find: com.nineoldandroids:library:2.4.0
build.gradle in datetimepicker-library :
apply plugin: 'com.android.library'
repositories {
mavenCentral()
}
dependencies {
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:support-v4:20.0.0'
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionName rootProject.versionName
versionCode rootProject.versionCode
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
//apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
updated
all my error :
Update this
dependencies {
compile 'com.nineoldandroids:library:2.4.0+'
}
Then Gradle your project
it's simple actually, just past
repositories {
mavenCentral()
}
to your build.gradle of the project (not the build.gradle of the module)
I have been using Android Studios from eclipe becuse Multidex 65000 compile Error!!!!
i did sync project gradle in android studio from eclipse project
i have problem compile Error in android studio
Error:Execution failed for task
':packageAllDevDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: android/support/multidex/MultiDex$V14.class
--build.gradle--
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android
{
compileSdkVersion 18
buildToolsVersion "20.0.0"
defaultConfig{
multiDexEnabled true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
productFlavors {
dev {
minSdkVersion 18
}
prod {
minSdkVersion 18
}
}
}
why problem occurring
i want this problem solve
help me error sovle please
I have a multi-flavor project, with flavors called "qa" and "prod". I need to include different versions of a library depending on both the build type and the flavor.
The documentation at http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Type-Product-Flavor-Build-Variant suggests that build types and flavors can be combined, using a "flavorBuildCompile" notation. However when I do this I get this error:
Error:(88, 0) Gradle DSL method not found: 'qaDebugCompile()'
I'm pretty sure this used to work (in an older version of gradle). Currently using gradle 2.1. I haven't found an explanation if the way to do this has changed.
Note, it works fine if I use "flavorCompile" notation, it only fails when I include the build type as well.
Here is the outline of my build script:
android {
compileSdkVersion 17
buildToolsVersion "20"
...
productFlavors {
qa {
applicationId "com.myapp.qa"
}
prod {
applicationId "com.myapp.prod"
}
}
sourceSets {
main {
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
manifest.srcFile 'AndroidManifest.xml'
}
qa {
res.srcDirs = ['res_qa']
}
prod {
res.srcDirs = ['res_prod']
}
}
}
...
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
qaCompile 'com.myapp.integration:other_lib:3.0+#aar' //this is fine
qaDebugCompile 'com.myapp.integration:mylib_qa:3.0+#aar' //this fails!
prodDebugCompile 'com.myapp.integration:mylib_prod:3.0+#aar'
qaReleaseCompile 'com.myapp.release:mylib_qa:3.0+#aar'
prodReleaseCompile 'com.myapp.release:mylib_prod:3.0+#aar'
}