Classpath specific to module in IntelliJ Gradle project - android

I have an IntelliJ Gradle project which contains an Android module, a GWT module and a pure Java module.
Is there a way to add the classpath for 'com.android.tools.build:gradle:1.0.0' such that it is not in a buildscript?
Here is my 'build.gradle' for the Android module:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
// workaround for "duplicate files during packaging of APK" issue
// see https://groups.google.com/d/msg/adt-dev/bl5Rc4Szpzg/wC8cylTWuIEJ
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.1+'
}
And here is my top-level 'build.gradle'
allprojects {
repositories {
mavenCentral()
}
}
Thank you!

Related

The project is not a Gradle-based project. How do I open the project from the root directory?

I've been having this issue for a while and have been racking my brain.
I googled this answer here
Which the response is "Make sure you open the project from its root directory. i.e. the directory which contains the top level build.gradle file."
My question is: How the do I do that if I cloned the project from bitbucket?
Here's a screenshot of my file tree:
Thank you for any insights
Edit: Gradle files
// 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.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
app level:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '4.0.0'
def JacksonVersion = '2.6.0'
def GPSVersion = '6.5.87'
dependencies {
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:preference-v7:23.0.0'
}
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName "appname"
logLevel 'TRACE'
logAppenderConsole 'true'
}
}
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "appname"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
Your project is not Gradle based because settings.gradle and bulid.gradle are not in the IDE project directory, they are in that blacked-out subfolder under .idea and .gradle in your picture.
You must close this project. Open that other folder as an Android Studio Project, regardless of where you got that project from.
For library projects in Github, it would look like this. Anyone can clone this as-is and open as a project.
For apps, replace sample with app, and remove library
Most importantly, buildscript and allprojects section should not be in /app/build.gradle, only /build.gradle
Additionally, your Gradle build plugin is outdated
The top level should look like this:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The app level file should look like this:
apply plugin: 'com.android.application'
def AAVersion = '4.0.0'
def JacksonVersion = '2.6.0'
def GPSVersion = '6.5.87'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) //This is where your JARs go
implementation 'com.android.support:appcompat-v7:23.0.0'
implementation 'com.android.support:design:23.0.0'
implementation 'com.android.support:recyclerview-v7:23.0.0'
implementation 'com.android.support:preference-v7:23.0.0'
}
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "appname"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
You need to remove the android-apt plugin from it because the functionality is already included. If you later run into trouble, check this question.

firebase setup on android

I can't setup the updated version of firebase on android studio.
I've created json file of the project on the site firebase and copied it into the project and after coping lines in gradle:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
compile 'com.google.firebase:firebase-core:9.0.1'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
I get the following error:
failed to resolve: compile 'com.google.firebase:firebase-core:9.0.0'
How can I fix it?
I had the same problem. If you are using Android studio, you should then update google repository in SDK Manager.
Following is my build.grade(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "package name"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.firebase:firebase-core:9.0.0'
}
apply plugin: 'com.google.gms.google-services'
And this is my build.grade(project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.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()
}
}
Firebase is working based on Google Play Services. So please make sure you have the following sdk tools and they are updated to sync against the library versions of firebase that you are using.
SDK Tools installed for this project
Project level build.gradle file
// 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:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Module Level build.gradle file
apply plugin: 'com.android.application'
android {
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.devdeeds.firebaseauth"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
}
apply plugin: 'com.google.gms.google-services'

INSTALL_PARSE_FAILED_NO_CERTIFICATES with google-services plugin

