Android Studio compiles but java source is full of errors - android

I am having some problems with Android Studio 0.1.5.
My app compiles and runs on my device.
But the java source code is full of red errors with
Cannot resolve Symbol
This only seems to happen with components that are in libs (ex Roboguice)
Here is my build.gradle (though the problem looks more on Android Studio)
build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android'
dependencies {
compile files(
'libs/GoogleAdMobAdsSdk-6.3.1.jar',
'libs/gson-2.2.2.jar',
'libs/guice-3.0-no_aop.jar',
'libs/javax.inject-1.jar',
'libs/roboguice-2.0b4.jar',
'libs/roboguice-sherlock-1.0.jar',
)
compile project(':libraries:ActionBarSherlock')
compile project(':libraries:android-ColorPickerPreference')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Do you have any hints?
Thanks.

I solved by selecting those libraries and then added as library.

Related

Android Studio: A mess of Gradle build versions and compilation errors

When I import projects from github into Android studio I see various errors related to the gradle version. For all the miseries of Eclipse I dont ever remember needing to do an upgrade every time to all sorts of different reasons. Usually it was SDK only.
I see a lot of errors along the lines of:
Error:failed to find Build Tools revision 21.1.0
Install Build Tools 21.1.0 and sync project
Failed to apply plugin [id 'com.android.application'] Gradle version 2.1 is required. Current version is 2.2.1. If using the gradlewrapper, try editing the distributionUrl in /Users/Mac1/Downloads/u2020-dagger2 /gradle/wrapper/gradle-wrapper.properties to gradle-2.1-all.zip
It seems odd that a system designed to reduce the complexity of dependencies would demand the installation of old versions of gradle or build tools. Why does this kind of thing happen. Does this mean it has no build tools or just not that version? Does it mean it must be the old version? It certainly seems to be encouraging backward compatibility by insisting in installing old versions of everything. Gradle, build tools etc. I don't mean to be rude, so I'll keep quiet about what I think of this. In the meantime, what are we supposed to do?
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
allprojects {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}
Here is project level build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 21
buildToolsVersion '21.1.0'
defaultConfig {
applicationId 'dagger.demo'
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName '1.0'
}
}
dependencies {
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
provided 'org.glassfish:javax.annotation:10.0-b28'
}
First, make sure you have the latest Gradle version or atleast 2.2.1. Then update your build.gradle:
Top build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3' // <-- updated
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
allprojects {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}
App build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 22
buildToolsVersion '21.0.0'
defaultConfig {
applicationId 'dagger.demo'
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName '1.0'
}
}
dependencies {
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
provided 'org.glassfish:javax.annotation:10.0-b28'
}

Android Studio showing compiler errors for no reason

This started happening once I imported jcodec (http://jcodec.org/) for Android into the Studio as a module. The actual project itself compiles fine and works as expected on both devices and emulators but the compiler marks everything involving non-custom libraries as errors. Operations involving custom classes within the project does not have the compiler errors.
I tried the following:
1) Invalidate/Cache restart
2) Deleted the .idea folder and .iml files and reimported the whole project
3) Added the library via Project Structure and Synced Project with Gradle files
The worst part is that this inline compiler error happens for all projects in Android Studio (new and old) now.
I am using Android Studio version 0.5.4.
Is there anything I can do to fix this? Does it have anything to do with jcodec?
jcodec build.gradle files
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 16
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
}
main project build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 16
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:support-v4:19.1.0'
compile files('libs/android-async-http-1.4.4.jar')
compile project(':jcodec')
}

Android Studio: Manifest merging failed for adding aar for sherlock action bar

I tried adding sherlock as an aar using gradle and it states an error saying "manifest merging failed. See console for more info".
Where exactly is the console ? I am using Windows, I see no windows in Android Studio claiming to be a console. I presume I would get to see more info here ?
This is my gradle file, my minsdk and tarjetsdk are the same in my manifest and my build.gradle.
Anyone had this and fixed it ?
Here is my gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0','com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
}
Thanks in advance
I guess targetSDK is higher in ABS.
Check console out and set your targetSDK to 18.

Android Studio: apache.http.entity.mime does not exist

I have tried to send a picture with http-post, like it´s described here: Sending images using Http Post
I have downloaded the libarys and put them into "libs", but AndroidStudio says:
"Error: Gradle: error: package org.apache.http.entity.mime does not exist"
How can i solve this problem, any ideas?
Thanks for your help.
Edit:
My build.gradle file contains:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
}
I have downloaded the apache-mime4j-0.6.rar and httpmime-4.1.2.jar and put them into "libs". Then i clicked in AndroidStudio on File/ProjectStructure and i have add the two folders.
Maybe its helpfull, if i post the error message:
http://i.stack.imgur.com/OnSaZ.png

Android Studio roboguice.xml syntax errors

I've referenced roboguice 2.0 in my new Android project build with Android Studio, here is my build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile files('/libs/android-support-v4.jar')
compile 'org.roboguice:roboguice:2.0'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 16
}
}
Both gradle clean and gradle build run successfully but the IDE is reporting the error Element resources must be declared in roboguice.xml
Am I missing something or is this a bug in the IDE?
Mystery solved,
I've accidentally copied roboguice.xml to res/menu instead of res/values

Categories

Resources