How to Set -Source 1.7 in Android Studio and Gradle

Gradle version 1.8 is required. Current version is 1.6

I am not sure if this will help you but here is what fixed it for me:

Open up this file in your project:

<Project>/gradle/wrapper/gradle-wrapper.properties

Edit the distributionUrl line and set it too:

distributionUrl=https\://services.gradle.org/distributions/gradle-1.8-all.zip

Rebuild your project.

Update: You might want to use gradle-2.8-all.zip now.

Android studio compile takes forever

Try set org.gradle.jvmargs setting in gradle.properties like the following:

org.gradle.jvmargs=-Xmx3g

Please pay attention that the first build of a big project after cleanup can take up to 10 mins or even a little more.

Some other tips:

  • update Android Gradle Plugin to the latest stable version (currently 7.1.3) and Gradle Version (currently 7.2). Refer to this document.

  • update Kotlin version to 1.6.10 or later.

  • update Android Studio and Build-Tools.

  • use JavaVersion.VERSION_11 for sourceCompatibility and targetCompatibility:

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_11
    targetCompatibility JavaVersion.VERSION_11
    }

    kotlinOptions {
    jvmTarget = "11"
    ...
    }
  • set android.enableJetifier=false in grade.properties.

Using Android Studio with Java 1.7

I went to Java SE Downloads and downloaded Java 7 again. The method mentioned above worked for Eclipse.

Running the installer from this manual download placed the JDK in /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home, which was accepted by Android Studio.

Gradle version 1.6 is required. Current version is 1.8-20130730220035+0000

I managed to fix my project through some combination of invalidating Android Studio cache, deleting .idea and .gradle directories and .iml files, restarting Studio, and reimporting the project:

Invalidate Cache confirm

on Mac OSX using Homebrew, brew install gradle then pick local gradle distribution and point to /usr/local/Cellar/gradle/1.7/libexec for gradle home:
local distribution

Gradle sync failed in android studio 3.6

Please update the class path to latest version and check

dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}

to

buildscript {
repositories {
google() //add here
jcenter()
maven { url "https://jitpack.io" }

}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
}
}

allprojects {
repositories {
google() //and here also
jcenter()
maven { url "https://jitpack.io" }

}
}

Build.gradle(app:)

apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion "25.0.3"

defaultConfig {
applicationId "com.graphhopper.android"
minSdkVersion 16
targetSdkVersion 29
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {

disable 'InvalidPackage'
}
}

dependencies {
compile(group: 'com.graphhopper', name: 'graphhopper-core', version: '0.9-SNAPSHOT') {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'org.openstreetmap.osmosis', module: 'osmosis-osm-binary'
exclude group: 'org.apache.xmlgraphics', module: 'xmlgraphics-commons'
}

compile 'org.mapsforge:vtm:0.6.0'
compile 'org.mapsforge:vtm-android:0.6.0'
compile 'org.mapsforge:vtm-android:0.6.0:natives-armeabi'
compile 'org.mapsforge:vtm-android:0.6.0:natives-armeabi-v7a'
compile 'org.mapsforge:vtm-android:0.6.0:natives-x86'
compile 'org.mapsforge:vtm-jts:0.6.0'
compile 'org.mapsforge:vtm-themes:0.6.0'
compile 'com.caverock:androidsvg:1.2.2-beta-1'
compile 'com.vividsolutions:jts:1.13'

compile 'org.slf4j:slf4j-api:1.7.21'
compile 'org.slf4j:slf4j-android:1.7.21'
}

Latest Android Studio - Problem adding Google Service Gradle plugin to build.gradle file

paste code for your build-script class file in project-level gradle.build file, here is an example :

    /**
* project-level - build.gradle file -- make sure buildscript is before
* plugins
**/
buildscript {
repositories {
mavenCentral()
}
dependencies {
// your classpath
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.41'
}
}

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.3' apply false
id 'com.android.library' version '7.1.3' apply false
id 'org.jetbrains.kotlin.android' version '1.6.20' apply false
}


task clean(type: Delete) {
delete rootProject.buildDir
}


Related Topics



Leave a reply



Submit