I have a big project with different build types and flavors.
It is in production already more than half of the year and I've made more then hundred updates of its version.
Today I need to implement plugin: 'com.google.gms.google-services' into the project and can not run application because INSTALL_PARSE_FAILED_NO_CERTIFICATES.
I'm sure problem with configuration of build types and flavors but before apply plugin: 'com.google.gms.google-services' everything was always well working. Please, help me to understand what can conflict with google-services plugin.
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'retrolambda'
apply plugin: 'android-apt'
apply plugin: 'android'
apply plugin: 'com.google.gms.google-services'
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:2.4.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
mavenCentral()
mavenLocal()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://github.com/taplytics/Taplytics-Android-SDK/raw/master/AndroidStudio/" }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
dexOptions {
jumboMode = true
}
defaultConfig {
applicationId "com.examplepack.appp"
minSdkVersion 14
targetSdkVersion 23
versionCode 291
versionName "1.0.1.291"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
signingConfigs {
config {
storeFile file('certificate.jks')
storePassword 'examplepass'
keyAlias 'appl'
keyPassword 'examplepass'
}
}
buildTypes {
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
productFlavors {
stage {
}
dev {
}
prod {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/MANIFEST.MF'
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName "com.examplepack.appp"
}
}
retrolambda {
jdk "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home"
oldJdk System.getenv("JAVA6_HOME")
javaVersion JavaVersion.VERSION_1_6
}
dependencies {
.............
compile 'com.google.android.gms:play-services:8.1.0'
}
There is a known issue with version 1.4-beta2 or newer of the Gradle plugin.
You can use a older version for this to work
I've been dealing with this issue for a while. I decided to try every combination of com.android.tools.build:gradle and com.google.gms:google-services.
This work for me:
Project level:
com.android.tools.build:gradle:1.3.1
com.google.gms:google-services:1.3.1
App Level:
com.google.android.gms:play-services:8.1.0
I also upgraded Google Repository and Sdk Tools to latest versions. I'm using Android Studio 1.4.

Android studio "Failed to resolve: com.adobe.creativesdk"

I followed a tutorial online to implement adobe creative sdk and end up, when I sync my application I got these two errors
Error:(65, 14) Failed to resolve: com.adobe.creativesdk.foundation:auth:0.3.94
Show in File<br>Show in Project Structure dialog
Error:Failed to resolve: com.adobe.creativesdk.image:4.0.0:
Open File
Did some research but could not solve this new issue previous issue was solved. I'm new to android so how can i solve this issue?
build.gradle:
apply plugin: 'com.android.application'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
defaultConfig {
minSdkVersion 10
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
allprojects {
repositories {
mavenCentral()
jcenter()
mavenLocal()
maven {
url "${project.rootDir}/creativesdk-repo/release"
}
}
}
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile 'com.adobe.creativesdk.foundation:auth:0.3.94'
compile 'com.adobe.creativesdk.image:4.0.0'
}
There is an issue in your dependencies block. Note that the line for the Image Editor UI component should be written as:
compile 'com.adobe.creativesdk:image:4.0.0'
Before the word image, there should be a colon, not a period.
If after that you are still having trouble with the dependencies, please see this answer.

Android Studio 0.5.3 android.compileSdkVersion is missing

I'm using Android studio 0.5.3
I keep getting :
Gradle 'OpenBook' project refresh failed:
Cause: android.compileSdkVersion is missing!
Gradle settings
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
sourceSets {
main {
manifest.srcFile '/MyApp/src/main/AndroidManifest.xml'
}
}
}
And My App Buid.gradle
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
sourceSets {
main {
manifest.srcFile '/src/main/AndroidManifest.xml'
}
}
}
dependencies {
// compile 'com.android.support:appcompat-v7:+'
compile project("libraries:library-toast")
compile project("libraries:Volley")
compile project("libraries:actionbarsherlock")
compile project("libraries:Dialoglibrary")
compile project("libraries:google-play-services_lib")
compile project("libraries:PullToRefreshlibrary")
compile project("libraries:facebook")
compile project("libraries:SlidingTabBarlibrary")
compile project("libraries:AndroidPlot-Core")
compile project("libraries:SignUpModule")
compile project("libraries:Jars")
compile project("libraries:UpdateChecker")
compile "com.mixpanel.android:mixpanel-android:4.0.0#aar"
}
Not Sure what to do.
Thanks for any help
You have specified "compileSdkVersion 19" in your build file. Seems like you are missing that SDK (can you post more of the output with the error in it) You need to make sure that you have installed the right SDK using the SDK manager in Android Studio.
Jake Wharton has created a new gradle plugin to automatically keep the SDKs updated https://github.com/JakeWharton/sdk-manager-plugin

Categories

Resources