I have been using AndriodAnnotations with Eclipse (ADT) without any issue. Recently, I decided to explore Android Studio. Using Android Studio with AndroidAnnotations has a few issues when I build the app. Below is the error:
I can run the app without any issues when it is showing three errors.
Below is my build.gradle:
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2+'
}
}
apply plugin: 'android'
apply plugin: 'android-apt'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.test.restaurantmenu"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName "com.test.restaurantmenu"
}
}
dependencies {
apt "org.androidannotations:androidannotations:3.0+"
compile "org.androidannotations:androidannotations-api:3.0+"
compile 'com.android.support:appcompat-v7:+'
compile 'com.github.satyan:sugar:1.3'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I've enabled the annotation processors as follow:
Is there any steps I missed or wrong in my setup?
I installed "Android SDK Tools 23.0.2" and all the errors were solved.
if you're using kotlin and you're getting an error showing
error: annotations are not supported in -source 1.3 (use -source 5 or
higher to enable annotations)
There is a workaround for it
Open Project Structure (File -> Project Structure). Select the module.
Change the source compatibility and Target compatibility from kotlin 1.3
to jdk 1.8
Related
Upgraded to:
Android Studio 3.0 Canary 2
com.android.tools.build:gradle:3.0.0-alpha2
I have a multi-module project (main app + sub modules)
Inclusion inside the main app:
dependencies {
implementation project(path: ':testlib', configuration: 'default')
}
The testlib is defined as a simple android library project and works normally when included with gradle 2.3.0 and via compile project(path: ':testlib')
I get the following gradle error message:
Could not resolve all dependencies for configuration ':app:devDebug_signedCompileClasspath'.
Selected configuration 'default' on 'project :testlib'
but it can't be used as a project dependency because
it isn't intended for consumption by other components.
What does "isn't intended for consumption by other components" mean in this context? The module is defined as an android library.
Here is the build.gradle of the testlib:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
What am I missing?
I also got this error. Android Studio 3.0 Canary 4 just came out. I updated to it, which also updates gradle to 4.0rc1.
The problem went away on it's own.
alter your Top-level build file (aka root gradle)
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
still not working?
update dist-url (inside gradle-wrapper.properties)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-rc-1-all.zip
I'm trying to implement the MVVM architecture using Robobinding. Here's the link I'm following for the Environment setup of Robobinding in Android Studio(without AspectJ):
http://robobinding.github.io/RoboBinding/getting_started.html#_android_studio
This is what my app level Build.gradle looks like after adding the dependencies:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.simpletimerapp"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile "org.robobinding:robobinding:${robobindingVersion}"
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
}
}
The problem is gradle build fails with the following error:
Error:(26, 0) Could not find property 'robobindingVersion' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated#2ccd2d42.
Open File
EDIT 1:
On replacing ${robobindingVersion} in the dependencies block with 0.8.12 (latest version of robobinding), gradle build finishes successfully. But now, I'm unable to use the "bind" attribute in the views in my layout files. This is the error:
Unexpected namespace prefix "bind" found for tag TextView
EDIT 2:
Still can't find the solution. So, I downloaded this minimal android app (from their official github page) which implements robobinding and edited it to create my own app. It's working fine now.
I have imported a project in Android Studio that was built in it. I require v4 and v7 library in the project. This is how my build.gradle looks like
build.gradle
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion '20'
defaultConfig {
applicationId 'com.example.sdk'
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
}
When I sync with gradle then it always gives error message
Failed to find: com.android.support:support-v4:20.0.+ & Failed to find: com.android.support:appcompat-v7:20.0.+
Please support & thanks in advance.
The Android support repository was missing,So go to Android SDK, install the Android Support Repository and Android Support Library.
Also you can use the following
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
instead of
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
Note: If you're developing with Android Studio, select and install the Android Support Repository item instead.
see here.
From Android Studio go to: Tools >> Android >> SDK Manager
Select and install "Extras|Android Support Repository"
add maven to your gradle file (project)
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
and use this gradle wrapper:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
and downgrade to gradle plugin to be 2.3.1
classpath 'com.android.tools.build:gradle:2.3.1'
I have upgraded to Android Studio Beta (0.8.0) version from earlier 0.6.x version. After upgrade all the projects (which were working earlier) throws error "Cannot resolve symbol" for everything - String, Activity, file, view - everything. I have done a clean and rebuild;
Obviously I have missed something in the upgrade; What could that be?
And my settings.gradle is:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.grabdata.gdlea.apps"
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use
this dependency.
// You must install or update the Support Repository through the SDK manager to use
this dependency.
compile 'com.android.support:appcompat-v7:19.+'
}
Ran into the same issue. I cleaned and rebuilt the project and everything worked again.
I need to prevent gradle from exporting a certain shared library.
I´ve read that using the provided scope should do the trick, but it seems that it was only working with older gradle versions.
Is there any other way to exclude dependencies from the build process to not get them into the final apk?
I have found solution here: https://stackoverflow.com/a/10406184/310760
But for Gradle 2.0 it has small changes:
configurations{
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
}
test {
compileClasspath += configurations.provided
}
}
sourceSets.main.compileClasspath += configurations.provided
idea {
module{
scopes.PROVIDED.plus += [configurations.provided] // for Gradle 2.0
}
}
I have the same problem, and I found some solutions.But I don't understand.
http://www.sinking.in/blog/provided-scope-in-gradle/
Solved thie problem by using the android-apt gradle plugin.
see https://bitbucket.org/hvisser/android-apt/overview
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "org.ligboy.test.card.module1"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
apt
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt 'com.android.support:support-v4:21.+'
apt 'com.google.code.gson:gson:2.2.+'
apt 'com.android.support:cardview-v7:+'
apt 'com.android.support:recyclerview-v7:+'
}
Fought with this for a while and found:
"provided" is part of gradle 1.3.0, but doesn't work properly.
"provided" works properly in gradle 1.5.0!
FYI: I had to delete my build directory after upgrading to 1.5.0 to remove the lib file from the .aar.