Here is my build.gradle file
when I compile it always says 'cannot find symbol class HtmlFetcher' which is inside the de.jetwick.snacktory dependency
jar file of snacktory library is downloaded into local gradle cache
but it is not including it into project.
what might be a problem?
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
maven {url "https://github.com/karussell/mvnrepo/raw/master/releases"}
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'de.jetwick:snacktory:1.1'
compile fileTree(dir: 'libs', include: '*.jar')
}
Upgrade to Android Studio 0.4.3. There are bugs with adding dependencies that have been fixed since 0.4.0.
compile fileTree(dir: 'libs', include: '*.jar')
That is the same line I use to compile my libs directory. I'm not sure if it's the version, as I've been using the above gradle line since 0.3 or so, and it's worked fine.
The only other thing to check would be the location of your libs folder.
Your libs folder needs to be inside of your Module.
Android studio projects are the same as IntelliJ projects meaning that the directory structure should be: ProjectName/ModuleName/libs
That means you need a libs directory on the same level as your src directory and build.gradle file. Double check it's in the right location.
Related
As i change my Windows OS from 8.1 to 10..After Installing windows 10,I start Installed Android Studio 1.5.1.After Installing Android Studio,I have downloaded SDK...After this the Android Studio Opens well..Then i started doing my project..I have created new project..And i am in need of including Firebase to my project..So i have Included respective dependencies for that..
build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.projects.ajayjayendran.sample"
minSdkVersion 15
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'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.firebase:firebase-core:10.2.3'
compile 'com.google.firebase:firebase-database:10.2.3'
compile 'com.google.firebase:firebase-storage:10.2.3'
compile 'com.firebaseui:firebase-ui-database:1.1.9'
}
apply plugin: 'com.google.gms.google-services'
build.gradle(Project:Sample)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I am getting this following Error..I know that this Question is already in Stack Overflow but it does not resolve my problem..I have lost one day..
In old Questions,they gave solution as Installing Google Repository and Google play Service in SDK Manager..Even after Installing this,I am getting this Same Error..Please anyone here Resolve my problem..
Thanks in Advance :)
Created a new project, copied your gradle files, and managed to reproduce the errors. However, I managed to make it compile smoothly after a few changes.
I don't know where you got 10.2.3 versions, but I edited the Firebase dependencies back to 10.2.4 (see versions here).
I'm presuming it's just a typo, but the Firebase UI library doesn't have a specified 1.1.9 version (see the versions here). I changed mine to 1.1.0.
After clean building the project with the changes above, it started to throw a different error. One where you have to make sure that the Compile SDK version, build tools version, and the support library versions are aligned (see this answer).
So from the above post, I edited out the compileSdkVersion to 25 and used the latest support library versions (25.x.x).
The resulting app gradle file (builds with no problems):
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.gradle.testapp2"
minSdkVersion 15
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'])
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.google.firebase:firebase-core:10.2.4'
compile 'com.google.firebase:firebase-database:10.2.4'
compile 'com.google.firebase:firebase-storage:10.2.4'
compile 'com.firebaseui:firebase-ui-database:1.1.0'
}
apply plugin: 'com.google.gms.google-services'
P.S.: It's also advisable to have your Android SDK Tools updated.
I have started with greendao 3.2. I added greendao jar in libs folder and added it as library. I generated my entities using greendao-generator. It generates entities but the generated entities java some annotations and android studio is giving error on these annotations.It is giving an error cannot find "org.greenrobot.greendao.annotation.*". How to resolve this?
Probably you didn't add the library in your app module . First of all rather than using jar , you can use gradle dependency . In your generator project add the following dependency
compile 'org.greenrobot:greendao-generator:3.2.0'
So the gradle file of your generator module , should be look like this
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.greenrobot:greendao-generator:3.2.0'
}
And in your gradle file (module app) add the following
compile 'org.greenrobot:greendao:3.2.0'
Your main gradle file (module app) should be like this
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.tcs.a1003548.greendao"
minSdkVersion 14
targetSdkVersion 24
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:24.2.0'
compile 'org.greenrobot:greendao:3.2.0'
}
Why are you putting .jar in libs folder and not using Gradle for dependency management? This quickly leads to dependency hell. It is a lot easier.
Inside main build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.0'
}
}
Inside application build.gradle:
apply plugin: 'org.greenrobot.greendao'
dependencies {
compile 'org.greenrobot:greendao:3.2.0'
}
I saw the sample here to use scala with gradle plugin. I created a new android studio project. These are my gradle builds
Project build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath "jp.leafytree.gradle:gradle-android-scala-plugin:1.4"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Module app build.gradle
apply plugin: "com.android.application"
apply plugin: "jp.leafytree.android-scala"
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.ashwinxd.escalaandroidapp"
minSdkVersion 21
targetSdkVersion 24
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:24.1.1'
compile "org.scala-lang:scala-library:2.11.7"
compile "org.scala-lang:scala-library:2.11.7"
compile "com.android.support:multidex:1.0.1"
compile "org.scalaz:scalaz-core_2.11:7.1.0"
}
The project compiles fine. There is no scala src directory generated. How do I proceed with using scala alongside java files? Is it necessary to use them in a source directory called scala? If so how do I generate it?
You have to create your own src/main/scala directory. That is where the scala gradle plugin looks for the scala source files. Just like the android plugin will look at src/main/java and src/androidTest/java.
That page describes you can customize that directory location at Put scala source files.
I have a project in Eclipse with gradlle.
I want to run the project on a physica device, but I do not see the option.
I select run tab, project just runs gradle.
Check below build.gradle file
apply plugin: 'java'
repositories {
jcenter()
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files ('libs/twitter4j-core-4.0.4.jar')
compile files ('libs/gson-2.2.2.jar')
compile files ('libs/agilio_rtmp-debug.jar')
compile files ('libs/facebook-android-sdk-4.14.1.jar')
compile files ('libs/agilio_rtmp-debug.jar')
}
When I select run:
I want to run the project on a physical device.
The task you want is app:installDebug, but that is assuming you have the correct project structure.
Since it isn't clear what the structure your project has, here is the recommended structure from the Android Gradle documentation.
settings.gradle
build.gradle # Top-level
app/ # A module named 'app'
build.gradle # Module-level
libs/
library-1.jar
library-2.jar
...
src/main/
AndroidManifest.xml
java/ # application package in here, then Java files in that
res/
This is the settings.gradle
include ':app'
Here is a top-level build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
Then, the module build.gradle with adjustments for your dependencies.
Most importantly - The top line here tells Gradle this is an android app, not a java app. This means you can run the various Android-related Gradle tasks like installDebug, which is the one you are looking for.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "xxxxxxxx"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
ext {
// Variables to keep libraries consistent
supportLibrary = '23+'
// Support Libraries dependencies
supportDependencies = [
design : "com.android.support:design:${supportLibrary}",
appCompatV7 : "com.android.support:appcompat-v7:${supportLibrary}"
]
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
// This line already compiles all jar files in the libs/ directory
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
// recommended
compile supportDependencies.design
}
I want to use view pager indicator library in android studio. As it is available for the maven and not for the gradle project yet so I am adding library folder in android studio and including it in app build.gradle file. Problem arises, when I compiled the project so it wont compile as both the app and library gradle files are using android-support-v4.jar files. I need to know how can I use the library in android studio.
settings.gradle
include ':app'
include ':library'
include ':sample'
app/build.gradle
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 project(':library')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
library.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android-library'
android {
sourceSets {
main {
java.srcDirs = ['src']
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
}
}
compileSdkVersion 19
buildToolsVersion '19.0.3'
}
dependencies {
compile files('libs/android-support-v4.jar')
// compile 'com.android.support:support-v4:19.+'
// compile fileTree(dir: 'libs', include: ['*.jar'])
}
Don't include the support library by adding a direct dependency to its jar file as you have in your library's build.gradle file. If you include it everywhere via the Maven-coordinate-style include, like your commented out line, the build system won't have trouble with duplicates:
dependencies {
compile 'com.android.support:support-v4:19.+'
}
Select "Projects" module in android studio.
download and unzip the ViewPagerIndicator-Library.
Create the libs folder under root folder and copy paste the library into that folder.
go to settings.gradle and add this line:
include ':libs:ViewPagerIndicator-Library'
add the compile project(':libs:ViewPagerIndicator-Library') in app's build.gradle model
Restart the studio and Have Fun ...